Author: FORTRADER.RU
Profit factor:
1.03

Okay, here's a breakdown of what this MetaTrader script does, explained in a way that doesn't require any programming knowledge:

Overall Goal:

This script is designed to automatically open and manage buy (long) and sell (short) trades based on certain market conditions, aiming to profit from price fluctuations. It uses technical indicators called Bollinger Bands and the Relative Strength Index (RSI) to identify potential trading opportunities.

How it Works (Step-by-Step):

  1. Setting the Stage (Parameters):

    • The script starts with a set of adjustable parameters, allowing users to customize its behavior. These parameters control things like:
      • Bollinger Band Settings: Bollinger Bands are like dynamic channels around the price. These settings control how wide those channels are, using three different settings (BB1, BB2, BB3).
      • RSI Settings: The RSI measures how overbought or oversold an asset is. Settings define the time frame used for this measurement (RSI) and how much leeway is given (predel and otstup).
      • Trade Size: The "Lots" parameter determines the size of the trades the script will place.
  2. Checking Existing Trades:

    • The script first checks if there are already open buy or sell trades. If there are, it remembers this and avoids opening a new trade in the same direction. This prevents the script from stacking too many similar trades.
  3. Identifying Potential Buy Signals:

    • **Bollinger Band Check:**The script checks if the lowest price of the previous bar has reached the third Bollinger Band (nbb3) .

    • RSI Confirmation: Once the previous price has touched the third Bollinger Band, the script looks back a few bars (defined by "predel") and checks if the RSI was below a certain level (30 in the code) at any of those points, indicating the asset might be oversold.

    • Buy Trigger: If both conditions are met (price touched the band and RSI was low), the script checks one final condition: whether the closing price of the previous bar is greater than the second bollinger band (nbb2). If there are no open buy trades, it will place a buy order.

    • Setting the Stop Loss: When the script opens a buy order, it calculates the point at which the order should close if the market goes the other way (the stoploss) and sets a green color in the code.

  4. Managing Existing Buy Trades:

    • If the script finds an open buy trade, it does the following:
      • Checking the second Bollinger Band: If price crosses the second Bollinger Band(vbb2) the script closes the order with the color violet on the code.
      • **Partial Closure and Trailing Stop:**The script sets a target price (setup2). When this target is achieved, the script is designed to close half the position (take some profit) and move the stop loss to break even (protect the remaining profit). If this target is achieved the script is programmed to make these changes just once.
  5. Identifying Potential Sell Signals:

    • The logic for sell trades is very similar to the buy trades, but in reverse:

    • **Bollinger Band Check:**The script checks if the highest price of the previous bar has reached the third Bollinger Band (vbb3) .

    • RSI Confirmation: The script checks if the RSI was above a certain level (70 in the code) at any of those points, indicating the asset might be overbought.

    • Sell Trigger: If both conditions are met and there are no open sell trades, the script will place a sell order.

    • Setting the Stop Loss: When the script opens a sell order, it calculates the point at which the order should close if the market goes the other way (the stoploss) and sets a white color in the code.

  6. Managing Existing Sell Trades:

    • If the script finds an open sell trade, it does the following:
      • Checking the second Bollinger Band: If price crosses the second Bollinger Band(nbb2) the script closes the order with the color violet on the code.
      • **Partial Closure and Trailing Stop:**The script sets a target price (setup2). When this target is achieved, the script is designed to close half the position (take some profit) and move the stop loss to break even (protect the remaining profit). If this target is achieved the script is programmed to make these changes just once.

In Summary:

The script watches the market using Bollinger Bands and RSI to find moments where the price might be about to reverse. It then opens trades, sets stop-loss orders to limit potential losses, and attempts to manage the trades by closing portions of it for a profit, and moving the stop loss to break even if the trade goes well.

Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
Indicators Used
Bollinger bands indicatorRelative strength index
12 Views
0 Downloads
1 Favorites
FullDamp
#property copyright "FORTRADER.RU"
#property link      "http://FORTRADER.RU"

/*

Ïîäðîáíîå îïèñàíèå ïàðàìåòðîâ ñîâåòíèêà äîñòóïíî â íîìåðå æóðíàëà îò 2 Èþíÿ, 
ïðåäëîæåíèÿ è îòçûâû ìû áóäåì ðàäû âèäåòü â íàøåé ýëåêòðîïî÷òå: letters@fortrader.ru
http://www.fortrader.ru/arhiv.php

A detailed description of the parameters adviser available issue of the journal dated Iune 2, 
suggestions and feedback we will be glad to see in our e-mail: letters@fortrader.ru
http://www.fortrader.ru/arhiv.php

Looking for an interpreter for the English version of the magazine on partnership.

*/




extern string x="Íàñòðîéêè BB:";
extern int BB1 = 20;
extern int BB2 = 20;
extern int BB3 = 20;
extern string x1="Íàñòðîéêè RSI:";
extern int RSI = 14;
extern int predel = 6;
extern int otstup = 10; 

