HI_Line_E_RSI_MA

Download script
Author: Copyright � 2009, Helen_Iv
Profit factor:
1.59

This automated trading script is designed to manage market entries and exits by analyzing price momentum and long-term trends. It operates as an "Expert Advisor," meaning it monitors the live market to make decisions based on specific mathematical conditions without requiring constant manual intervention.

Core Trading Logic

The system relies on three primary components to determine when to enter or exit a trade:

1. Momentum Analysis (RSI) The script uses a Relative Strength Index (RSI) to gauge whether an asset is being overbought or oversold. It looks at the change between the current momentum and the previous candle's momentum.

  • It seeks "crossover" points where the momentum shifts direction significantly, ensuring that it doesn't just enter a trade because the market is extreme, but rather because the trend is starting to turn.

2. Trend Filtering (Moving Averages) To ensure the system isn't trading against the major market direction, it uses two different Moving Averages calculated on a daily timeframe.

  • By comparing these averages, the script identifies the "health" of the overall trend. This acts as a secondary filter to verify that the short-term momentum signals align with the long-term price movement.

3. Execution Rules The logic is divided into clear "Open" and "Close" triggers:

  • Buy Signals: The script looks for a situation where the RSI momentum is rising above a specific threshold, combined with a confirmed upward trend in the daily moving averages.
  • Sell Signals: Conversely, it looks for a downward shift in RSI momentum while the long-term moving averages indicate a bearish environment.
  • Exit Strategy: The script also monitors "Close" conditions. If the RSI reaches opposite extremes (indicating the move might be exhausted), it will trigger an automatic exit to secure the position before the trend potentially reverses.

Operational Safeguards

To ensure smooth performance, the script includes several professional management features:

  • Single Trade Prevention: The logic is built to prevent "over-trading." It checks for existing positions on the current candle to ensure it doesn't open multiple redundant trades for the same signal.
  • Automated Profit Targets: Every trade opened by the script includes a pre-defined profit target (Take Profit). This ensures that once a certain price level is reached, the trade closes automatically.
  • Spread Awareness: The system accounts for the "Spread" (the difference between the buy and sell price provided by the broker), ensuring that trades are executed at realistic prices to protect the account from unnecessary costs.

In summary, this script acts as an automated filter: it waits for a specific moment where short-term momentum aligns with long-term trends, executes the trade with a predefined profit goal, and monitors the market to exit the position when the momentum begins to fade.

Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Relative strength indexMoving average indicator
16 Views
0 Downloads
0 Favorites
HI_Line_E_RSI_MA
//+------------------------------------------------------------------+
//|                                 Helen_Iv_Line_Experts_RSI_MA.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Helen_Iv"
#property link      "http://helenclubfinance.com"

//---- input parameters
extern double Lots=0.1;


extern int p=23;
extern int ma2=9;
extern int ma3=19;

extern int TakeProfit = 1000;


int BuyTicket,SellTicket;
int StLevel2;
double slts,tpts;
datetime prevtimecalc=0;
int OpenBuy=0, OpenSell=0, CloseBuy=0, CloseSell=0;
int Spread;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   double DeltaTakeStopMin, DeltaFreezeLevel;
   Spread = MarketInfo (Symbol(), MODE_SPREAD);
   
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+

int start()
{

   CalcCloseOpen();      

   int total=OrdersTotal();
   int NP=0;
   for(int x=total; x>=0; x--)
      {
      if (!OrderSelect(x, SELECT_BY_POS, MODE_TRADES))continue;
      // Çàêðûòèå îòêðûòûõ ïîçèöèé
      if (OrderType()==OP_BUY && CloseBuy==1){Close_Order(); continue;}
      if (OrderType()==OP_SELL && CloseSell==1) {Close_Order(); continue;}
      // èñêëþ÷àåì îòêðûòèå íåñêîëüêèõ îðäåðîâ íà ñèãíàëå îäíîì áàðà
      if (OrderType()==OP_BUY && OrderOpenPrice()>=Time[0]) NP++;
      if (OrderType()==OP_SELL && OrderOpenPrice()>=Time[0]) NP++;
      }
      
   // åñëè åùå åñòü ñèãíàë íà îòêðûòèå, òî áóäåì îòêðûâàòüñÿ
   if (NP == 0) Open_Buy_Sell ();
           
      

   return(0);
}
//+------------------------------------------------------------------+
// âû÷èñëèì óñëîâèÿ íà çàêðûòèå è îòêðûòèå ïîçèöèé
//+------------------------------------------------------------------+

void CalcCloseOpen()
{
   //Comment("000Buy - ", OpenBuy, " 000Sell - ", OpenSell);
   if (prevtimecalc==Time[0])return; else prevtimecalc=Time[0];
   OpenBuy=0; OpenSell=0; CloseBuy=0; CloseSell=0;    

   double t1=iRSI(NULL,0,p,PRICE_CLOSE,1);
   double t11=iRSI(NULL,0,p,PRICE_CLOSE,2);
   
   double t2=iMA(NULL,PERIOD_D1,ma2,0,MODE_EMA,0,1);

   double t3=iMA(NULL,PERIOD_D1,ma3,0,MODE_EMA,0,1);

   
   if (t1>30.0&&t11<30.0&&t1>t11&&t1>30.0&&t2>t3) {OpenBuy=1;}
   if (t1<70.0&&t11>70.0&&t1<t11&&t1<70.0) {CloseBuy=1;}
    
   if (t1<70.0&&t11>70.0&&t1<t11&&t1<70.0&&t2<t3) {OpenSell=1;} 
   if (t1>30.0&&t11<30.0&&t1>t11&&t1>30.0) {CloseSell=1;}
   //Comment("Buy - ", OpenBuy, " Sell - ", OpenSell);
   return;
}      


