Profit factor:
0.68
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
0 Views
0 Downloads
0 Favorites
NOC-EA
extern double dBuyLevel = 0.54;
extern double dSellLevel= 0.74;
extern double dStopLoss = 200;
extern double dTrailingStop = 174;

// ------

double dTakeProfit = 0;

datetime timePrev = 0;
int nBars;
int nSlip = 5;

extern double risk = 0.05;

int nMagic = 0;


// ------

int init ()
{
    nBars = Bars;

    
    return(0);
}
// ------
int deinit()
{
    return(0);
}

// ------

int start()
{
    if(Bars < 200)
        return(0);
    
    if(!IsBarEnd())
        return(0);
    
    // ------
    
    double dNoc = iCustom(NULL, 0, "_NOC", 0, 3);
    double dNocPrev = iCustom(NULL, 0, "_NOC", 0, 4);
        
    for(int nCnt = OrdersTotal() - 1; nCnt >= 0; nCnt--)
    {
        OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES);
        if(OrderMagicNumber() == nMagic)
        {
            if(OrderType() == OP_BUY)
            {         
                if(dNocPrev >= dSellLevel && dNoc <= dSellLevel)
                {
                    OrderClose(OrderTicket(), 
                        OrderLots(), Bid, nSlip, Aqua);
                    break;
                }
            }
            else if(OrderType() == OP_SELL)
            {
                if(dNocPrev <= dBuyLevel && dNoc >= dBuyLevel)
                {
                    OrderClose(OrderTicket(), 
                        OrderLots(), Ask, nSlip, OrangeRed);
                    break;
                }
            }
        }
    }

    int nNumOfOpenedOrders = 0;
    for(nCnt = OrdersTotal() - 1; nCnt >= 0; nCnt--)
    {
        OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES);
        if(OrderMagicNumber() == nMagic)
            nNumOfOpenedOrders++;
    }

    if(nNumOfOpenedOrders == 0)
    {
        if(dNocPrev <= dBuyLevel && dNoc >= dBuyLevel) 
        {
            OrderSend(Symbol(), OP_BUY,  GetRisk(risk), Ask, 
                nSlip, Ask - dStopLoss*Point, 0, "", 
                nMagic, 0, Aqua);
        }
        else if(dNocPrev >= dSellLevel && dNoc <= dSellLevel) 
        {
            OrderSend(Symbol(), OP_SELL, GetRisk(risk), Bid, 
                nSlip, Bid + dStopLoss*Point, 0, "", 
                nMagic, 0, OrangeRed);
        }
    }
        
    // ------

    ModifyOrders();
    
    // ------
    
    return(0);
}


// ------

void ModifyOrders()
{
    for(int nCnt = 0; nCnt < OrdersTotal(); nCnt++)
    {
        OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES);
        if(OrderMagicNumber() == nMagic)
        {
            if(OrderType() == OP_BUY)
            {
                if(OrderStopLoss() < Bid - dTrailingStop*Point - 5 * Point)
                {
                    OrderModify(OrderTicket(), OrderOpenPrice(), 
                        Bid - dTrailingStop*Point, OrderTakeProfit(), 0, Aqua);
                    break;
                }
            }
            
            if(OrderType() == OP_SELL)
            {
                if(OrderStopLoss() > Ask + dTrailingStop*Point + 5 * Point)
                {
                    OrderModify(OrderTicket(), OrderOpenPrice(), 
                        Ask + dTrailingStop*Point, OrderTakeProfit(), 
                        0, OrangeRed);
                    break;
                }
            }
        }
    }
}

// ------

bool IsBarEnd()
{
    bool bIsBarEnd = false;
    if(nBars != Bars)
    {
        bIsBarEnd = true;
        nBars = Bars;
    }
    
    return(bIsBarEnd);
}

double GetRisk( double dRisk)
{
   
   double   dMinLot = MarketInfo (Symbol (),MODE_MINLOT);
   double   dMaxLot = MarketInfo (Symbol (),MODE_MAXLOT);
   double   dLotStep = MarketInfo (Symbol (),MODE_LOTSTEP);
   double   dLotSize = MarketInfo (Symbol (),MODE_LOTSIZE);
   double   dLots;

   if (dMinLot < 0 || dMaxLot <= 0.0 || dLotStep <= 0.0)
   {
      Print ("CalculateVolume: invalid MarketInfo() results [",dMinLot,",",dMaxLot,",",dLotStep,"]");
      return (0);
   }

   if (AccountLeverage () <= 0)
   {
      Print ("CalculateVolume: invalid AccountLeverage() [",AccountLeverage (),"]");
      return (0);
   }

   dLots = NormalizeDouble (AccountBalance () * dRisk * AccountLeverage () / dLotSize,2);
   dLots = NormalizeDouble (dLots / dLotStep,0) * dLotStep;
   if (dLots < dMinLot) dLots = dMinLot;
   if (dLots > dMaxLot) dLots = dMaxLot;
   return (dLots);
}


Profitability Reports

USD/CAD Oct 2024 - Jan 2025
1.36
Total Trades 56
Won Trades 26
Lost trades 30
Win Rate 46.43 %
Expected payoff 20.24
Gross Profit 4271.66
Gross Loss -3138.36
Total Net Profit 1133.30
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.41
Total Trades 42
Won Trades 9
Lost trades 33
Win Rate 21.43 %
Expected payoff -60.31
Gross Profit 1790.31
Gross Loss -4323.13
Total Net Profit -2532.82
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.51
Total Trades 65
Won Trades 17
Lost trades 48
Win Rate 26.15 %
Expected payoff -42.40
Gross Profit 2921.47
Gross Loss -5677.35
Total Net Profit -2755.88
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.42
Total Trades 49
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -48.91
Gross Profit 1762.92
Gross Loss -4159.63
Total Net Profit -2396.71
-100%
-50%
0%
50%
100%

Comments