I keep getting error 4753 when using cTrade.PositionOpen

I am trying to run an EA from a tutorial, but I keep getting errorcode 4753

I tried with a demo account from a broker and also a standard mt5 demo account…

Please help

thanks

Files: Anna_v1.02_Complete.mq5 12 KB

You mean 4753 I suppose ?

Sorry, yes, the code in the title is the correct one, I am editing to fix the other one

Ok.

Is the position open or not ?

The code is not correct. It should be something like :slight_smile:


if(myTradingControlPanel.PositionOpen(_Symbol, ORDER_TYPE_BUY, lot, currentAsk, stopLossLevel, takeProfitLevel, ...)
  && (myTradingControlPanel.ResultRetcode()==10008 || myTradingControlPanel.ResultRetcode()==10009) 
  )
  {
    Print("Entry rules: A Buy order has been successfully placed with Ticket#: ", myTradingControlPanel.ResultOrder());
  }
else
  {
    Print("Entry rules: The Buy order request could not be completed. Error: ", GetLastError(), myTradingControlPanel.ResultRetcode());
    ResetLastError();
    return;
  }
         

I’m not experienced with MQL, but that part of the code is inside this if(PositionSelect(_Symbol) == false) so no, I guess it is not opened.

I noticed that ResultRetcode returned errorcode 10030, so I found out that I needed to put this inside OnInit

myTradingControlPanel.SetTypeFilling(ORDER_FILLING_IOC);

now my EA is trading! thanks