Download MetaTrader 5

EMA Data missmatch ....

To add comments, please log in or register
frobber
15
frobber  

Hello

I am lost - maybe some gurus can help me ;)


My goal is to draw colored arrow in the chart exactly at the EMA line - but only when the difference from  current to previous candle is above/below a specific level.

So far so good ...

During an Uptrend - the arrow is displayed exactly on the EMA line in the chart and works as expected.

But on a downtrend the arrows are always drawn a bit below the EMA line... and I have no clue why !


example code:

MA1   = iMA (NULL, PERIOD_CURRENT, 21, 0, MODE_EMA, PRICE_CLOSE, 0);


example code for drawing function:

void Draw_up(int Code,int Fontsize,color LineColor, string Anchorpunkt) 

{  

         string objName = "up" + Time[1]; 

         ObjectCreate(objName, OBJ_TEXT, 0, Time[1], Anchorpunkt); 

         ObjectSetText(objName, CharToStr(Code), Fontsize, "Wingdings", LineColor); 

}

void Draw_down(int Code,int Fontsize,color LineColor, string Anchorpunkt)   

{  

         string objName = "down" + Time[1]; 

         ObjectCreate(objName, OBJ_TEXT, 0, Time[1], Anchorpunkt);

         ObjectSetText(objName, CharToStr(Code), Fontsize, "Wingdings", LineColor); 

}


I call the functions:

Draw_up(230,16,MediumBlue,MA1);

Draw_down(228,16,MediumBlue,MA1);


I tried to change the MA line in the chart from Close to all available price options but I couldnt find the settings to match my downtrend symbols ....

Any idea?

whroeder1
16575
whroeder1  
frobber:
MA1   = iMA (NULL, PERIOD_CURRENT, 21, 0, MODE_EMA, PRICE_CLOSE, 0);
  1. Please use SRC
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Why are you looking at the current bar for your MA but putting the arrow on the previous one?
Naguisa Unada
123
Naguisa Unada  
 //void Draw_up(int Code,int Fontsize,color LineColor, string Anchorpunkt)  
 void Draw_up( int Code, int Fontsize, color LineColor, double Anchorpunkt) 

 //void Draw_down(int Code,int Fontsize,color LineColor, string Anchorpunkt)    
 void Draw_down( int Code, int Fontsize, color LineColor, double Anchorpunkt)   

These are evident mistakes.

In either case, I think that it is much easier to prepare buffers to use "SetIndexArrow" than create objects.

To add comments, please log in or register