Support&Resistance

Download script
Author: Scriptong
Profit factor:
1.01

Technical Logic Overview: Support & Resistance Trading Script

This document provides a non-technical explanation of the logic used by the provided MetaTrader MQL4 script. The script is designed to automatically identify key price levels (Support and Resistance) based on momentum indicators and manage trade positions accordingly.

1. Initialization and Safety Checks

When the script first starts, it performs several "housekeeping" tasks to ensure it can operate correctly:

  • Market Environment Check: It gathers essential data about the specific currency pair, such as the minimum allowed trade size, the current spread (cost of trading), and the minimum distance required for stop-loss orders.
  • Lot Size Validation: It checks your requested "Lots" (trade volume). If the number you entered is too small or too large for the broker's rules, the script will disable itself and display a warning message on the screen.
  • Naming Convention: It assigns unique internal names to its visual indicators to ensure it doesn't interfere with other objects on your chart.

2. Identifying Support and Resistance (The "Core" Logic)

The script identifies key price levels by analyzing the Awesome Oscillator (AO), a momentum indicator. It looks for specific structural shifts in the market:

  • Support Levels: If the momentum is positive but shows a specific type of "correction" (a temporary dip after an upward move), the script scans back through history to find where the momentum turned negative. It then marks the highest price point from that period as the Resistance and the lowest as the Support.
  • Resistance Levels: Conversely, if the momentum is negative but shows a correction (a temporary rise after a downward move), it identifies the point where momentum turned positive. It marks the extreme high and low points of that "swing" as its new trading levels.
  • Visual Representation: Once these levels are calculated, the script draws physical lines on your chart so you can see exactly where it is currently looking to trade.

3. Trade Execution and Management

Once the Support and Resistance lines are established, the script follows a specific set of rules for opening and managing trades:

A. Smart Order Entry: The script calculates entry prices based on these levels combined with the "Spread" (to ensure enough room to open the trade).

  • It seeks to place Buy Stop orders slightly above Resistance.
  • It seeks to place Sell Stop orders slightly below Support.

B. Dynamic Order Modification: This is a sophisticated part of the script. If you already have an active position or a pending order, the script constantly monitors it:

  • Price Adjustment: If the market moves significantly, the script will automatically move your "Stop Loss" and "Take Profit" prices to ensure they remain valid according to the current price distance rules (StopLevel).
  • Automatic Re-calculation: It ensures that even if a trade is already open, its exit points are mathematically linked to the new Support/Resistance levels identified by the indicators.

C. Order Cleanup and Prevention: To prevent "over-trading" or opening multiple redundant positions:

  • If the script identifies a Buy position exists (or a pending Buy order), it will not place additional Buy orders if the price is already approaching the Resistance.
  • It performs the same logic for Sell positions relative to the Support level.

4. Error Handling and Communication

The script includes a robust error-reporting system:

  • Trade Context: Before sending an order, it checks if the trading server is "busy." If busy, it waits briefly before trying again.
  • Error Messages: If a trade fails (e.g., not enough money, connection lost, or broker restrictions), the script will translate the technical error code into a readable message on your chart screen.
  • Alerts: Upon successfully opening a position, the script can play a sound file to notify you.

Summary of Workflow

  1. Scan the market using the Awesome Oscillator to find "swings" in price history.
  2. Draw horizontal lines at the highest and lowest points of those swings.
  3. Monitor the current price; if it approaches these lines, place pending orders.
  4. Manage existing trades by constantly updating their Stop Loss and Take Profit prices to stay mathematically aligned with the identified levels.
Orders Execution
It automatically opens orders when conditions are reachedChecks for the total of open ordersIt can change open orders parameters, due to possible stepping strategy
Indicators Used
Bill Williams Awesome oscillator
Miscellaneous
It plays sound alerts
18 Views
1 Downloads
0 Favorites
Support&Resistance
//+-------------------------------------------------------------------------------------+
//|                                                              Support&Resistance.mq4 |
//|                                                                           Scriptong |
//|                                                                   scriptong@mail.ru |
//+-------------------------------------------------------------------------------------+
#property copyright "Scriptong"
#property link      "scriptong@mail.ru"


//---- input parameters
extern double    Lots = 0.1;
extern string    OpenOrderSound = "ok.wav";
extern int       MagicNumber = 875;
extern color     SupportColor = Blue;                            // Öâåò óðîâíÿ ïîääåðæêè
extern color     ResistanceColor = Red;                      // Öâåò óðîâíÿ ñîïðîòèâëåíèÿ

