Hi,
Can someone please help me with this code.
I am looking at a simple EA to manage my trades, i.e TP and SL.
Simple.
But am having issues with this, below.
Thanks,
Guess
//+------------------------------------------------------------------+
//| level_triling.mq4 |
//+------------------------------------------------------------------+
extern int Ticket=0; // you should put here the ticket number of the order you want to control
extern int Level_1_target=50; //in pips ... pozitive value only
extern int Level_1_stop=0; //in pips ....pozitive and negative value
int init(){return(0);}
int deinit(){return(0);}
int start()
{
int i=0;
for (i=0;i<OrdersTotal();i++){
OrderSelect(i,SELECT_BY_POS);
if (OrderTicket()==Ticket){
if (OrderType()==OP_BUY && Bid>=Level_1_target && Bid<Level_2_target && OrderStopLoss()!=OrderOpenPrice()+Level_1_stop*Point) {
if (!OrderModify(Ticket,OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()+Level_1_stop*Point,Digits),OrderTakeProfit(),0,Blue)) Alert("Error BUY 1: "+GetLastError());
if (OrderType()==OP_SELL && Ask<=Level_1_target && Ask>Level_2_target && OrderStopLoss()!=OrderOpenPrice()-Level_1_stop*Point) {
if (!OrderModify(Ticket,OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()-Level_1_stop*Point,Digits),OrderTakeProfit(),0,Red)) Alert("Error SELL 1: "+GetLastError());
}
break;
}
}
return(0);
}
Can someone please help me with this code.
I am looking at a simple EA to manage my trades, i.e TP and SL.
Simple.
But am having issues with this, below.
Thanks,
Guess
//+------------------------------------------------------------------+
//| level_triling.mq4 |
//+------------------------------------------------------------------+
extern int Ticket=0; // you should put here the ticket number of the order you want to control
extern int Level_1_target=50; //in pips ... pozitive value only
extern int Level_1_stop=0; //in pips ....pozitive and negative value
int init(){return(0);}
int deinit(){return(0);}
int start()
{
int i=0;
for (i=0;i<OrdersTotal();i++){
OrderSelect(i,SELECT_BY_POS);
if (OrderTicket()==Ticket){
if (OrderType()==OP_BUY && Bid>=Level_1_target && Bid<Level_2_target && OrderStopLoss()!=OrderOpenPrice()+Level_1_stop*Point) {
if (!OrderModify(Ticket,OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()+Level_1_stop*Point,Digits),OrderTakeProfit(),0,Blue)) Alert("Error BUY 1: "+GetLastError());
if (OrderType()==OP_SELL && Ask<=Level_1_target && Ask>Level_2_target && OrderStopLoss()!=OrderOpenPrice()-Level_1_stop*Point) {
if (!OrderModify(Ticket,OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()-Level_1_stop*Point,Digits),OrderTakeProfit(),0,Red)) Alert("Error SELL 1: "+GetLastError());
}
break;
}
}
return(0);
}