Given the regular standard for setting a stop loss after an order is sent as:
{
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, Ask - StopLoss * Point, Ask + TakeProfit*Point, "LONG Entry", 12345, 0, Green);
if(ticket > 0)
{
if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
Print("BUY order opened : ",OrderOpenPrice());
}
else
Print("Error opening BUY order : ", GetLastError());
return(0);
}
Say you want to use the current value of the 50EMA as the stop level. Not the close of the bar and the 50EMA, the current value of the 50EMA. This means that the stop level would change tick per tick as the price level (value of the 50EMA) changes.
The Ask - StopLoss * Point needs to be tweaked. I've tried to use StopLoss==50EMA (assuming 50EMA has been assigned the exp. mov avg set at 50) and it does compile. But in the Results column of the strategy tester the S/L column is blank and a few of the position should have been stopped out as the bar passed through the 50EMA.
Or, is this a circumstance where the strategy can only be tested live given the fact that the 50EMA is a bar on close value? How would you specify the current value of the moving average instead of the close if
50EMA = iMA(NULL,60, ShortEma, 0, MODE_EMA, PRICE_CLOSE, 0);
and there is no
50EMA = iMA(NULL,60, ShortEma, 0, MODE_EMA, PRICE_NOW, 0);
Thanks
{
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, Ask - StopLoss * Point, Ask + TakeProfit*Point, "LONG Entry", 12345, 0, Green);
if(ticket > 0)
{
if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
Print("BUY order opened : ",OrderOpenPrice());
}
else
Print("Error opening BUY order : ", GetLastError());
return(0);
}
Say you want to use the current value of the 50EMA as the stop level. Not the close of the bar and the 50EMA, the current value of the 50EMA. This means that the stop level would change tick per tick as the price level (value of the 50EMA) changes.
The Ask - StopLoss * Point needs to be tweaked. I've tried to use StopLoss==50EMA (assuming 50EMA has been assigned the exp. mov avg set at 50) and it does compile. But in the Results column of the strategy tester the S/L column is blank and a few of the position should have been stopped out as the bar passed through the 50EMA.
Or, is this a circumstance where the strategy can only be tested live given the fact that the 50EMA is a bar on close value? How would you specify the current value of the moving average instead of the close if
50EMA = iMA(NULL,60, ShortEma, 0, MODE_EMA, PRICE_CLOSE, 0);
and there is no
50EMA = iMA(NULL,60, ShortEma, 0, MODE_EMA, PRICE_NOW, 0);
Thanks