I would be very grateful if someone can have a look at the code for SCB with pending order attached below. The codes look ok but the ea is not sending any trades even when all the conditions are fulfilled.
Code: Select all
//Long
if (SendLong)
{
CountOpenTrades(symbol, PairIndex);
if (MarketBuysCount > 0)
return;
if (BuyStopsCount > 0)
return;
type = OP_BUYSTOP;
price = NormalizeDouble(Ask + (PendingOrderBuffer/factor), Digits);
//if ((price - Ask) <= (PendingOrderBuffer / factor)) price = price + (PendingOrderBuffer / factor); //increase if price too close to current high
if ((Ask + stopLevel) >= price ) return;//MR LONG MOD
stop = CalculateStopLoss(OP_BUY, price);
take = CalculateTakeProfit(OP_BUY, price);
//Lot size calculated by risk
if (!CloseEnough(RiskPercent, 0)) SendLots = CalculateLotSize(symbol, price, stop );
SendTrade = true;
}//if (SendLong)
//Short
if (SendShort)
{
CountOpenTrades(symbol, PairIndex);
if (MarketSellsCount > 0)
return;
if (SellStopsCount > 0)
return;
type = OP_SELLSTOP;
price = NormalizeDouble(Bid - (PendingOrderBuffer/factor), Digits);
//if ((Bid - price) <= (PendingOrderBuffer / factor)) price = price - (PendingOrderBuffer / factor); //decrease if price too close to current low
if (price >= (Bid - stopLevel)) return;//MR LONG MOD
stop = CalculateStopLoss(OP_SELL, price);
take = CalculateTakeProfit(OP_SELL, price);
//Lot size calculated by risk
if (!CloseEnough(RiskPercent, 0)) SendLots = CalculateLotSize(symbol, price, stop);
SendTrade = true;
}//if (SendShort)Code: Select all
//Buy
if (tradingStatus[PairIndex] == tradablelong)
if (MarketBuysCount == 0)
if (BuyStopsCount == 0)
{
SendTrade = true;
type = OP_BUYSTOP;
price = NormalizeDouble(Ask + (PendingOrderBuffer/factor), Digits);
//if ((price - Ask) <= (PendingOrderBuffer / factor)) price = price + (PendingOrderBuffer / factor); //increase if price too close to current high
if ((Ask + stopLevel) >= price ) return;//MR LONG MOD
if (UseZeljko && !BalancedPair(symbol, OP_BUY) ) return;
stop = CalculateStopLoss(OP_BUY, price);
take = CalculateTakeProfit(OP_BUY, price);
//Lot size calculated by risk
if (!CloseEnough(RiskPercent, 0)) SendLots = CalculateLotSize(symbol, price, stop);
}//if (!DoesTradeExist(symbol, OP_BUY) )
//Sell
if (tradingStatus[PairIndex] == tradableshort)
if (MarketSellsCount == 0)
if (SellStopsCount ==0 )
{
SendTrade = true;
type = OP_SELLSTOP;
price = NormalizeDouble(Bid - (PendingOrderBuffer/factor), Digits);
//if ((Bid - price) <= (PendingOrderBuffer / factor)) price = price - (PendingOrderBuffer / factor); //decrease if price too close to current low
if (price >= (Bid - stopLevel)) return;//MR LONG MOD
if (UseZeljko && !BalancedPair(symbol, OP_SELL) ) return;
stop = CalculateStopLoss(OP_SELL, price);
take = CalculateTakeProfit(OP_SELL, price);
//Lot size calculated by risk
if (!CloseEnough(RiskPercent, 0)) SendLots = CalculateLotSize(symbol, price, stop);
}//if (!DoesTradeExist(symbol, OP_SELL) )peter