bool Activate, FreeMarginAlert, FatalError;
double Tick, Spread, StopLevel, FreezeLevel, MinLot, MaxLot, LotStep, Supp, Resis;
datetime LastBar, ChanStart;
string SName, RName;

//+-------------------------------------------------------------------------------------+
//| expert initialization function                                                      |
//+-------------------------------------------------------------------------------------+
int init()
  {
   FatalError = False;
   Activate = False;
// - 1 - == Ñáîð èíôîðìàöèè îá óñëîâèÿõ òîðãîâëè ========================================
   Tick = MarketInfo(Symbol(), MODE_TICKSIZE);                         // ìèíèìàëüíûé òèê
   Spread = ND(MarketInfo(Symbol(), MODE_SPREAD)*Point);                 // òåêóùèé ñïðýä
   StopLevel = ND(MarketInfo(Symbol(), MODE_STOPLEVEL)*Point);  // òåêóùèé óðîâåíü ñòîïîâ
   FreezeLevel = ND(MarketInfo(Symbol(), MODE_FREEZELEVEL)*Point);   // óðîâåíü çàìîðîçêè
   MinLot = MarketInfo(Symbol(), MODE_MINLOT);    // ìèíèìàëüíûé ðàçðåøåííûé îáúåì ñäåëêè
   MaxLot = MarketInfo(Symbol(), MODE_MAXLOT);   // ìàêñèìàëüíûé ðàçðåøåííûé îáúåì ñäåëêè
   LotStep = MarketInfo(Symbol(), MODE_LOTSTEP);          // øàã ïðèðàùåíèÿ îáúåìà ñäåëêè
// - 1 - == Îêîí÷àíèå áëîêà =============================================================

// - 2 - == Ïðèâåäåíèå îáúåìà ñäåëêè ê äîïóñòèìîìó è ïðîâåðêà êîððåêòíîñòè îáúåìà =======
   Lots = MathRound(Lots/LotStep)*LotStep; // îêðóãëåíèå îáúåìà äî áëèæàéøåãî äîïóñòèìîãî
   if(Lots < MinLot || Lots > MaxLot) // îáúåì ñäåëêè íå ìåíüøå MinLot è íå áîëüøå MaxLot
     {
      Comment("Ïàðàìåòðîì Lots áûë çàäàí íåïðàâèëüíûé îáúåì ñäåëêè! Ñîâåòíèê îòêëþ÷åí!");
      return(0);
     }
// - 2 - == Îêîí÷àíèå áëîêà =============================================================

   SName = "Support"+MagicNumber;                    // Èìÿ äëÿ îáúåêòà "ëèíèÿ ïîääåðæêè"
   RName = "Resistance"+MagicNumber;             // Èìÿ äëÿ îáúåêòà "ëèíèÿ ñîïðîòèâëåíèÿ"
    
   Activate = True;
   
//----
   return(0);
  }
//+-------------------------------------------------------------------------------------+
//| expert deinitialization function                                                    |
//+-------------------------------------------------------------------------------------+
int deinit()
  {
//----
   Comment("");
//----
   return(0);
  }
  
//+-------------------------------------------------------------------------------------+
//| Ïðèâåäåíèå çíà÷åíèé ê òî÷íîñòè îäíîãî òèêà                                          |
//+-------------------------------------------------------------------------------------+
double ND(double A)
{
 return(NormalizeDouble(A, Digits));
}  

//+-------------------------------------------------------------------------------------+
//| Ðàñøèôðîâêà ñîîáùåíèÿ îá îøèáêå                                                     |
//+-------------------------------------------------------------------------------------+
string ErrorToString(int Error)
{
 switch(Error)
   {
    case 2: return("çàôèêñèðîâàíà îáùàÿ îøèáêà, îáðàòèòåñü â òåõïîääåðæêó."); 
    case 5: return("ó âàñ ñòàðàÿ âåðñèÿ òåðìèíàëà, îáíîâèòå åå."); 
    case 6: return("íåò ñâÿçè ñ ñåðâåðîì, ïîïðîáóéòå ïåðåçàãðóçèòü òåðìèíàë."); 
    case 64: return("ñ÷åò çàáëîêèðîâàí, îáðàòèòåñü â òåõïîääåðæêó.");
    case 132: return("ðûíîê çàêðûò."); 
    case 133: return("òîðãîâëÿ çàïðåùåíà."); 
    case 149: return("çàïðåùåíî ëîêèðîâàíèå."); 
   }
}

