求把fxcm里面的EWN艾略特波浪数目指标改成MT4可以用的代码!
-- The indicator is based on EWO. -- The formula of EWO is described in the Kaufman "Trading Systems and Methods" chapter 14 "Behavioral techniques" (page 358-361) -- Indicator profile initialization routine -- Defines indicator profile properties and indicator parameters function Init() indicator:name(resources:get("name")); indicator:description(resources:get("description")); indicator:requiredSource(core.Bar); indicator:type(core.Oscillator); indicator.parameters:addInteger("Trigger", resources:get("param_Trigger_name"), resources:get("param_Trigger_description"), 70, 2, 1000); indicator.parameters:addInteger("Period", resources:get("param_Period_name"), resources:get("param_Period_description"), 20, 2, 1000); indicator.parameters:addColor("clrEWV", resources:get("param_clrEWV_name"), resources:get("param_clrEWV_description"), core.rgb(255, 0, 0)); end -- Indicator instance initialization routine -- Processes indicator parameters and creates output streams -- Parameters block local Trigger; local Period; local first; local source = nil; local hMean = nil; local trend = nil; local hiOsc = nil; local hiOsc2 = nil; local hiPrice = nil; local hiPrice2 = nil; local ewo = nil; -- Streams block local EWN = nil; -- Routine function Prepare() Trigger = instance.parameters.Trigger; Period = instance.parameters.Period; source = instance.source; first = source:first() + Period + 35; ewo = core.indicators:create("EWO", source); local name = profile:id() .. "(" .. source:name() .. ", " .. Trigger .. ", " .. Period .. ")"; instance:name(name); hMean = instance:addInternalStream(0, 0); trend = instance:addInternalStream(0, 0); hiOsc = instance:addInternalStream(0, 0); hiOsc2 = instance:addInternalStream(0, 0); hiPrice = instance:addInternalStream(0, 0); hiPrice2 = instance:addInternalStream(0, 0); EWN = instance:addStream("EWN", core.Line, name, "EWN", instance.parameters.clrEWV, first) EWN:addLevel(0); EWN:addLevel(5); end -- Indicator calculation routine function Update(period, mode) ewo:update(mode); hMean[period] = -100000; trend[period] = 0; hiOsc[period] = -999; hiOsc2[period] = -999; hiPrice[period] = -999; hiPrice2[period] = -999; if period >= first then local wave = EWN[period - 1]; local hmean = hMean[period - 1]; local i = 0; for i = period - 5, period do local newHMean = (source.high + source.low) / 2; if hmean < newHMean then hmean = newHMean; end end local range = core.rangeFrom(period - Period + 1, Period); local lowest = core.min(ewo.DATA, range); local highest = core.max(ewo.DATA, range); local last = ewo.DATA[period]; local oldTrend = trend[period - 1]; local newTrend = oldTrend; if newTrend == 0 then if (last == highest) then newTrend = 1; end if (last == lowest) then newTrend = -1; end end local trigger = Trigger / 100; if (lowest < 0 and newTrend == -1 and last > (-1 * trigger * lowest)) then newTrend = 1; end if (highest > 0 and newTrend == 1 and last < (-1 * trigger * highest)) then newTrend = -1; end local mean = (source.high[period] + source.low[period]) / 2; local osc = hiOsc[period - 1]; local osc2 = hiOsc2[period - 1]; local price = hiPrice[period - 1]; local price2 = hiPrice2[period - 1]; if newTrend == 1 and oldTrend == -1 and last > 0 then osc = last; price = mean; wave = 3; end if wave == 3 then if price < mean then price = mean; end if osc < last then osc = last; end if last = 0) then wave = 5; osc2 = last; price2 = mean; elseif (wave == 5) then if price2 < mean then price2 = mean; end if osc2 < last then osc2 = last; end end if (wave == 5 and osc2 > osc and newTrend == 1) then wave = 3; osc = osc2; price = price2; osc2 = -999; price2 = -999; elseif (wave == 5 and newTrend == -1) then wave = 3; osc = -999; osc2 = -999; price = -999; price2 = -999; end EWN[period] = wave; hMean[period] = hmean; trend[period] = newTrend; hiOsc[period] = osc; hiOsc2[period] = osc2; hiPrice[period] = price; hiPrice2[period] = price2; end end |
打赏
最新创建圈子
- 新闻EA运行效果图圈 2019-05-05
圈主:admin 帖子:1