The Pine Editor

12m

## The Pine Editor

``研究（“我的脚本”）``

``绘制图表（收盘）``

``//@version=4 study("My Script", overlay=true) plot(open, color=color.purple)``

``//@version=4 study("My Script", overlay=true) plotcandle(open, high, low, close)``

``//@version=4 study("My Script", overlay=true) colors = open >= close?color.red: color.green plotcandle(open, high, low, close)``

``//@version=4 study("My Script", overlay=true) colors = open >= close?color.red: color.green plotcandle(open, high, low, close, color=colors)``

## 绘制移动平均线(MA)

EMA与简单移动平均线(SMA)略有不同，它更看重最近的数据。它倾向于对突然的变化作出更多反应，并经常用于短期操作（例如，在日间交易中）。

### 简单移动平均线(SMA)

``plot(sma(close, 10))``

SMA基于前十天的数据。

### 指数移动平均线(EMA)

EMA的理解比较复杂，但不用担心。我们先来分析一下这个公式：

``EMA=（收盘价-前一天的EMA）*倍数-前一天的EMA``

``倍数=2/（EMA长度+1）``

``//@version=4 study("My Script", overlay=true) plot(sma(close, 10)) plot(ema(close, 10))``

### 内置脚本

……并点击设置的齿轮图标，在弹窗中轻松更改一些数值。

## 回溯测试

``//@version=4 strategy("ToDaMoon", overlay=true) enter = input(11000) exit = input(11300) price = close if (price <= enter) strategy.entry("BuyTheDip",strategy.long,comment="BuyTheDip") if (price >= exit) strategy.close_all(comment="SellTheNews")``

## 结合起来

``study(title="Binance Academy Script", overlay=true)``

``study(title="Binance Academy Script", overlay=true) emaLength = input(title="EMA Length", type=input.integer,defval=25, minval=0)``

``study(title="Binance Academy Script", overlay=true) emaLength = input(title="EMA Length", type=input.integer,defval=25, minval=0) emaVal = ema(close, emaLength)``

``study(title="Binance Academy Script", overlay=true) emaLength = input(title="EMA Length", type=input.integer,defval=25, minval=0) emaVal = ema(close, emaLength) rsiLength = input(title="RSI Length", type=input.integer,defval=25, minval=0)``

``study(title="Binance Academy Script", overlay=true) emaLength = input(title="EMA Length", type=input.integer, defval=25, minval=0) emaVal = ema(close, emaLength) rsiLength = input(title="RSI Length", type=input.integer, defval=25, minval=0) rsiVal = rsi(close, rsiLength)``

``study(title="Binance Academy Script", overlay=true) emaLength = input(title="EMA Length", type=input.integer,defval=25, minval=0) emaVal = ema(close, emaLength) rsiLength = input(title="RSI Length", type=input.integer,defval=25, minval=0) rsiVal = rsi(close, rsiLength) colors = close > emaVal and rsiVal > 50? color.green: color.red``

``study(title="Binance Academy Script", overlay=true) emaLength = input(title="EMA Length", type=input.integer,defval=25, minval=0) emaVal = ema(close, emaLength) rsiLength = input(title="RSI Length", type=input.integer,defval=25, minval=0) rsiVal = rsi(close, rsiLength) colors = close > emaVal and rsiVal > 50? color.green: color.red plot(emaVal, "EMA")``

``study(title="Binance Academy Script", overlay=true) emaLength = input(title="EMA Length", type=input.integer,defval=25, minval=0) emaVal = ema(close, emaLength) rsiLength = input(title="RSI Length", type=input.integer,defval=25, minval=0) rsiVal = rsi(close, rsiLength) colors = close > emaVal and rsiVal > 50?color.green: color.red plot(emaVal, "EMA") plotcandle(open, high, low, close, color=colors)``