//+-------------------------------------------------------------------------------------+
//| Îæèäàíèå òîðãîâîãî ïîòîêà. Åñëè ïîòîê ñâîáîäåí, òî ðåçóëüòàò True, èíà÷å - False    |
//+-------------------------------------------------------------------------------------+  
bool WaitForTradeContext()
{
 int P = 0;
 // öèêë "ïîêà"
 while(IsTradeContextBusy() && P < 5)
   {
    P++;
    Sleep(1000);
   }
 // -------------  
 if(P == 5)
   return(False);
 return(True);    
}
  
//+-------------------------------------------------------------------------------------+
//| "Ïðàâèëüíîå" îòêðûòèå ïîçèöèè                                                       |
//|  îòëè÷èå îò OpenOrder ïðîâåðÿåò ñîîòíîøåíèå òåêóùèõ óðîâíåé è óñòàíàâëèâàåìûõ      |
//| Âîçâðàùàåò:                                                                         |
//|   0 - íåò îøèáîê                                                                    |
//|   1 - Îøèáêà îòêðûòèÿ                                                               |
//|   2 - Îøèáêà çíà÷åíèÿ Price                                                         |
//|   3 - Îøèáêà çíà÷åíèÿ SL                                                            |
//|   4 - Îøèáêà çíà÷åíèÿ TP                                                            |
//|   5 - Îøèáêà çíà÷åíèÿ Lot                                                           |
//+-------------------------------------------------------------------------------------+
int OpenOrderCorrect(int Type, double Price, double SL, double TP, 
                     bool Redefinition = True)
