Moving average of Momentum MQL code. - page 2

To add comments, please log in or register
gouki1001
223
gouki1001  
lippmaje:
Can't read it. Format the code and use code tags.


#include <stdlib.mqh>

#include <stderror.mqh>



//--- indicator settings

#property indicator_separate_window

#property indicator_buffers 2



#property indicator_type1 DRAW_LINE

#property indicator_style1 STYLE_SOLID

#property indicator_width1 1

#property indicator_color1 0xFFAA00

#property indicator_label1 ""



//--- indicator buffers

double Buffer1[];

double Buffer2[];



double myPoint; //initialized in OnInit



void myAlert(string type, string message)

  {

   if(type == "print")

      Print(message);

   else if(type == "error")

     {

      Print(type+" | MT4I1 @ "+Symbol()+","+Period()+" | "+message);

     }

   else if(type == "order")

     {

     }

   else if(type == "modify")

     {

     }

  }



//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {   

   IndicatorBuffers(2);

   SetIndexBuffer(0, Buffer1);

   SetIndexEmptyValue(0, 0);

   SetIndexBuffer(1, Buffer2);

   SetIndexEmptyValue(0, 0);

   //initialize myPoint

   myPoint = Point();

   if(Digits() == 5 || Digits() == 3)

     {

      myPoint *= 10;

     }

   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 = rates_total - prev_calculated;

   //--- counting from 0 to rates_total

   ArraySetAsSeries(Buffer1, true);

   //--- initial zero

   if(prev_calculated < 1)

     {

      ArrayInitialize(Buffer1, 0);

     }

   else

      limit++;

   

   //--- main loop

   for(int i = limit-1; i >= 0; i--)

     {

      if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   

      //Indicator Buffer 1

      if(true //no conditions!

      )

   

         Buffer2[i] =  iMomentum(NULL, PERIOD_CURRENT, 14, PRICE_CLOSE, i);

         Buffer1[i]= iMAOnArray(Buffer2,0,14,0,MODE_SMA,0);

       

     I took out all the bits that i commented out its simple code. 

     }

   return(rates_total);

  }
Sergey Golubev
Moderator
109226
Sergey Golubev  
gouki1001:

...


Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button


gouki1001
223
gouki1001  
Sergey Golubev:


Thanks. 

lippmaje
384
lippmaje  
gouki1001:

Thanks. 

Still not formatted. Are you serious about getting help? Goodbye.
gouki1001
223
gouki1001  
lippmaje:
Still not formatted. Are you serious about getting help? Goodbye.

You are obviously not a programmer or a novice at mql. Thank you despite your incompetence.

12
To add comments, please log in or register