I have multi timeframe supertrend indicator with code as below (unfortunately I cannot display all code due to limitation of character to send at forum
I want to use this indicator as a trigger to open position on my EA with following rules :
1) When color of indicator is green on H4 timeframe, and color of indicator just changed from red to green on M15 timeframe, then open buy
2) When color of indicator is red on H4 timeframe, and color of indicator just changed from green to red on M15 timeframe, then open sell
I use iCustom to call this indicator, and got the value : 1 point something when the line is green, and millions when the line is red. So I conclude that if value<2 on H4 I will prepare buy position only and when value>2 on H4 then I will prepare sell position only.
So, I made a script like below
I compiled my EA without any error, but when I backtested the EA, it open buy and sell based on Super_trend and Super_trend2 only (M15 TF), and disregard Super_trend_H41 result.
I think I made mistake when calling the indicator, but I don't know exactly my mistake.
Could anyone help me to solve this problem?
Thank you,
Super_trend = iCustom(Symbol(),PERIOD_M15,"MQLTA MT4 Supertrend Multi-Timeframe",0,1); Super_trend2 = iCustom(Symbol(),PERIOD_M15,"MQLTA MT4 Supertrend Multi-Timeframe",0,2); Super_trend_H41 = iCustom(Symbol(),PERIOD_H4,"MQLTA MT4 Supertrend Multi-Timeframe",0,0); and ...... bool buy()
Always post all relevant code (using Code button) or attach the source file.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem
In what function are those assignments?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have multi timeframe supertrend indicator with code as below (unfortunately I cannot display all code due to limitation of character to send at forum
I want to use this indicator as a trigger to open position on my EA with following rules :
1) When color of indicator is green on H4 timeframe, and color of indicator just changed from red to green on M15 timeframe, then open buy
2) When color of indicator is red on H4 timeframe, and color of indicator just changed from green to red on M15 timeframe, then open sell
I use iCustom to call this indicator, and got the value : 1 point something when the line is green, and millions when the line is red. So I conclude that if value<2 on H4 I will prepare buy position only and when value>2 on H4 then I will prepare sell position only.
So, I made a script like below
I compiled my EA without any error, but when I backtested the EA, it open buy and sell based on Super_trend and Super_trend2 only (M15 TF), and disregard Super_trend_H41 result.
I think I made mistake when calling the indicator, but I don't know exactly my mistake.
Could anyone help me to solve this problem?
Thank you,