// Redefinition - ïðè True äîîïðåäåëÿòü ïàðàìåòðû äî ìèíèìàëüíî äîïóñòèìûõ
//                ïðè False - âîçâðàùàòü îøèáêó
{
// - 1 - == Ïðîâåðêà äîñòàòî÷íîñòè ñâîáîäíûõ ñðåäñòâ ====================================
 if(AccountFreeMarginCheck(Symbol(), OP_BUY, Lots) <= 0 || GetLastError() == 134) 
  {
   if(!FreeMarginAlert)
    {
     Print("Íåäîñòàòî÷íî ñðåäñòâ äëÿ îòêðûòèÿ ïîçèöèè. Free Margin = ", 
           AccountFreeMargin());
     FreeMarginAlert = True;
    } 
   return(5);  
  }
 FreeMarginAlert = False;  
// - 1 - == Îêîí÷àíèå áëîêà =============================================================

// - 2 - == Êîððåêòèðîâêà çíà÷åíèé Price, SL è TP èëè âîçâðàò îøèáêè ====================

 RefreshRates();
 switch (Type)
   {
    case OP_BUY: 
                string S = "BUY"; 
                if (MathAbs(Price-Ask)/Point > 3)
                  if (Redefinition) Price = ND(Ask);
                  else              return(2);
                if (ND(TP-Bid) < StopLevel && TP != 0)
                  if (Redefinition) TP = ND(Bid+StopLevel);
                  else              return(4);
                if (ND(Bid-SL) < StopLevel)
                  if (Redefinition) SL = ND(Bid-StopLevel);
                  else              return(3);
                break;
    case OP_SELL: 
                 S = "SELL"; 
                 if (MathAbs(Price-Bid)/Point > 3)
                   if (Redefinition) Price = ND(Bid);
                   else              return(2);
                 if (ND(Ask-TP) < StopLevel) 
                   if (Redefinition) TP = ND(Ask-StopLevel);
                   else              return(4);
                 if (ND(SL-Ask) < StopLevel && SL != 0)
                   if (Redefinition) SL = ND(Ask+StopLevel);
                   else              return(3);
                 break;
    case OP_BUYSTOP: 
                    S = "BUYSTOP";
                    if (ND(Price-Ask) < StopLevel)
                      if (Redefinition) Price = ND(Ask+StopLevel);
                      else              return(2);
                    if (ND(TP-Price) < StopLevel && TP != 0)
                      if (Redefinition) TP = ND(Price+StopLevel);
                      else              return(4);
                    if (ND(Price-SL) < StopLevel)
                      if (Redefinition) SL = ND(Price-StopLevel);
                      else              return(3);
                    break;
    case OP_SELLSTOP: 
                     S = "SELLSTOP";
                     if (ND(Bid-Price) < StopLevel)
                       if (Redefinition) Price = ND(Bid-StopLevel);
                       else              return(2);
                     if (ND(Price-TP) < StopLevel)
                       if (Redefinition) TP = ND(Price-StopLevel);
                       else              return(4);
                     if (ND(SL-Price) < StopLevel && SL != 0)
                       if (Redefinition) SL = ND(Price+StopLevel);
                       else              return(3);
                     break;
    case OP_BUYLIMIT: 
                     S = "BUYLIMIT";
                     if (ND(Ask-Price) < StopLevel)
                      if (Redefinition) Price = ND(Ask-StopLevel);
                      else              return(2);
                     if (ND(TP-Price) < StopLevel && TP != 0)
                       if (Redefinition) TP = ND(Price+StopLevel);
                       else              return(4);
                     if (ND(Price-SL) < StopLevel)
                       if (Redefinition) SL = ND(Price-StopLevel);
                       else              return(3);
                     break;
    case OP_SELLLIMIT: 
                     S = "SELLLIMIT";
                     if (ND(Price - Bid) < StopLevel) 
                       if (Redefinition) Price = ND(Bid+StopLevel);
                       else              return(2);
                     if (ND(Price-TP) < StopLevel)
                       if (Redefinition) TP = ND(Price-StopLevel);
                       else              return(4);
                     if (ND(SL-Price) < StopLevel && SL != 0)
                       if (Redefinition) SL = ND(Price+StopLevel);
                       else              return(3);
                     break;
   }
// - 2 - == Îêîí÷àíèå áëîêà =============================================================
 
// - 3 - == Îòêðûòèå îðäåðà ñ îæèäàíèå òîðãîâîãî ïîòîêà =================================
 if(WaitForTradeContext())  // îæèäàíèå îñâîáîæäåíèÿ òîðãîâîãî ïîòîêà
   {  
    Comment("Îòïðàâëåí çàïðîñ íà îòêðûòèå îðäåðà ", S, " ...");  
    int ticket=OrderSend(Symbol(), Type, Lots, Price, 3, 
               SL, TP, NULL, MagicNumber, 0);// îòêðûòèå ïîçèöèè
    // Ïîïûòêà îòêðûòèÿ ïîçèöèè çàâåðøèëàñü íåóäà÷åé
    if(ticket<0)
      {
       int Error = GetLastError();
       if(Error == 2 || Error == 5 || Error == 6 || Error == 64 
          || Error == 132 || Error == 133 || Error == 149)     // ñïèñîê ôàòàëüíûõ îøèáîê
         {
          Comment("Ôàòàëüíàÿ îøèáêà ïðè îòêðûòèè ïîçèöèè ò. ê. "+
                   ErrorToString(Error)+" Ñîâåòíèê îòêëþ÷åí!");
          FatalError = True;
         }
        else 
         Comment("Îøèáêà îòêðûòèÿ ïîçèöèè ", S, ": ", Error);       // íåôàòàëüíàÿ îøèáêà
       return(1);
      }
    // ---------------------------------------------
    
    // Óäà÷íîå îòêðûòèå ïîçèöèè   
    Comment("Ïîçèöèÿ ", S, " îòêðûòà óñïåøíî!"); 
    PlaySound(OpenOrderSound); 
    return(0); 
    // ------------------------
   }
  else
   {
    Comment("Âðåìÿ îæèäàíèÿ îñâîáîæäåíèÿ òîðãîâîãî ïîòîêà èñòåêëî!");
    return(1);  
   } 
// - 3 - == Îêîí÷àíèå áëîêà =============================================================
   
}

