Hi, I would like to know if is its possible in an EA to have it Buy again after a previous Buy trade has been opened and closed. In other words to buy every time there is a valid condition and not wait for the Sell signal before opening another trade. I am having a difficult time in making an EA take another buy trade in the trend direction after it has opened and closed a buy trade. Due to last direction and current direction.
If this is possible then at least I know its doable. Open on signal change was a way to make it try and take another trade. Though it will open on any subsequent bar whether the trade condition is true or not.
Thanks
If this is possible then at least I know its doable. Open on signal change was a way to make it try and take another trade. Though it will open on any subsequent bar whether the trade condition is true or not.
PHP Code
if ( (OpenOnSignalChange && lastDirection != OP_BUY && curDirection == OP_BUY)
|| (!OpenOnSignalChange && curDirection == OP_BUY && TradeCount[OP_BUY] == 0)
) {
closeTrades(OP_SELL);
if (StopLossPips > 0) StopLoss = Ask - StopLossPips * MyPoint; else StopLoss = getZigZagStopLoss(OP_BUY);
Lots = getLotSize3( (Ask-StopLoss)/MyPoint );
OpenOrder(OP_BUY, Lots, Slippage, StopLoss, TakeProfitPips, "", MagicNumber, 3, Blue);
} else if ( (OpenOnSignalChange && lastDirection != OP_SELL && curDirection == OP_SELL)
|| (!OpenOnSignalChange && curDirection == OP_SELL && TradeCount[OP_SELL] == 0)
) {
closeTrades(OP_BUY);
if (StopLossPips > 0) StopLoss = Bid + StopLossPips * MyPoint; else StopLoss = getZigZagStopLoss(OP_SELL);
Lots = getLotSize3( (StopLoss-Bid)/MyPoint );
OpenOrder(OP_SELL, Lots, Slippage, StopLoss, TakeProfitPips, "", MagicNumber, 3, Red);
}
lastDirection = curDirection;