//+------------------------------------------------------------------
//|  Çàêðûòèå ïîçèöèé
//+------------------------------------------------------------------

void Close_Order ()
   {

    if(OrderType()==OP_BUY)
      {
          //Îáåñïå÷èâàåì ïàóçó ìåæäó îïåðàöèÿìè
          //Pause();
          OrderClose(OrderTicket(),OrderLots(),Bid,Spread,Yellow);
          //TradeIsNotBusy();
      }      

    if(OrderType()==OP_SELL)
      {
          //Îáåñïå÷èâàåì ïàóçó ìåæäó îïåðàöèÿìè
          //Pause();
          OrderClose(OrderTicket(),OrderLots(),Ask,Spread,Yellow);
          //TradeIsNotBusy();
      }      
   }
   
//+------------------------------------------------------------------
//|  Îòêðûòèå ïîçèöèé ðûíî÷íûìè îðäåðàìè
//+------------------------------------------------------------------

void Open_Buy_Sell ()

{
   // BUY
   // Open=Ask, Take =Open+Profit, Stop = Open-Spred-stop 
   if(OpenBuy !=0)
      {      		
      // îáíîâëÿåì ðûíî÷íóþ èíôîðìàöèþ
      if (!IsTesting() && !IsOptimization( )) RefreshRates();
      OrderSend(Symbol(),OP_BUY,Lots,Ask,Spread,0,Ask + TakeProfit*Point,0,0,0,Blue);
      if(GetLastError()==0){OpenBuy=0; return;}
      }
   // SELL
   // Open = Bid, Take =Open-Profit, Stop=Open+Spred+Stop
   
   if( OpenSell !=0)
      {      		
      if (!IsTesting() && !IsOptimization( )) {RefreshRates();}
      OrderSend(Symbol(),OP_SELL,Lots,Bid,Spread,0,Bid - TakeProfit*Point,0,0,0,Red); // èñïîëíÿåì
      if(GetLastError()==0) {OpenSell=0; return;}
      }   
   
   return(0);

}
   

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
17 reports
USD/JPY Jul 2025 - Sep 2025
6.49
Total Trades 22
Won Trades 19
Lost trades 3
Win Rate 86.36 %
Expected payoff 46.07
Gross Profit 1198.08
Gross Loss -184.58
Total Net Profit 1013.50
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
4.68
Total Trades 15
Won Trades 10
Lost trades 5
Win Rate 66.67 %
Expected payoff 19.21
Gross Profit 366.40
Gross Loss -78.30
Total Net Profit 288.10
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
3.45
Total Trades 21
Won Trades 15
Lost trades 6
Win Rate 71.43 %
Expected payoff 43.41
Gross Profit 1283.90
Gross Loss -372.20
Total Net Profit 911.70
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
3.27
Total Trades 25
Won Trades 21
Lost trades 4
Win Rate 84.00 %
Expected payoff 34.59
Gross Profit 1246.20
Gross Loss -381.52
Total Net Profit 864.68
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
2.03
Total Trades 14
Won Trades 10
Lost trades 4
Win Rate 71.43 %
Expected payoff 13.09
Gross Profit 361.08
Gross Loss -177.82
Total Net Profit 183.26
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.03
Total Trades 17
Won Trades 10
Lost trades 7
Win Rate 58.82 %
Expected payoff 0.79
Gross Profit 540.61
Gross Loss -527.23
Total Net Profit 13.38
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.95
Total Trades 16
Won Trades 7
Lost trades 9
Win Rate 43.75 %
Expected payoff -1.20
Gross Profit 362.70
Gross Loss -381.90
Total Net Profit -19.20
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.89
Total Trades 11
Won Trades 7
Lost trades 4
Win Rate 63.64 %
Expected payoff -5.61
Gross Profit 504.10
Gross Loss -565.80
Total Net Profit -61.70
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.85
Total Trades 11
Won Trades 6
Lost trades 5
Win Rate 54.55 %
Expected payoff -5.95
Gross Profit 363.30
Gross Loss -428.80
Total Net Profit -65.50
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.82
Total Trades 11
Won Trades 7
Lost trades 4
Win Rate 63.64 %
Expected payoff -8.30
Gross Profit 408.74
Gross Loss -500.04
Total Net Profit -91.30
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
0.68
Total Trades 17
Won Trades 8
Lost trades 9
Win Rate 47.06 %
Expected payoff -11.76
Gross Profit 428.10
Gross Loss -628.00
Total Net Profit -199.90
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.62
Total Trades 5
Won Trades 3
Lost trades 2
Win Rate 60.00 %
Expected payoff -26.27
Gross Profit 214.54
Gross Loss -345.87
Total Net Profit -131.33
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.57
Total Trades 17
Won Trades 9
Lost trades 8
Win Rate 52.94 %
Expected payoff -8.69
Gross Profit 192.64
Gross Loss -340.41
Total Net Profit -147.77
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.51
Total Trades 11
Won Trades 4
Lost trades 7
Win Rate 36.36 %
Expected payoff -24.02
Gross Profit 270.76
Gross Loss -534.96
Total Net Profit -264.20
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.22
Total Trades 5
Won Trades 3
Lost trades 2
Win Rate 60.00 %
Expected payoff -126.82
Gross Profit 181.60
Gross Loss -815.70
Total Net Profit -634.10
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.02
Total Trades 4
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -373.57
Gross Profit 32.80
Gross Loss -1527.10
Total Net Profit -1494.30
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.01
Total Trades 6
Won Trades 1
Lost trades 5
Win Rate 16.67 %
Expected payoff -432.27
Gross Profit 20.00
Gross Loss -2613.60
Total Net Profit -2593.60
-100%
-50%
0%
50%
100%

Comments