I am trying but doesnt seem to work. Thanks in advance!
Code: Select all
double entry = iCustom(NULL,0,"entry",11,0);
double stop = iCustom(NULL,0,"stop",1,0);
double tp1 = iCustom(NULL,0,"tp1",7,0);
double tp2 = iCustom(NULL,0,"tp2",9,0);
void OnTick()
{
static datetime last_time = Time[0];
if(last_time < Time[0])
{
last_time = Time[0];
if (Ask == entry && OrdersTotal() == 0)
int buyticket = OrderSend(Symbol(), OP_BUY, 0.01, Ask, 3,stop,tp1, NULL, 0, 0, Green);
if (Ask == entry && OrdersTotal() == 1)
int buyticket2 = OrderSend(Symbol(), OP_BUY, 0.01, Ask, 3,stop,tp2, NULL, 0, 0, Green);
if (Ask == entry && OrdersTotal() == 2)
int buyticket3 = OrderSend(Symbol(), OP_BUY, 0.01, Ask, 3,stop,0, NULL, 0, 0, Green);
for (int i = OrdersTotal() - 1; i >= 0; i--);
{
// Select an order by index i, selecting by position and from the pool of market trades.
// If the selection is successful, proceed with the update.
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
// Check if the order is for the current chart's currency pair.
if (OrderSymbol() == Symbol())
double OpenPrice = entry;
double StopLossPrice = NormalizeDouble(stop,Digits()); //new stop loss
if(!OrderModify(OrderTicket(), OrderOpenPrice(), StopLossPrice, OrderTakeProfit(), OrderExpiration()))
{
Print("No se puede editar el SL de la orden ",OrderTicket(), " al precio ",StopLossPrice," por el error ",GetLastError());
}
}
}
}
}