📅 财经日历 📊 实时波动 📈 大盘云图 📶 行情走势 🆚 投机情绪 🚀 今日热点

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

    2011-10-09 · 11168 阅读
    -- 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
    ""
    还没有人打赏,支持一下
    回复

    举报

     

    回答|共 23 个

    q543777345 LV5

    发表于 2012-11-21 22:58:35 | 显示全部楼层

    似曾相识的感觉  

    贞子 LV5

    发表于 2012-11-21 22:58:35 | 显示全部楼层

    刚刚接触EA ,楼主请发份给我…  

    后山俗人 LV5

    发表于 2012-11-21 23:54:18 | 显示全部楼层

    晕死也不多加点分  

    小林 LV3

    发表于 2012-11-21 23:54:18 | 显示全部楼层

    支持一下吧  

    zylzflzj LV3

    发表于 2014-11-15 23:39:25 | 显示全部楼层

    看看怎么样

    ivanlu LV3

    发表于 2014-11-18 23:23:41 | 显示全部楼层

    亏损中……………………

    几号个结合 LV3

    发表于 2014-11-24 02:39:51 | 显示全部楼层

    xiexiefenxiang

    wozbang LV3

    发表于 2014-12-22 10:15:40 | 显示全部楼层

    顶楼主~~~~~~~~~~~~~~~

    410934434 LV3

    发表于 2014-12-23 00:20:46 | 显示全部楼层

    我靠
    123下一页
    您需要登录后才可以回帖 登录 | 注册

    提醒: 禁止引战、谩骂、灌水内容

    微信二维码

    有问题联系客服