Hi
I have been trying to modify this bit of sample code for use. I keep getting the Invalid Price error. Does anyone have any ideas
Thanks
double volume=0.1;
string symbol="GBPUSD"; // specify the symbol, at which the order is placed
int digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS); // number of decimal places
double point=SymbolInfoDouble(symbol,SYMBOL_POINT); // point
double ask=SymbolInfoDouble(symbol,SYMBOL_ASK); // current buy price
double price=1000*point; // unnormalized open price
price=NormalizeDouble(price,digits); // normalizing open price
int SL_pips=300; // Stop Loss in points
int TP_pips=500; // Take Profit in points
double SL=price-SL_pips*point; // unnormalized SL value
SL=NormalizeDouble(SL,digits); // normalizing Stop Loss
double TP=price+TP_pips*point; // unnormalized TP value
TP=NormalizeDouble(TP,digits); // normalizing Take Profit
datetime expiration=TimeTradeServer()+PeriodSeconds(PERIOD_D1);
string comment=StringFormat("Buy Limit %s %G lots at %s, SL=%s TP=%s",
symbol,volume,
DoubleToString(price,digits),
DoubleToString(SL,digits),
DoubleToString(TP,digits));
//--- everything is ready, sending a Buy Limit pending order to the server
if(!trade.BuyLimit(volume,price,symbol,SL,TP,ORDER_TIME_GTC,expiration,comment))
{
//--- failure message
Print("BuyLimit() method failed. Return code=",trade.ResultRetcode(),
". Code description: ",trade.ResultRetcodeDescription());
}
else
{
Print("BuyLimit() method executed successfully. Return code=",trade.ResultRetcode(),
" (",trade.ResultRetcodeDescription(),")");
}