Pending order gets cancelled immediately on live account - not on the demo! Why?

 

I have written my first trading robot using mql5 and tested it on the demo account AMP Futures have provided. As I was trying to run the robot on the live account all the pending orders have been cancelled immediately after being accepted by the trade server. So I have written a small piece of code to test things out. Here it is:

//#include <Trade\Trade.mqh>
//CTrade ctd;

input int entryHour = 18;
input int entryMin = 00;

bool onlyonce = false;

void OnTick() {
   MqlDateTime now;
   TimeCurrent(now);
   
   if(now.hour == entryHour && now.min == entryMin && !onlyonce) {
      onlyonce = true;
      Print(" DOOOOOOOOOOOO");
      //ctd.BuyLimit(1,NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits)-5,_Symbol,0,0,ORDER_TIME_GTC,0);

//-==ORDER==
      MqlTradeRequest treq={};
      MqlTradeResult  tres={};
      treq.magic = 556322;
      treq.symbol = _Symbol;
      
      treq.type = ORDER_TYPE_BUY_LIMIT;
      treq.volume = 1;
      treq.action = TRADE_ACTION_PENDING;
      treq.price = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits)-5;
      
      if (OrderSend(treq, tres)) {
         Print("-==Ord success; oTck: ", tres.order, " Ord/Pos Tot: ", OrdersTotal(), "/", PositionsTotal(), "Fu/Co: ", __FUNCTION__,"/",tres.comment);
      }
      else
         Print("-==Order ERROR retcode: ", tres.retcode);
//-=========
}}

If I use the built-in CTrade wrapper it works fine. If i try to use OrderSend() in just gets cancelled instantly. Why?
Am I missing something while setting up the order? Why is it ok like that on the demo account?

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
  • www.mql5.com
Trade Operation Types - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Your topic has been moved to the section: Expert Advisors and Automated Trading — In the future, please consider which section is most appropriate for your query.
 
And the answer is yes, I was missing a parameter setting up the OrderSend() function:
treq.type_filling = ORDER_FILLING_RETURN;
Now it works fine. Happy days