Скопировать индикатор написанный на mql4 в Ninjatrader.

MQL4 Indicators Other C++

Specification

Здравствуйте, нужно сделать, индикатор для терминала Ninjatrader, такой как приложен mq4.

#property strict
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_plots   5
#property indicator_minimum 0
#property indicator_maximum 100

input int MAPeriod=200;//Price chanel period
input ENUM_MA_METHOD MAMethod=MODE_EMA;//MA Method
input ENUM_APPLIED_PRICE ApPrice=PRICE_CLOSE;//Applied price
input color clrLine=clrLime;//Color line

double ma[],up[],dn[],matrend[],line[];
string realVal="";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
    realVal=_Symbol;
   IndicatorShortName("P_C_O");
   SetIndexBuffer(0,line);
   SetIndexBuffer(1,ma);
   SetIndexBuffer(2,up);
   SetIndexBuffer(3,dn);
   SetIndexBuffer(4,matrend);

   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,clrLine);
   SetIndexStyle(1,DRAW_NONE);
   SetIndexStyle(2,DRAW_NONE);
   SetIndexStyle(3,DRAW_NONE);
   SetIndexStyle(4,DRAW_NONE);

   SetLevelValue(0,20);
   SetLevelValue(1,80);
   SetLevelValue(2,50);

   SetIndexLabel(0,realVal+" Price");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int limit;
   if(rates_total<=1){ return(0); }
//--- last counted bar will be recounted
   limit=rates_total-prev_calculated;
   if(prev_calculated>0)
      limit=limit+2;

   for(int x=limit-1; x>=0; x--)
     {
      ma[x]=EMPTY_VALUE; up[x]=EMPTY_VALUE; dn[x]=EMPTY_VALUE; matrend[x]=EMPTY_VALUE;  line[x]=EMPTY_VALUE;
      double mal=iMA(realVal,_Period,MAPeriod,0,MAMethod,ApPrice,x);
      double ma1=iMA(realVal,_Period,1,0,MAMethod,ApPrice,x);

      mal=NormalizeDouble(mal,_Digits);
      ma[x]= mal;
      if(x>=rates_total-1)
        {
         matrend[x]=mal;
           }else{
         // not first
         int lwst1 = iLowest(realVal, _Period, MODE_LOW, MAPeriod, x);
         int hgst1 = iHighest(realVal, _Period, MODE_HIGH, MAPeriod, x);

         if(iHigh(realVal,_Period,hgst1)<iHigh(realVal,_Period,hgst1+1))
           {
            up[x]=up[x+1]; dn[x]=dn[x+1];
           }
         if(iLow(realVal,_Period,lwst1)>iLow(realVal,_Period,lwst1+1))
           {
            dn[x]=dn[x+1]; up[x]=up[x+1];
           }

         if(up[x]==EMPTY_VALUE)
           {
            up[x]=iHigh(realVal,_Period,hgst1);
           }
         if(dn[x]==EMPTY_VALUE)
           {
            dn[x]=iLow(realVal,_Period,lwst1);
           }
         // change up and dn 
         if(up[x]!=up[x+1] || dn[x]!=dn[x+1])
           {
            matrend[x]=mal;
              }else{
            matrend[x]=matrend[x+1];
           }
         line[x]=NormalizeDouble(100-((up[x]-ma1)*100/(up[x]-dn[x])),2);

        }

     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------


Responded

1
Developer 1
Rating
(564)
Projects
844
73%
Arbitration
15
53% / 13%
Overdue
193
23%
Free
2
Developer 2
Rating
(20)
Projects
43
30%
Arbitration
6
0% / 50%
Overdue
17
40%
Free
Published: 1 code
3
Developer 3
Rating
(4)
Projects
5
40%
Arbitration
1
0% / 100%
Overdue
0
Free
Published: 1 code

Project information

Budget
30+ USD
Deadline
from 3 to 10 day(s)