My script does not open positions in real trades in mql5

 

Hello, this is my code, it works well in the tester strategy, but when I put it in the main chart for real trades, it does not open a position.

#include<Trade\Trade.mqh>
CTrade trade;


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);

   trade.Buy(0.01,_Symbol,Ask, Ask-50*_Point);

  }
 

Please check documentation to use the correct input parameters to the Buy method:

https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradebuy

Also make sure to turn on AutoTrading when running live!
Documentation on MQL5: Standard Library / Trade Classes / CTrade / Buy
Documentation on MQL5: Standard Library / Trade Classes / CTrade / Buy
  • www.mql5.com
Buy(double,const string,double,double,double,const string) - CTrade - Trade Classes - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Yashar Seyyedin #:

Please check documentation to use the correct input parameters to the Buy method:

https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradebuy

Also make sure to turn on AutoTrading when running live!
I checked everything. Ordering is done well in test and demo transactions. But in real trading, all orders are executed well and even the comment is displayed in the chart window, but it does not open a position.
 
mansour afshar #:
I checked everything. Ordering is done well in test and demo transactions. But in real trading, all orders are executed well and even the comment is displayed in the chart window, but it does not open a position.
Did you enable algo trading? Check journal tab for possible errors and messages when executing orders.
 
Yashar Seyyedin #:
Did you enable algo trading? Check journal tab for possible errors and messages when executing orders.
Yes enable algo trading 
 
mansour afshar #: Yes enable algo trading 
Then please show the log output, both Experts and Journal log.