angevoyageur: Show your code, so we can say you where to add this line.
Bonsoir Angevoyageur,
Here is my code. The two part are separated in the onTick section.
Thank you
Vivaldie
MqlTick latest_price; // To be used for getting recent/latest price quotesMqlTradeRequest mrequest; // To be used for sending our trade requestsMqlTradeResult mresult; // To be used to get our trade resultsMqlRates mrate[]; // To be used to store the prices, volumes and spread of each barZeroMemory(mrequest); // Initialization of mrequest structure
if(ConditionDICrossMain = -1)
{
if(Buy_opened)
{
return; // Don't open a new Buy Position
}
mrequest.action = TRADE_ACTION_DEAL; // immediate order execution
mrequest.price = NormalizeDouble(latest_price.ask,_Digits); // latest ask price
mrequest.sl = NormalizeDouble(latest_price.ask - STP*_Point,_Digits); // Stop Loss
mrequest.tp = NormalizeDouble(latest_price.ask + TKP*_Point,_Digits); // Take Profit
mrequest.symbol = _Symbol; // currency pair
mrequest.volume = Lot; // number of lots to trade
mrequest.magic = EA_Magic; // Order Magic Number
mrequest.type = ORDER_TYPE_BUY; // Buy Order
mrequest.type_filling = ORDER_FILLING_FOK; // Order execution type
mrequest.deviation=100; // Deviation from current price//--- send orderOrderSend(mrequest,mresult);
// get the result codeif(mresult.retcode==10009 || mresult.retcode==10008) //Request is completed or order placed
{
Alert("A Buy order has been successfully placed with Ticket#:",mresult.order,"!!");
}
else
{
Alert("The Buy order request could not be COMPLETE -error:",GetLastError());
ResetLastError();
return;
}
}
Standard Constants, Enumerations and Structures / Data Structures / Structure of Request Check Results - Reference on algorithmic/automated trading language for MetaTrader 5
Show your code, so we can say you where to add this line.
Bonsoir Angevoyageur,
Here is my code. The two part are separated in the onTick section.
Thank you
Vivaldie
Bonsoir Angevoyageur,
Here is my code. The two part are separated in the onTick section.
Thank you
Vivaldie
I didn't saw messages in the log and it says problem came from stop loss.
With value of 0 it works great : )
I didn't saw messages in the log and it says problem came from stop loss.
With value of 0 it works great : )
Ange I get it working now :) problem came from the STP variable.
Need to change the declaration with type double (instead of int) to please mr. NormalizeDouble.
Thanks
double STP, TKP;I mistaken and changing the variable declaration didn't solve the error message. Problem come from STP and TKP variable that are 0 making sl = tp.
Is the necessity to add
ZeroMemory(request);a bug in build 975 (x86)?
I recently encountered the error 4756 during a strategy test and adding the line above fixed it.
Is the necessity to add
a bug in build 975 (x86)?
I recently encountered the error 4756 during a strategy test and adding the line above fixed it.
hi
send order work in demo account but in real account don't work(2014.11.30 18:21:00.062 55 (اخابر,D1) BuyA: error 4756, retcode = 10006)
{ //--- prepare the request MqlTradeRequest request; MqlTradeResult result; MqlTradeCheckResult check; ZeroMemory(request); ZeroMemory(result); ZeroMemory(check); request.action=5; request.symbol=_Symbol; request.volume=1000.00; request.price=2652.000; request.stoplimit=2652.000; request.sl=0; request.tp=0; request.type=6; request.type_filling=2; request.type_time=0; request.expiration=0; request.magic=0; request.comment=""; if(!OrderSend(request,result)) { Print(__FUNCTION__,": error ",GetLastError(),", retcode = ",result.retcode); } //---