'request' - undeclared identifier, why am I getting this error?
'request' - undeclared identifier, why am I getting this error?
Loading saved threads...
Foenkelito · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Foenkelito
Original post: https://stackoverflow.com/questions/73772066
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I believe I am doing the exact same as in the MQl5 guide, 820 and 1517.
Could someone tell me what I am doing wrong?
//--- Preparing the request
double BuyAsync(double volume)
{MqlTradeRequest request={};
request.price = SymbolInfoDouble(_Symbol(),SYMBOL_ASK); // Long
request.magic = EXPERT_MAGIC; // EA magic number so you can track trades
request.action = TRADE_ACTION_DEAL; // Market order
request.symbol = "EURUSD"; // Symbol
request.type = ORDER_TYPE_BUY; // Long
request.order = "OrderTicketBuy"; // The orderticket so you can trace the individual trade
request.deviation = 5; // Maximum price deviation
request.volume = 0.25; // This should be €25.000
request.tp = tpLong; // Take profit long
request.sl = slLong; // Stoploss long
request.comment = "Buy using OrderSendAsync()";
MqlTradeResult result={};
if(!OrderSendAsync(request,result))
{
Print(__FUNCTION__,": error ", GetLastError(),", retcode = ", result.retcode);
}
}
Quote
Report
Ajay Pun Magar · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Ajay Pun Magar
Original post: https://stackoverflow.com/a/73772179
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
instead of this:
MqlTradeRequest request={};
use this:
MqlTradeRequest request;
do same for the request
Quote
Report
Ajay Pun Magar · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Ajay Pun Magar
Original post: https://stackoverflow.com/a/73773845
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
#include <Trade\Trade.mqh>
CTrade trade;
void OnInit()
{
double vol=0.01;
double selling_price=SymbolInfoDouble(_Symbol,SYMBOL_BID);
double buying_price=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
trade.Sell(vol,_Symbol,selling_price,0,0);
trade.Buy(vol,_Symbol,buying_price,0,0);
}
this is just a simple example, i haven't used stop loss of take profit, i have just opened the trade u can modify the stop loss and take profit.Hope my effort makes a difference for you.
Quote
Report
Foenkelito · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Foenkelito
Original post: https://stackoverflow.com/a/73774161
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
If it helps anyone, this is the answer to the original question:
//--- Preparing the request
void BuyAsync()
{MqlTradeRequest request={};
request.price = SymbolInfoDouble(_Symbol,SYMBOL_ASK); // Long
request.magic = EXPERT_MAGIC; // EA magic number so you can track trades
request.action = TRADE_ACTION_DEAL; // Market order
request.symbol = _Symbol; // Symbol
request.type = ORDER_TYPE_BUY; // Long
request.order = "OrderTicketBuy"; // The orderticket so you can trace the individual trade
request.deviation = 5; // Maximum price deviation
request.volume = 0.25; // This should be €25.000
request.tp = tpLong; // Take profit long
request.sl = slLong; // Stoploss long
request.comment = "Buy using OrderSendAsync()";
MqlTradeResult result={};
if(!OrderSendAsync(request,result))
{
Print(__FUNCTION__,": error ", GetLastError(),", retcode = ", result.retcode);
}
The difference is in the first couple of lines.
Quote
Report
rakesh Anjana · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: rakesh Anjana
Original post: https://stackoverflow.com/a/79796550
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
trade.SetExpertComment(InpTradeComment);
undeclared identifier robot.mq5
'InpTradeComment' - some operator expected
2 errors, 0 warnings
the above comman i get this error when i compile can anyone sugget why i get this error and hoe to correct it.
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: Foenkelito Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/a/73774161 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. If it helps anyone, this is the answer to the original question: //--- Preparing the request void BuyAsync() {MqlTradeRequest request={}; request.price = SymbolInfoDouble(_Symbol,SYMBOL_ASK); // Long request.magic = EXPERT_MAGIC; // EA magic number so you can track trades request.action = TRADE_ACTION_DEAL; // Market order request.symbol = _Symbol; // Symbol request.type = ORDER_TYPE_BUY; // Long request.order = "OrderTicketBuy"; // The orderticket so you can trace the individual trade request.deviation = 5; // Maximum price deviation request.volume = 0.25; // This should be €25.000 request.tp = tpLong; // Take profit long request.sl = slLong; // Stoploss long request.comment = "Buy using OrderSendAsync()"; MqlTradeResult result={}; if(!OrderSendAsync(request,result)) { Print(__FUNCTION__,": error ", GetLastError(),", retcode = ", result.retcode); } The difference is in the first couple of lines.
Checking account access…