I am trying to write an EA but I have a problem.
I want it to look at stochastic on multiple timeframes.
So I wrote my "if" statement with two iStochastic sentences with 4h and daily chart selected. And with && between the two, but when I backtest I look at the Stochastic and it will buy before its under 20!
if((iStochastic(NULL,PERIOD_H4,5,3,3,MODE_SMA,1,MODE_MAIN,0)<20)&&(iStochastic(NULL,PERIOD_D1,5,3,3,MODE_SMA,1,MODE_MAIN,0)<20))
Help!
The "if" statement is right. But don't forget that you watch (both on H4 and D1) the current bar and the current bar isn't finished (The Stochastics are changed until the current bar is finished).
But why would it place a trade before the two criteria are met?
the if statement isn't right .
iStochastic : The function returns the handle of the Stochastic Oscillator indicator and not the value.
You need to use copyBuffer to get the values.
the if statement isn't right .
iStochastic : The function returns the handle of the Stochastic Oscillator indicator and not the value.
You need to use copyBuffer to get the values.
But why would it place a trade before the two criteria are met?
So I changed my code a little bit to see if I could get around doing stuff I don't already know. And now I'm also getting the errors Unbalanced Parenthesis, and Unexpected End of Program... And I've tried adding a close parenthesis in multiple places but cant find where to place it. (I have an extra "{" right before "Get Handles") Any Help would be Great! Thanks
I've seen your code and now I'm sure you need help because you are really confused. You tried to mix MQL4 and MQL5. It will never work. I suppose you want to edit an old code that someone else created. You should go back to the original code and persuade someone to edit the code by your rules.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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 want it to look at stochastic on multiple timeframes.
So I wrote my "if" statement with two iStochastic sentences with 4h and daily chart selected. And with && between the two, but when I backtest I look at the Stochastic and it will buy before its under 20!
if((iStochastic(NULL,PERIOD_H4,5,3,3,MODE_SMA,1,MODE_MAIN,0)<20)&&(iStochastic(NULL,PERIOD_D1,5,3,3,MODE_SMA,1,MODE_MAIN,0)<20))
Help!