Hi
I am giving the ea code below
=========================================================
double macd[2];
double signal[2];
int i;
for(i=0;i<2;i++)
{
macd[i]= iMACD(Symbol(), 0, FAST_EMA_PERIOD, SLOW_EMA_PERIOD, MACD_SIGNAL_PERIOD, PRICE_CLOSE, MODE_MAIN, i+1);
signal[i]= iMACD(Symbol(), 0, FAST_EMA_PERIOD, SLOW_EMA_PERIOD, MACD_SIGNAL_PERIOD, PRICE_CLOSE, MODE_SIGNAL, i+1);
}
if(UseHedge)
{
if(macd[0]>signal[0] && macd[1]<=signal[1] )
{
CloseOrders(OP_SELL);
if(state!=1)
if(-1!=OrderSend(Symbol(), OP_BUY, Lots, Ask, MarketInfo(Symbol(), MODE_SPREAD), 0,
0, WindowExpertName(), MagicNumber, 0, Green))
state= 1;
}
if(macd[0]<signal[0] && macd[1]>=signal[1] )
{
CloseOrders(OP_BUY);
if(state!=2)
if(-1!=OrderSend(Symbol(), OP_SELL, Lots, Bid, MarketInfo(Symbol(), MODE_SPREAD), 0,
0, WindowExpertName(), MagicNumber, 0, Red))
state= 2;
}
}
//----
return(0);
}
==================================================
All i want is we put a tp and sl of 30 pips along with the order and the order should be opened at 2 pips from the open ask of the next candle post the signal and in case of buy 2 pip less than the open bid value of the next candle post the signal candle. If any order is present then when a new order is opened when the signal changes the old running order should be closed.
can somebody chip in
I am giving the ea code below
=========================================================
double macd[2];
double signal[2];
int i;
for(i=0;i<2;i++)
{
macd[i]= iMACD(Symbol(), 0, FAST_EMA_PERIOD, SLOW_EMA_PERIOD, MACD_SIGNAL_PERIOD, PRICE_CLOSE, MODE_MAIN, i+1);
signal[i]= iMACD(Symbol(), 0, FAST_EMA_PERIOD, SLOW_EMA_PERIOD, MACD_SIGNAL_PERIOD, PRICE_CLOSE, MODE_SIGNAL, i+1);
}
if(UseHedge)
{
if(macd[0]>signal[0] && macd[1]<=signal[1] )
{
CloseOrders(OP_SELL);
if(state!=1)
if(-1!=OrderSend(Symbol(), OP_BUY, Lots, Ask, MarketInfo(Symbol(), MODE_SPREAD), 0,
0, WindowExpertName(), MagicNumber, 0, Green))
state= 1;
}
if(macd[0]<signal[0] && macd[1]>=signal[1] )
{
CloseOrders(OP_BUY);
if(state!=2)
if(-1!=OrderSend(Symbol(), OP_SELL, Lots, Bid, MarketInfo(Symbol(), MODE_SPREAD), 0,
0, WindowExpertName(), MagicNumber, 0, Red))
state= 2;
}
}
//----
return(0);
}
==================================================
All i want is we put a tp and sl of 30 pips along with the order and the order should be opened at 2 pips from the open ask of the next candle post the signal and in case of buy 2 pip less than the open bid value of the next candle post the signal candle. If any order is present then when a new order is opened when the signal changes the old running order should be closed.
can somebody chip in