The qusetion for OrderSend(),OnInit() and OnChartEvent()

 

Here is the code I used and it's working in OnInit(),but not working in OnChartEvent()... return code is 10013...I get the 4756 error...

Why?

Please help.

            MqlTradeRequest request;
            request.action = TRADE_ACTION_DEAL;
            request.symbol = Symbol();
            request.volume = 0.01;
            request.type = ORDER_TYPE_BUY;
            request.type_filling = ORDER_FILLING_AON;  
            MqlTradeResult result;
            OrderSend(request,result);
            Print("Reply code=",result.retcode);  
 

Here is the code I added and it's working in OnChartEvent()


request.price = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
 

Also don't forget to add ZeroMemory() function.... something like that... especially when you want to modify orders:

MqlTradeRequest request;
ZeroMemory(request);
...
...
...

MqlTradeResult result;
ZeroMemory(result);
 
JDeel:

Also don't forget to add ZeroMemory() function.... something like that... especially when you want to modify orders:

 

Thank you! I will always remember!

Reason: