RSI trader v0.10

Download script
Author: Copyright � 2005, TraderSeven
Profit factor:
0.00

This trading script is designed to automate the process of identifying and executing trades based on the relationship between price momentum and relative strength. It functions by analyzing two primary indicators: Moving Averages (which track the average price over specific timeframes) and the Relative Strength Index (RSI, which measures the speed and change of price movements).

Core Trading Logic

The system operates by comparing "Short-Term" data against "Long-Term" data to determine the prevailing market trend. It specifically looks at:

  • Price Trends: Comparing a fast 9-period moving average against a slower 45-period moving average.
  • Momentum Strength: Comparing a fast 9-period RSI average against a slower 45-period RSI average.

Market Conditions and Actions

The script categorizes the market into three distinct states to decide whether to enter or exit a position:

1. Bullish Trend (Buy Signal) If both the short-term price average is higher than the long-term price average, AND the short-term momentum (RSI) is higher than the long-term momentum, the script identifies a strong upward trend. If no other trades are currently open, it will automatically execute a Buy order.

2. Bearish Trend (Sell Signal) If both the short-term price average is lower than the long-term price average, AND the short-term momentum (RSI) is lower than the long-term momentum, the script identifies a strong downward trend. If no other trades are currently open, it will automatically execute a Sell order.

3. Sideways Market (Exit Signal) The script identifies "Sideways" or conflicting conditions—situations where the price and momentum indicators are moving in opposite directions (e.g., price is rising while momentum is falling, or vice versa). In these instances, the script acts as a safety mechanism: if you already have an open trade, it will detect the lack of a clear trend and automatically close the position to protect your capital.

Summary of Execution

  • Entry: Only occurs when price and momentum align in the same direction (both up or both down).
  • Exit: Automatically triggers when the market becomes "choppy" or contradictory, ensuring that trades are closed during periods of uncertainty.
  • Trade Management: The script manages trade volume (Lot size) and allows for a small margin of error (Slippage) during execution to ensure smooth entries and exits in fast-moving markets.
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Indicators Used
Relative strength indexMoving average indicatorMoving average indicator
10 Views
0 Downloads
0 Favorites
RSI trader v0.10
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+-----------------------------------------------------------------------------+
//|                                                            RSI trader v0.15 |
//+-----------------------------------------------------------------------------+
#property copyright "Copyright © 2005, TraderSeven"
#property link      "TraderSeven@gmx.net"
 
//            \\|//             +-+-+-+-+-+-+-+-+-+-+-+             \\|// 
//           ( o o )            |T|r|a|d|e|r|S|e|v|e|n|            ( o o )
//    ~~~~oOOo~(_)~oOOo~~~~     +-+-+-+-+-+-+-+-+-+-+-+     ~~~~oOOo~(_)~oOOo~~~~
// Run on EUR/USD H1 
// At a certain time a small breakout often occurs.
//
//----------------------- HISTORY
// v0.10 Initial release.
//----------------------- TODO
// Test other pairs and timeframes.
// Trailing stop
 
extern int RSIPeriod=14;
extern int Short_price_MA_periods = 9;
extern int Long_price_MA_periods = 45;
extern int Short_RSI_MA_periods = 9;
extern int Long_RSI_MA_periods = 45;
extern double Lots = 1;
extern int Slippage=3;


//----------------------- MAIN PROGRAM LOOP

//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
int start()
  {
  
  int arraysize=200;
   double RSI[];
   double RSI_SMA[];
   ArrayResize(RSI,arraysize);
   ArrayResize(RSI_SMA,arraysize);
   ArraySetAsSeries(RSI,true);
   
   for(int i3=arraysize-1;i3>=0;i3--)
      RSI[i3]=iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i3);
   for(i3=arraysize-1;i3>=0;i3--)
      RSI_SMA[i3]=iMAOnArray(RSI,0,Short_RSI_MA_periods,0,MODE_SMA,i3);
double RSI9 =RSI_SMA[1];

   for(i3=arraysize-1;i3>=0;i3--)
      RSI[i3]=iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i3);
   for(i3=arraysize-1;i3>=0;i3--)
      RSI_SMA[i3]=iMAOnArray(RSI,0,Long_RSI_MA_periods,0,MODE_SMA,i3);
double RSI45 =RSI_SMA[1];


double Price45=iMA(NULL,0, Long_price_MA_periods ,0,MODE_LWMA,PRICE_CLOSE,1);
double Price9 =iMA(NULL,0, Short_price_MA_periods,0,MODE_SMA,PRICE_CLOSE,1);


bool Long=false;
bool Short=false;
bool Sideways=false;
if(Price9>Price45 && RSI9>RSI45) Long=true;
if(Price9<Price45 && RSI9<RSI45) Short=true; 
if(Price9>Price45 && RSI9<RSI45) Sideways=true;
if(Price9<Price45 && RSI9>RSI45) Sideways=true;  

if(Long==true  && OrdersTotal()==0)
  {
  OrderSend(Symbol(),OP_BUY ,Lots,Ask,Slippage,Ask/3,Ask*3,0,0,Blue);
  }
  
if(Short==true && OrdersTotal()==0)
  {
  OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid*3,Bid/3,0,0,Red);
  }  
  
if(Sideways==true  && OrdersTotal()!=0) 
  { 
  OrderSelect(0, SELECT_BY_POS, MODE_TRADES);
  Comment("Sideways detected");
  if(OrderType()==OP_BUY) OrderClose(OrderTicket(),1,Ask,3,Red); 
  if(OrderType()==OP_SELL) OrderClose(OrderTicket(),1,Bid,3,Red);
  }
}

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
4 reports
AUD/USD Oct 2024 - Jan 2025
0.00
Total Trades 1
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 6364.00
Gross Profit 6364.00
Gross Loss 0.00
Total Net Profit 6364.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.00
Total Trades 1
Won Trades 1
Lost trades 0
Win Rate 100.00 %
Expected payoff 6915.00
Gross Profit 6915.00
Gross Loss 0.00
Total Net Profit 6915.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00
Total Trades 1
Won Trades 1
Lost trades 0
Win Rate 100.00 %
Expected payoff 6243.00
Gross Profit 6243.00
Gross Loss 0.00
Total Net Profit 6243.00
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.00
Total Trades 1
Won Trades 1
Lost trades 0
Win Rate 100.00 %
Expected payoff 5989.14
Gross Profit 5989.14
Gross Loss 0.00
Total Net Profit 5989.14
-100%
-50%
0%
50%
100%

Comments