Change this line :
MqlTradeRequest mrequest={0};
Thanks Alain, solved my problem too.
Hello,
Here is my code:
//+------------------------------------------------------------------+ //| C1.mq5 | //| Copyright 2021, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2021, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- MqlTradeRequest Action={0}; MqlTradeResult result={0}; Action.action=TRADE_ACTION_DEAL; Action.type=ORDER_TYPE_BUY; Action.symbol=_Symbol; Action.volume=.01; Action.type_filling=ORDER_FILLING_IOC;//ORDER_FILLING_FOK; if(OrderSend(Action,result)) { Print("OKK"); } else { Print("Not OKK"); Print(result.retcode); Print(result.comment); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+
The above solution shows me this error : "cannot convert 0 to enum 'ENUM_TRADE_REQUEST_ACTIONS' C1.mq5 15 25" for
MqlTradeRequest Action={0}
Before that I got (removing ={0}) retcore=10013 error. what is my mistake?
MqlTradeRequest Action={};
Hello to everyone!
Can anybody make it clear for me, why this code does not work?
So, the deal is I am dropping that Script onto my Graph, and as a result I get a Messege:
Invalid request - 10013. To tell the truth this messege is not able to clarify anything for me.
If you, my dear friends, can open my eyes and may make this code work, please help me, I will really appreciate that.
//+------------------------------------------------------------------+ //| trade.mq5 | //| Copyright 2021, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2021, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ long ask_p=0; long ask_v = 0; long bid_v = 0; long ask_price=0; long ask_volume = 0; long bid_volume = 0; MqlTradeRequest request{}; MqlTradeResult result{}; int OnInit() { //--- MqlBookInfo BookInfo[]; MarketBookAdd(_Symbol); MarketBookGet(_Symbol,BookInfo); for(int j=0;j<1;j++) { for(int i=0;i<ArraySize(BookInfo)-1;i++) { if(BookInfo[i].type != BookInfo[i+1].type) { ask_p= BookInfo[i].price; ask_v = BookInfo[i].volume; bid_v = BookInfo[i+1].volume; } } } if(ask_volume<((ask_v)/14)) { printf("ok") ; request.action = TRADE_ACTION_PENDING; request.type = ORDER_TYPE_BUY; request.symbol = _Symbol; request.volume = 500; request.type_filling = ORDER_FILLING_RETURN; request.price = ask_price; request.tp = 1.042*(request.price); } OrderSend(request,result); if(result.retcode == 10008 || result.retcode == 10009) { Print("Trade placed"); } else { printf("naok") ; Print("Trade not placed. Error code ",result.retcode); } Print("Return Code:",result.retcode,", Volume: ",result.volume, ", Price: ",result.price,", Bid: ",result.bid,", Ask: ",result.ask); return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { //--- } void OnTick() { MqlBookInfo BookInfo[]; MarketBookAdd(_Symbol); MarketBookGet(_Symbol,BookInfo); for(int z=0;z<ArraySize(BookInfo)-1;z++) { if(BookInfo[z].type != BookInfo[z+1].type) { ask_price= BookInfo[z].price; ask_volume = BookInfo[z].volume; bid_volume = BookInfo[z+1].volume; } } } //--- //+------------------------------------------------------------------+
Your TP is not set to normalized price.
Are you sure you want to open 500 lot? Is that intentional?
I would suggest initializing the structs empty.
MqlTradeRequest request = {};
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello to everyone!
Can anybody make it clear for me, why this amazingly sophisticated code does not work?
So, the deal is I am dropping that Script onto my Graph, and as a result I get a Messege:
Invalid request - 10013. To tell the truth this messege is not able to clarify anything for me.
If you, my dear friends, can open my eyes and may make this code work, please help me, I will really appreciate that.