Howdie folks, I just need a simple indicator with alert that compares the candle body (open-close) of previous candle to the previous previous candle body. If the previous candle body is bigger than indicator will alert. I know candle body logic probably only a one liner, how would you write this?
- Compare a last candle to last i candles
- I will write an advisor free of charge
- candle size alert
-
Perhaps you should read the manual. OnCalculate - Event Handling - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up. -
One line? Not unless you want continuous alerts.
Not compiled, not tested, just typed.
int OnCalculate( const int rates_total, // size of input time series const int prev_calculated, // number of handled bars at the previous call const datetime& time{}, // Time array const double& open[], // Open array const double& high[], // High array const double& low[], // Low array const double& close[], // Close array const long& tick_volume[], // Tick Volume array const long& volume[], // Real Volume array const int& spread[] // Spread array ){ ArraySetAsSeries(time, true); static datetime timeCurr=0; datetime timePrev=timeCurr; timeCurr=Time[0]; if(timeCurr != timePrev){ ArraySetAsSeries(open, true); ArraySetAsSeries(close, true); double body1 = MathAbs( open[1] - close[1] ); double body2 = MathAbs( open[2] - close[2] ); if( body2 > body1) Alert("previous candle body is bigger"); } return 0; }
Not compiled, not tested, just typed.Was that so hard, that you couldn't attempt it?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register