//+-------------------------------------------------------------------------------------+
//| Îòîáðàæåíèå ëèíèé ïîääåðæêè è ñîïðîòèâëåíèÿ                                         |
//+-------------------------------------------------------------------------------------+
void ShowChannel()
{
 if (Supp != 0 && Resis != 0)                                   // Åñëè óðîâíè îïðåäåëåíû
   {
    if (ObjectFind(SName) < 0)      // è îáúåêòà ïîääåðæêè íåò, òî ðèñóåì ëèíèþ ïîääåðæêè
      {
       ObjectCreate(SName, OBJ_TREND, 0, ChanStart, Supp, Time[0], Supp); 
       ObjectSet(SName, OBJPROP_RAY, False);
       ObjectSet(SName, OBJPROP_COLOR, SupportColor);
      }
     else      // åñëè ëèíèÿ ïîääåðæêè óæå åñòü, òî ïðîñòî ïåðåíîñèì åå íà íóæíûé óðîâåíü
      {
       ObjectMove(SName, 0, ChanStart, Supp);
       ObjectMove(SName, 1, Time[0], Supp);
      } 
    if (ObjectFind(RName) < 0)   // åñëè ñîïðîòèâëåíèÿ íåò, òî ðèñóåì ëèíèþ ñîïðîòèâëåíèÿ
      {
       ObjectCreate(RName, OBJ_TREND, 0, ChanStart, Resis, Time[0], Resis);
       ObjectSet(RName, OBJPROP_RAY, False);
       ObjectSet(RName, OBJPROP_COLOR, ResistanceColor);
      }
     else  // åñëè ëèíèÿ ñîïðîòèâëåíèÿ óæå åñòü, òî ïðîñòî ïåðåíîñèì åå íà íóæíûé óðîâåíü
      {
       ObjectMove(RName, 0, ChanStart, Resis);
       ObjectMove(RName, 1, Time[0], Resis);
      } 
   }
  else           // åñëè óðîâíè íå îïðåäåëåíû, òî óäàëÿåì ëèíèè ïîääåðæêè è ñîïðîòèâëåíèÿ
   {
    if (ObjectFind(SName) == 0)
      ObjectDelete(SName);
    if (ObjectFind(RName) == 0)
      ObjectDelete(RName);
   } 
}

//+-------------------------------------------------------------------------------------+
//| Ðàñ÷åò óðîâíåé ïîääåðæêè è ñîïðîòèâëåíèÿ                                            |
//+-------------------------------------------------------------------------------------+
void GetLevels()
{
 Supp = 0;
 Resis = 0;
// - 1 - == Ðàñ÷åò äàííûõ èíäèêàòîðà ÀÎ =================================================
 double AO1 = iAO(Symbol(), 0, 1);
 double AO2 = iAO(Symbol(), 0, 2); 
 double AO3 = iAO(Symbol(), 0, 3); 
// - 1 - == Îêîí÷àíèå áëîêà =============================================================

// - 2 - == Ïîèñê ñîïðîòèâëåíèÿ è ïîääåðæêè â ïîëîæèòåëüíîé çîíå èíäèêàòîðà ÀÎ ==========
 if (AO1 > 0)
   if (AO1 < AO2 && AO2 > AO3)                   // Áûëà êîððåêöèÿ âíèç ïîñëå âîñõîæäåíèÿ
     {
      // Ïîèñê áàðà, íà êîòîðîì çíà÷åíèå ÀÎ ñòàíîâèòñÿ îòðèöàòåëüíûì
      int i = 4;   
      while (AO3 > 0 && i < Bars)
        {
         AO3 = iAO(Symbol(), 0, i);
         i++;
        }
      if (i == Bars) return;                // åñëè äîøëè äî êîíöà èñòîðèè, òî ýòî îøèáêà
      // Ðàñ÷åò óðîâíåé
      Supp = Low[iLowest(Symbol(), 0, MODE_LOW, i-1)];
      Resis = High[iHighest(Symbol(), 0, MODE_HIGH, i-1)];
      ChanStart = Time[i-2];              // Çàïîìèíàåì âðåìÿ íà÷àëà äëÿ èíäèêàöèè êàíàëà
     }
// - 2 - == Îêîí÷àíèå áëîêà =============================================================

// - 3 - == Ïîèñê ñîïðîòèâëåíèÿ è ïîääåðæêè â îòðèöàòåëüíîé çîíå èíäèêàòîðà ÀÎ ==========
 if (AO1 < 0)
   if (AO1 > AO2 && AO2 < AO3)                      // Áûëà êîððåêöèÿ ââåðõ ïîñëå ïàäåíèÿ
     {
      // Ïîèñê áàðà, íà êîòîðîì çíà÷åíèå ÀÎ ñòàíîâèòñÿ ïîëîæèòåëüíûì
      i = 4;
      while (AO3 < 0 && i < Bars)
        {
         AO3 = iAO(Symbol(), 0, i);
         i++;
        } 
      if (i == Bars) return;                // åñëè äîøëè äî êîíöà èñòîðèè, òî ýòî îøèáêà
      // Ðàñ÷åò óðîâíåé
      Supp = Low[iLowest(Symbol(), 0, MODE_LOW, i-1)];
      Resis = High[iHighest(Symbol(), 0, MODE_HIGH, i-1)];
      ChanStart = Time[i-2];              // Çàïîìèíàåì âðåìÿ íà÷àëà äëÿ èíäèêàöèè êàíàëà
     }
// - 3 - == Îêîí÷àíèå áëîêà =============================================================
 
 ShowChannel();                                                    // Îòîáðàæåíèå óðîâíåé
}

