Using custom inputs for an EMA in MQL5

Viewed 18

So the question I have, is how to use a custom input to use for an EMA in MQL5.

I want to use the real body in pips from only the green candles.

double      greenCandle =     close > open;
double      openGC =          greenCandle ? open : 0;
double      closeGC =         greenCandle ? close : 0;
double      GCRBAdif =        GCRBAclose - GCRBAopen;

So "GCRBAdif" is the real body of only green candles. but how would I use "GCRBAdif" to plot an EMA?

This is how it looks in pine script if it helps anyone:

//---------------------------------
// taking the open and close of only the red candles
openGC =    greenCandle ? open : 0
closeGC =   greenCandle ? close : 0

// calculating the exponantial moving average of the open and close from the green candles 
// RGRBA = GreenCandleRealBodyAverage
GCRBAopen =     ta.ema(openGC, 100) 
GCRBAclose =    ta.ema(closeGC, 100)

// defining the size of the real body 
GCRBAdif =      GCRBAclose - GCRBAopen

If someone could help, that would be great. Thanks in advance!

0 Answers
Related