i cant open position

 

hello, my EA cannot open position mean while it must open buy position when AC indicator have a negative number .

whats its wrong, please.

Files:
az.mq5  4 kb
 
market_kings :

hello, my EA cannot open position mean while it must open buy position when AC indicator have a negative number .

whats its wrong, please.

Just creating an object of some class is not enough. You need to initialize the indicator, you need to update the indicator data ...

 
Vladimir Karputov #:

Just creating an object of some class is not enough. You need to initialize the indicator, you need to update the indicator data ...

hello, i do what you said such as initialize the indicator and update the indicator data . what else you want me to do?

also , in this level i just want open position not extra things like: stop lost , take profit and close position.(please check new attached file)

Files:
az.mq5  8 kb
 
market_kings #:

hello, i do what you said such as initialize the indicator and update the indicator data . what else you want me to do?

also , in this level i just want open position not extra things like: stop lost , take profit and close position.(please check new attached file)

Forum on trading, automated trading systems and testing trading strategies

Help with MA cross and price crossing another MA

Vladimir Karputov, 2021.12.28 04:39

You have a global error - you create several indicator handles at each tick.

Remember: according to the MQL5 style, the indicator handle must be created ONCE and must be done in OnInit.

Example:

Creating an iMA indicator handle, getting indicator values


 
Vladimir Karputov #:




i correct it as you said,but on backup teste, it open two positions (buy and sell simultaneously) and don't set stop loss and take profit for them!?!

Files:
az.mq5  12 kb
 
market_kings # :



i correct it as you said,but on backup teste, it open two positions (buy and sell simultaneously) and don't set stop loss and take profit for them!?!

You haven't done anything: you create the indicator handle again and again AT EVERY TICK!

This is a gross mistake.

 

Vladimir you are right but please pay attention i fix last problems and now  in my strategy tester, EA open position correctly according to indicator signal but it cannot set take-profit or stop-loss therefore i think handle of indicator is not important now and we must fix this journals error (error when it want set take-profit and stop-loss):

cannot modify position cause position doesn't exist (meanwhile position is open)

Files:
az.mq5  12 kb
 
market_kings # :

Vladimir you are right but please pay attention i fix last problems and now  in my strategy tester , EA open position correctly according to indicator signal but it cannot set take-profit or stop-loss therefore i think handle of indicator is not important now and we must fix this journals error (error when it want set take-profit and stop-loss):

cannot modify position cause position doesn't exist (meanwhile position is open)

Until you correct your global mistake, you cannot move on. You shouldn't make such gross mistakes! Is it really so hard to read the help and correct your BIGGEST MISTAKE ???

Correct your BIGGEST BUG!

 
OK, i think, this bug is fixed , can you take a review on it.
Files:
az2.mq5  13 kb