//+-------------------------------------------------------------------------------------+
//| Ïðèâåäåíèå çíà÷åíèé ê òî÷íîñòè îäíîãî òèêà                                          |
//+-------------------------------------------------------------------------------------+
double NP(double A)
{
 return(MathFloor(A/Tick)*Tick);
}  

//+-------------------------------------------------------------------------------------+
//| Óñòàíîâêà îðäåðîâ, ïîäòÿæêà ñòîïîâ                                                  |
//+-------------------------------------------------------------------------------------+
bool SetOrders()
{
// - 1 - == Ðàñ÷åò óðîâíåé âõîäà è âûõîäà èç ñäåëîê =====================================
 bool Buy = False, Sell = False;                                 // Ñäåëêè åùå íå íàéäåíû
 double BuyStop = NP(Resis + Spread + Tick);// Öåíà îòêðûòèÿ äëÿ BuyStop è ñòîïà äëÿ Sell
 double SellStop = NP(Supp - Tick);         // Öåíà îòêðûòèÿ äëÿ SellStop è ñòîïà äëÿ Buy
 double BuyTake = NP(2*BuyStop - SellStop);                       // Öåíà äëÿ ïðîôèòà Buy
 double SellTake = NP(2*SellStop - BuyStop);                     // Öåíà äëÿ ïðîôèòà Sell
// - 1 -  == Îêîí÷àíèå áëîêà ============================================================

// - 2 - == Ïîèñê ñâîèõ îðäåðîâ/ïîçèöèé =================================================
 for (int i = OrdersTotal()-1; i >= 0; i--)
   if (OrderSelect(i, SELECT_BY_POS))
     if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
// - 2 -  == Îêîí÷àíèå áëîêà ============================================================

// - 3 - == Íàéäåí BUY ==================================================================
       {
        RefreshRates();
        if (OrderType() == OP_BUY)
          {
           Buy = True;
           // Åñëè ó BUY óñòàíîâëåí íåâåðíûé ñòîï, òî èçìåíÿåì ñòîï è ïðîôèò
           if (ND(OrderStopLoss() - SellStop) != 0 && ND(Bid - StopLevel - SellStop) > 0
               && ND(BuyTake - Bid - StopLevel) > 0)
             if (WaitForTradeContext())
               if (!OrderModify(OrderTicket(), 0, SellStop, BuyTake, 0))
                 return(False);
          }       
// - 3 -  == Îêîí÷àíèå áëîêà ============================================================

// - 4 - == Íàéäåí BUYSTOP ==============================================================
        if (OrderType() == OP_BUYSTOP)
          {
           Buy = True;
           // Åñëè ó îðäåðà íåïðàâèëüíàÿ öåíà îòêðûòèÿ, òî èçìåíÿåì öåíó, ñòîï è ïðîôèò
           if (ND(OrderOpenPrice() - BuyStop) != 0 && ND(BuyStop - Ask - StopLevel) > 0
               && ND(OrderOpenPrice() - Ask - FreezeLevel) > 0)
             if (WaitForTradeContext())
               if (!OrderModify(OrderTicket(), BuyStop, SellStop, BuyTake, 0))
                 return(False);
          }       
// - 4 -  == Îêîí÷àíèå áëîêà ============================================================

// - 5 - == Íàéäåí SELL =================================================================
        if (OrderType() == OP_SELL)
          {
           Sell = True;
           if (ND(OrderStopLoss() - BuyStop) != 0 && ND(BuyStop - Ask - StopLevel) > 0 &&
               ND(Bid - StopLevel - SellTake) > 0)
             if (WaitForTradeContext())
               if (!OrderModify(OrderTicket(), 0, BuyStop, SellTake, 0))
                 return(False);
          }       
// - 5 -  == Îêîí÷àíèå áëîêà ============================================================

// - 6 - == Íàéäåí SELLSTOP =============================================================
        if (OrderType() == OP_SELLSTOP)
          {
           Sell = True;
           if (ND(OrderOpenPrice() - SellStop) != 0 && ND(Bid - SellStop - StopLevel) > 0
               && ND(Bid - OrderOpenPrice() - FreezeLevel) > 0)
             if (WaitForTradeContext())
               if (!OrderModify(OrderTicket(), SellStop, BuyStop, SellTake, 0))
                 return(False);
          }       
       }
// - 6 - === Îêîí÷àíèå áëîêà ============================================================
       
// - 7 - == BuyStop èëè Buy íå íàéäåíû - óñòàíîâêà BuyStop ==============================
 if (!Buy && Ask < Resis)
   if (OpenOrderCorrect(OP_BUYSTOP, BuyStop, SellStop, BuyTake) > 0)
     return(False);
// - 7 - === Îêîí÷àíèå áëîêà ============================================================
 
// - 8 - == SellStop èëè Sell íå íàéäåíû - óñòàíîâêà SellStop ===========================
 if (!Sell && Bid > Supp)
   if (OpenOrderCorrect(OP_SELLSTOP, SellStop, BuyStop, SellTake) > 0)
     return(False);
// - 8 - === Îêîí÷àíèå áëîêà ============================================================
}
 
