客服热线:18391752892

求把fxcm里面的EWN艾略特波浪数目指标改成MT4可以用的代码!

   日期:2019-01-12     浏览:161    
马上注册,结交更多好友,下载更多资源

您需要 登录 才可以下载或查看,没有帐号?注册 -- 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
外汇交易有很大的风险性,本站所有资源均来自网络,请选择使用,如若出现亏损,本站不承担任何责任!


特别提示:本信息由相关企业自行提供,真实性未证实,仅供参考。请谨慎采用,风险自负。


0相关评论
相关行情
推荐行情
点击排行