extern double Lots=1;

datetime Bar,sBar;int buy,sell,i,a,b,nbb3ok,vbb3ok,nbar;double Sstoploss,stoploss,setup2,rsi,okbuy,oksell;

int start()
  {
  if (Volume[0]>1){return(0); }

     buy=0;sell=0;
     for(  i=0;i<OrdersTotal();i++)
         {
           OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
           if(OrderType()==OP_BUY){buy=1;}
           if(OrderType()==OP_SELL){sell=1;}
         }   
   
   double vbb1 =iBands(NULL,0,BB1,1,0,PRICE_CLOSE,MODE_UPPER,1);
   double vbb2 =iBands(NULL,0,BB2,2,0,PRICE_CLOSE,MODE_UPPER,1);
   double vbb3 =iBands(NULL,0,BB3,3,0,PRICE_CLOSE,MODE_UPPER,1);
   double nbb1 =iBands(NULL,0,BB1,1,0,PRICE_CLOSE,MODE_LOWER,1);
   double nbb2 =iBands(NULL,0,BB2,2,0,PRICE_CLOSE,MODE_LOWER,1);
   double nbb3 =iBands(NULL,0,BB3,3,0,PRICE_CLOSE,MODE_LOWER,1);
  
  
  if(Low[1]<=nbb3 )
  { okbuy=0;  Bar=Time[1];
  
      for( i=predel;i>0;i--)
      {
      double rsi=iRSI(NULL,0,RSI,PRICE_CLOSE,i);
      if(rsi<30){nbb3ok=1;}
      }
  }
  
 
  if(okbuy==0 && nbb3ok==1 && Close[1]>nbb2 && buy==0)
  {okbuy=1;nbb3ok=0;a=0;
   stoploss=Low[iLowest(NULL,0,MODE_LOW,iBarShift(NULL,0,Bar,FALSE),1)]-otstup*Point;
   OrderSend(Symbol(),OP_BUY,Lots,Ask,3,stoploss,0,0,16385,0,Green);
  
  }
  
  for(i=0;i<OrdersTotal();i++)
  {
   OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
   if(OrderType()==OP_BUY )
   {  
    double setup2=OrderOpenPrice()+((OrderOpenPrice()-OrderStopLoss()));
    
          if(High[1]>vbb2)
       {
        OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
       } 
       
      if(High[1]>setup2 && a==0)
      { 
         OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,White);
         OrderClose(OrderTicket(),OrderLots()/2,Bid,3,Violet); 
         a=1;
       }
 
       
    }      
  }
  
  /**********************************************sell**********************************************************/
  
    if(High[1]>=vbb3 )
  { oksell=0;  sBar=Time[1];
  
      for( i=predel;i>0;i--)
      {
      rsi=iRSI(NULL,0,RSI,PRICE_CLOSE,i);
      if(rsi>70){vbb3ok=1;}
      }
  }
 
  if(oksell==0 && vbb3ok==1 && Close[1]<vbb2 && sell==0)
  {oksell=1;vbb3ok=0;b=0;
   Sstoploss=High[iHighest(NULL,0,MODE_HIGH,iBarShift(NULL,0,sBar,FALSE),1)]+otstup*Point;
   OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Sstoploss,0,0,16385,0,White);
  }
  
  for(i=0;i<OrdersTotal();i++)
  {
   OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
   if(OrderType()==OP_SELL )
   {  
      setup2=OrderOpenPrice()-((OrderStopLoss()-OrderOpenPrice()));
      
       if(Low[1]<nbb2)
    {
     OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
    } 
     
      if(Low[1]<setup2 && b==0)
      {
       OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,White);
       OrderClose(OrderTicket(),OrderLots()/2,Ask,3,Violet); 
       b=1;
      }      
      
   
       
    }      
  }
  
  
   

   return(0);
  }

Profitability Reports

USD/CAD Oct 2024 - Jan 2025
2.45
Total Trades 29
Won Trades 16
Lost trades 13
Win Rate 55.17 %
Expected payoff 36.20
Gross Profit 1775.31
Gross Loss -725.63
Total Net Profit 1049.68
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.05
Total Trades 13
Won Trades 2
Lost trades 11
Win Rate 15.38 %
Expected payoff -160.92
Gross Profit 108.00
Gross Loss -2200.00
Total Net Profit -2092.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.52
Total Trades 27
Won Trades 14
Lost trades 13
Win Rate 51.85 %
Expected payoff -65.31
Gross Profit 1878.00
Gross Loss -3641.50
Total Net Profit -1763.50
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
1.11
Total Trades 17
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 7.29
Gross Profit 1291.00
Gross Loss -1167.00
Total Net Profit 124.00
-100%
-50%
0%
50%
100%

Comments