Please help! How to show MA cross-over on chart at MA cross level NOT at the price level.. Thanks!

 

I would like to know how to show MA cross-over at MA cross level (at the lines) NOT at the price level (at the candles)..

I was looking for some sort of function like " SetIndexPosition(Absolute) " i.e. would display the drawing (e.g. arrow or circle) exactly where the cross happened.

Is there a way to do that?

Any help would be much much appreciated! Thanks! ; )


my current code of that section, not sure if this would be in that section or not..!?

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

//| Custom indicator initialization function                         |

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

int init()

  {

//---- indicators

   SetIndexStyle(0, DRAW_ARROW, EMPTY,3); 

   SetIndexArrow(0, 233);

   SetIndexBuffer(0, CrossUp);

   SetIndexStyle(1, DRAW_ARROW, EMPTY,3);

   SetIndexArrow(1, 234);

   SetIndexBuffer(1, CrossDown);

//----
Step on New Rails: Custom Indicators in MQL5
Step on New Rails: Custom Indicators in MQL5
  • www.mql5.com
Finally we've got an opportunity to try the new trade terminal - MetaTrader 5. No doubt, it is noteworthy and has many new features as compared to its predecessor. The important advantages of this platform among others are: Essentially modified language allowing now to use the object-oriented programming, still allowing to use the rich...
 
Fred4X: I would like to know how to show MA cross-over at MA cross level (at the lines) NOT at the price level (at the candles)..
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. If you put the MAs on the chart, they show you the cross. No code required.

  3. You can only draw an arrow at a candle or a line connecting two. You can't draw where they crossed (between two candles.) A line connecting bar 2 onward is the best you can do.
  4. Compute the level where they cross:
    F = F2 + T(F1-F2)                          // \ Assuming MAs moved 
    S = S2 + T(S1-S2)                          // / linear in time.
    
    F2 + Tc(F1-F2) = S2 + Tc(S1-S2)            // The cross is when F == S solve for Tc.
    
    F2-S2 = t(S1-S2)-t(F1-F2) = t(S1-S2 - F1+F2)
    Tc = (F2-S2) / (S1-S2 - F1+F2)
    
    Fc = Sc = F2 + Tc(F1-F2) = S2 + Tc(S1-S2)  // Compute the cross price at time of cross.
 
Thank you for prompt reply William! ; )