//+-------------------------------------------------------------------------------------+
//| Ôóíêöèÿ START ýêñïåðòà                                                              |
//+-------------------------------------------------------------------------------------+
int start()
  {
// - 1 -  == Ðàçðåøåíî ëè ñîâåòíèêó ðàáîòàòü? ===========================================
   if (!Activate || FatalError)             // Îòêëþ÷àåòñÿ ðàáîòà ñîâåòíèêà, åñëè ôóíêöèÿ
    return(0);           //  init çàâåðøèëàñü ñ îøèáêîé  èëè èìåëà ìåñòî ôàòàëüíàÿ îøèáêà
// - 1 -  == Îêîí÷àíèå áëîêà ============================================================
     
// - 2 - == Ñáîð èíôîðìàöèè îá óñëîâèÿõ òîðãîâëè ========================================
   Spread = ND(MarketInfo(Symbol(), MODE_SPREAD)*Point);                 // òåêóùèé ñïðýä
   StopLevel = ND(MarketInfo(Symbol(), MODE_STOPLEVEL)*Point);  // òåêóùèé óðîâåíü ñòîïîâ 
// - 2 -  == Îêîí÷àíèå áëîêà ============================================================
   
   if (LastBar == Time[0])
     return(0);
     
// - 3 - == Ðàñ÷åò ïîñëåäíèõ ïîääåðæêè è ñîïðîòèâëåíèÿ ==================================
   GetLevels();
// - 3 -  == Îêîí÷àíèå áëîêà ============================================================

// - 4 - == Óñòàíîâêà îðäåðîâ ===========================================================
   if (Supp != 0 && Resis != 0)       // Óñòàíîâêà îðäåðîâ òîëüêî, åñëè îïðåäåëåíû óðîâíè
     if (!SetOrders()) return(0);
// - 4 -  == Îêîí÷àíèå áëîêà ============================================================

   LastBar = Time[0];                                             // Íîâûé áàð "ïîñ÷èòàí"

   return(0);
  }

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
29 reports
EUR/USD Jul 2025 - Sep 2025
4.02
Total Trades 160
Won Trades 118
Lost trades 42
Win Rate 73.75 %
Expected payoff 23.99
Gross Profit 5111.80
Gross Loss -1272.60
Total Net Profit 3839.20
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
3.81
Total Trades 235
Won Trades 166
Lost trades 69
Win Rate 70.64 %
Expected payoff 15.11
Gross Profit 4817.50
Gross Loss -1265.80
Total Net Profit 3551.70
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
1.22
Total Trades 51
Won Trades 23
Lost trades 28
Win Rate 45.10 %
Expected payoff 3.40
Gross Profit 968.59
Gross Loss -795.33
Total Net Profit 173.26
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
1.19
Total Trades 150
Won Trades 59
Lost trades 91
Win Rate 39.33 %
Expected payoff 2.60
Gross Profit 2483.10
Gross Loss -2093.10
Total Net Profit 390.00
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
1.17
Total Trades 142
Won Trades 63
Lost trades 79
Win Rate 44.37 %
Expected payoff 2.12
Gross Profit 2059.51
Gross Loss -1758.30
Total Net Profit 301.21
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
1.07
Total Trades 81
Won Trades 34
Lost trades 47
Win Rate 41.98 %
Expected payoff 1.27
Gross Profit 1553.70
Gross Loss -1450.60
Total Net Profit 103.10
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.95
Total Trades 136
Won Trades 48
Lost trades 88
Win Rate 35.29 %
Expected payoff -1.09
Gross Profit 2985.87
Gross Loss -3133.51
Total Net Profit -147.64
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.93
Total Trades 64
Won Trades 31
Lost trades 33
Win Rate 48.44 %
Expected payoff -1.22
Gross Profit 1074.79
Gross Loss -1153.01
Total Net Profit -78.22
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.91
Total Trades 71
Won Trades 23
Lost trades 48
Win Rate 32.39 %
Expected payoff -1.02
Gross Profit 729.42
Gross Loss -802.06
Total Net Profit -72.64
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.90
Total Trades 132
Won Trades 54
Lost trades 78
Win Rate 40.91 %
Expected payoff -1.27
Gross Profit 1563.60
Gross Loss -1730.70
Total Net Profit -167.10
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.85
Total Trades 68
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -1.83
Gross Profit 729.20
Gross Loss -853.80
Total Net Profit -124.60
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.84
Total Trades 57
Won Trades 23
Lost trades 34
Win Rate 40.35 %
Expected payoff -1.59
Gross Profit 490.04
Gross Loss -580.87
Total Net Profit -90.83
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.81
Total Trades 123
Won Trades 44
Lost trades 79
Win Rate 35.77 %
Expected payoff -1.52
Gross Profit 817.00
Gross Loss -1004.30
Total Net Profit -187.30
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.81
Total Trades 122
Won Trades 50
Lost trades 72
Win Rate 40.98 %
Expected payoff -1.57
Gross Profit 824.30
Gross Loss -1016.30
Total Net Profit -192.00
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.80
Total Trades 131
Won Trades 56
Lost trades 75
Win Rate 42.75 %
Expected payoff -2.64
Gross Profit 1387.45
Gross Loss -1732.81
Total Net Profit -345.36
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.79
Total Trades 148
Won Trades 50
Lost trades 98
Win Rate 33.78 %
Expected payoff -3.35
Gross Profit 1881.60
Gross Loss -2377.60
Total Net Profit -496.00
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.72
Total Trades 155
Won Trades 64
Lost trades 91
Win Rate 41.29 %
Expected payoff -6.99
Gross Profit 2741.08
Gross Loss -3825.00
Total Net Profit -1083.92
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.70
Total Trades 70
Won Trades 25
Lost trades 45
Win Rate 35.71 %
Expected payoff -5.50
Gross Profit 877.93
Gross Loss -1263.04
Total Net Profit -385.11
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.68
Total Trades 228
Won Trades 73
Lost trades 155
Win Rate 32.02 %
Expected payoff -5.34
Gross Profit 2564.32
Gross Loss -3782.48
Total Net Profit -1218.16
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
0.68
Total Trades 227
Won Trades 69
Lost trades 158
Win Rate 30.40 %
Expected payoff -4.15
Gross Profit 1979.28
Gross Loss -2921.58
Total Net Profit -942.30
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.67
Total Trades 78
Won Trades 29
Lost trades 49
Win Rate 37.18 %
Expected payoff -5.58
Gross Profit 875.12
Gross Loss -1310.65
Total Net Profit -435.53
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.66
Total Trades 77
Won Trades 26
Lost trades 51
Win Rate 33.77 %
Expected payoff -4.89
Gross Profit 735.00
Gross Loss -1111.60
Total Net Profit -376.60
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.63
Total Trades 128
Won Trades 41
Lost trades 87
Win Rate 32.03 %
Expected payoff -8.87
Gross Profit 1936.12
Gross Loss -3071.54
Total Net Profit -1135.42
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.62
Total Trades 212
Won Trades 65
Lost trades 147
Win Rate 30.66 %
Expected payoff -4.16
Gross Profit 1415.60
Gross Loss -2297.00
Total Net Profit -881.40
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.60
Total Trades 132
Won Trades 49
Lost trades 83
Win Rate 37.12 %
Expected payoff -5.40
Gross Profit 1077.60
Gross Loss -1790.98
Total Net Profit -713.38
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.58
Total Trades 56
Won Trades 19
Lost trades 37
Win Rate 33.93 %
Expected payoff -6.01
Gross Profit 474.20
Gross Loss -810.60
Total Net Profit -336.40
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.50
Total Trades 115
Won Trades 29
Lost trades 86
Win Rate 25.22 %
Expected payoff -8.98
Gross Profit 1030.48
Gross Loss -2063.59
Total Net Profit -1033.11
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.42
Total Trades 48
Won Trades 12
Lost trades 36
Win Rate 25.00 %
Expected payoff -11.97
Gross Profit 411.80
Gross Loss -986.20
Total Net Profit -574.40
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.39
Total Trades 108
Won Trades 24
Lost trades 84
Win Rate 22.22 %
Expected payoff -11.09
Gross Profit 759.37
Gross Loss -1956.82
Total Net Profit -1197.45
-100%
-50%
0%
50%
100%

Comments