stochastics indicator overbought and oversold expert advisor

 

Hi everyone,

i am currently working on an EA that will place a buy order when stochastics is below 80 and a sell order when it is above 20,

so i came up with this instruction, buy if iStochastics(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,1)<80

AND sell if iStochastics(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,1)>20

but i discovered that it still buy when stoch is already above 80 and also sell when stoch was already below 20 level on the previous bar.

Does anyone no what could be wrong with my instructions?

any suggestion would be highly appreciated.

thanks.

 
Do you use Buy & Sell Variables when Sto changes? If yes, are they Static or Global? If no, then I'll need to see the entire code to help further.
 
ubzen:
Do you use Buy & Sell Variables when Sto changes? If yes, are they Static or Global? If no, then I'll need to see the entire code to help further.


hi ubzen,

thanks for your response,i don't understand what you mean by Static or Global,but i have attached the code for you to check,

expecting your reply

Files:
asiwaju1.mq4  14 kb