Pine script 将Pine脚本转换为MQL4或MQL5语言(简易EA)
有人能帮我把这个脚本转换成MQL4或MQL5吗?我尝试了一整天都没有成功,因为我对代码不太在行,但我相信这对你们中的一些人来说真的很容易,因为它是一个小代码。由于MT4/5已经完成了回溯测试,因此回溯测试部分没有必要 额外信息,因为stackoverflow要求提供更多详细信息: 我无法绕过cz部分,所以我的“Filt”的mql4方程不起作用; 我不知道它在哪里提到了购买的地段,但我相信这是最容易纠正的部分Pine script 将Pine脚本转换为MQL4或MQL5语言(简易EA),pine-script,mql4,mql5,Pine Script,Mql4,Mql5,有人能帮我把这个脚本转换成MQL4或MQL5吗?我尝试了一整天都没有成功,因为我对代码不太在行,但我相信这对你们中的一些人来说真的很容易,因为它是一个小代码。由于MT4/5已经完成了回溯测试,因此回溯测试部分没有必要 额外信息,因为stackoverflow要求提供更多详细信息: 我无法绕过cz部分,所以我的“Filt”的mql4方程不起作用; 我不知道它在哪里提到了购买的地段,但我相信这是最容易纠正的部分 // =========================================
// ============================================ PROCESS INPUTS ============================================= //
tClose = security(tickerid, period, open)
// Inputs
ssPeriod = input(defval = 20, title = "Period length", type = integer) // Period of bars to look back on
// The number of previous data points to use when building the EMA
number_of_periods = input(title="Number Of Periods", type=integer, defval=1, minval=1)
// The type of price to use when building the EMA (close, open, high, low, etc)
data_source = input(title="Data Source", type=source, defval=hlc3)
// The time-frame to use when building the EMA
// Value must be greater than or equal to your current time-frame
// Min value is 1 minute. Max value is 1440 minutes(1 day)
data_source_period = input(title="Data Source Period (Minutes)", type=integer, defval=1440, minval=1, maxval=14400)
// === INPUT BACKTEST RANGE ===
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
FromYear = input(defval = 2018, title = "From Year", minval = 2000)
ToMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)
ToDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31)
ToYear = input(defval = 9999, title = "To Year", minval = 2000)
// === FUNCTION EXAMPLE ===
start = timestamp(FromYear, FromMonth, FromDay, 00, 00) // backtest start window
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59) // backtest finish window
window() => time >= start and time <= finish ? true : false // create function "within window of time"
valid_inputs = true
if isintraday
if data_source_period < interval
valid_inputs := false // why show a 5 minute EMA on a 4 hour chart
else
valid_inputs := false // this version only supports intraday charts
// =============================================== BUILD EMA =============================================== //
a1 = exp(-1.414*3.14159 / ssPeriod)
b1 = 2*a1*cos((3.14159/180)*(1.414*180 / ssPeriod))
c2 = b1
c3 = (-a1)*a1
c1 = 1 - c2 - c3
Filt = c1*(tClose + nz(tClose[1])) / 2 + c2*nz(Filt[1]) + c3*nz(Filt[2])
// Short Smooth
plot(Filt, title = "Short", style = line, color = red, transp = 0, linewidth = 1) // Plot it
len1 = input(31, minval=1, title="EMA1 (Slow)")
src1 = input(open, title="EMA1 Source")
ema1 = ema(src1, len1)
// Default to an EMA on the current time-frame
ema_values = ema(data_source, number_of_periods)
// Get the price feed for the specified price type and time-frame
price_feed_for_ema = security(tickerid, tostring(data_source_period), data_source)
if valid_inputs
number_of_periods_normalized = number_of_periods * data_source_period / interval
ema_values := ema(price_feed_for_ema, number_of_periods_normalized)
// Long
plot(series=ema_values, title = "Long", style=line, linewidth=1, color=green)
//extra
len12 = input(73, minval=1, title="Slow EMA 12")
src = close
ema12 = ema(src, len12)
colFinal2 = gray
p4=plot(ema12, title="Slow EMA 12", style=line, linewidth=2, color=black)
// extra
len7 = input(30, minval=1, title="Slow EMA 7")
ema7 = ema(src, len7)
plot(ema7, title="Slow EMA 7", style=line, linewidth=1, color=purple)
longCondition = crossunder(ema12, ema_values)
shortCondition = crossover(ema12, ema_values)
if (longCondition)
strategy.entry("Go Long Entry", strategy.long, when = window())
if (shortCondition)
strategy.entry("Go Short Entry", strategy.short, when = window())
//================================================================================================================================================================================================================================================================================================================================================//
tClose=安全性(tickerid、period、open)
//投入
ssPeriod=input(deffal=20,title=“Period length”,type=integer)//要回顾的条形图的周期
//构建EMA时要使用的先前数据点的数量
周期数=输入(title=“周期数”,type=integer,deffal=1,minval=1)
//构建EMA时使用的价格类型(关闭、打开、高、低等)
数据源=输入(title=“数据源”,type=source,deffal=hlc3)
//构建EMA时使用的时间框架
//值必须大于或等于当前时间范围
//最小值为1分钟。最大值为1440分钟(1天)
数据源时段=输入(title=“数据源时段(分钟)”,类型=整数,定义值=1440,最小值=1,最大值=14400)
//==输入回测范围===
FromMonth=输入(defval=1,title=“From Month”,minval=1,maxval=12)
FromDay=输入(defval=1,title=“From Day”,minval=1,maxval=31)
FromYear=输入(defval=2018,title=“From Year”,minval=2000)
ToMonth=输入(defval=12,title=“To Month”,minval=1,maxval=12)
今天=输入(defval=31,title=“今天”,minval=1,maxval=31)
ToYear=输入(defval=9999,title=“To Year”,minval=2000)
//==函数示例===
开始=时间戳(FromYear、FromMonth、FromDay、00、00)//反向测试开始窗口
finish=时间戳(今年,明天,今天,23,59)//回溯测试完成窗口
window()=>时间>=开始和时间请有人帮帮我?至少在cz部分?