Rare code issue (2)

 

I have to make declaration of Buy or Sell Positions>0 into the main loop to make the advisor work.

if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY&&LongPos>0){
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL&&ShortPos>0){

It was supposed to be some buy or sell behind this lines. Does anyone know something about this?

 

Calling OrderSend does not garantee that the order will be executed, you need to check if the position exists and then execute the logic you want.

People usually use magic numbers to easily identify positions created by an EA.

Documentation on MQL5: Trade Functions / OrderSend
Documentation on MQL5: Trade Functions / OrderSend
  • www.mql5.com
OrderSend - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Alexandre Borela:

Calling OrderSend does not garantee that the order will be executed, you need to check if the position exists and then execute the logic you want.

People usually use magic numbers to easily identify positions created by an EA.

This answer doesn't make sense about the question, moreover this is MQL5.