Sidus-Crossover_Signal

Download script
Sidus-Crossover_Signal

This script is designed as a technical analysis tool for the MetaTrader platform. Its primary purpose is to identify specific market trends and potential entry points by combining multiple moving average types, price range calculations, and momentum oscillators (specifically RSI and CCI).

Core Logic Overview

The script functions by monitoring three distinct layers of data: trend direction, "tunnel" confirmations, and final signal execution.

1. The "Sidus Tunnel" (Trend Confirmation)

The foundation of the logic relies on comparing two different types of Exponential Moving Averages (EMAs).

  • Upward Trend: When a faster EMA crosses above a slower EMA, the script identifies an "Up Tunnel." This is visually represented by a dot confirming an ascending trend.
  • Downward Trend: When a faster EMA crosses below a slower EMA, it identifies a "Down Tunnel," represented by a dot confirming a descending trend.

This serves as the baseline environment; the script effectively checks whether the overall momentum is currently bullish or bearish before looking for specific trade signals.

2. Price Action and Volatility

To ensure that signals are placed at appropriate distances from the price candles, the script calculates a dynamic "Range." It does this by averaging the difference between the high and low prices over the last 10 bars. This calculation allows the script to automatically adjust the distance of its visual markers (arrows and dots) based on how volatile or calm the market is at any given moment.

3. The Signal Execution (The Buy/Sell Arrows)

The script does not trigger a signal simply because an EMA crosses; it requires a specific "confluence" of factors to occur simultaneously:

  • Trend Alignment: It checks if the current Linear Weighted Moving Averages (LWMA) have successfully moved beyond the Sidus Tunnel boundaries.
  • Crossover Verification: It validates that the price action has shifted from a previous state (e.g., moving from below a boundary to above it).
  • Momentum Filtering: While the primary logic focuses on the moving average crossovers and tunnel states, the script is structured to incorporate RSI (Relative Strength Index) and CCI (Commodity Channel Index) as data points to ensure the moves have sufficient strength.

4. Alerts and Notifications

When the logic confirms a "Buy" or "Sell" signal based on the criteria above, the script performs three actions:

  • Visual Cues: It places an arrow on the chart (Blue for Buy, Yellow/Red for Sell) at a distance calculated by the price range.
  • Sound Alerts: It triggers an audible notification within the trading platform.
  • Email Notifications: If enabled by the user, it sends an automated email alert containing the specific signal and the currency pair being monitored.

Summary of Behavior

In simple terms, this script acts as a "filter." It monitors the general direction of the market (The Tunnel) and waits for the faster price averages to break out of that tunnel in alignment with the trend. Once all these conditions align, it notifies the user with a visual arrow and an alert, indicating a potential high-probability trade entry.

Indicators Used
Moving average indicatorRelative strength indexCommodity channel index
Miscellaneous
Implements a curve of type %1It sends emails
15 Views
1 Downloads
0 Favorites
Sidus-Crossover_Signal
// Original Sidus Method filtered with RSI and CCI.
// Edited by Tians using Sidus-Crossover_Signal.mq4 as a
// template.
//(Tians)

/*
  +------------------------------------------------------------------+
  | Shows an arrow when there is a Sidus signal.  Shows dots when    |
  | the Sidus tunnel crosses.   Blue dot confirms uptrend.  Red dot  |
  | confirms downtrend.  Alerts on Sidus signal by default - Sounds  |
  | alert and sends e-mail.                                          |
  +------------------------------------------------------------------+
*/   

extern bool Alerts = true;
extern bool Tunnel_Alerts= false;
extern bool Email_Alerts = false;

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Yellow
#property indicator_color3 Blue
#property indicator_color4 Yellow

#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_width4 1

double CrossUp[];
double CrossDown[];
double Tup[];
double Tdown[];
bool   DownTunnel = false;
bool   UpTunnel = false;
bool   Signal = false;

extern int FasterLWMA = 2;
extern int SlowerLWMA = 8;
extern int FasterSidusEMA = 18;
extern int SlowerSidusEMA = 28;

int upalert=false,downalert=false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW, EMPTY);
   SetIndexArrow(0, 241);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW, EMPTY);
   SetIndexArrow(1, 242);
   SetIndexBuffer(1, CrossDown);
   SetIndexStyle(2, DRAW_ARROW, EMPTY);
   SetIndexArrow(2, 167);
   SetIndexBuffer(2, Tup);
   SetIndexStyle(3, DRAW_ARROW, EMPTY);
   SetIndexArrow(3, 167);
   SetIndexBuffer(3, Tdown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int limit, i, counter;
   double RSI, RSIp, CCI, FasterLWMAnow, SlowerLWMAnow, FasterLWMAprevious, SlowerLWMAprevious, FasterLWMAafter, SlowerLWMAafter, fasterSidusEMAnow, fasterSidusEMAprevious, fasterSidusEMAafter, slowerSidusEMAnow, slowerSidusEMAprevious, slowerSidusEMAafter;
   double Range, AvgRange;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;

   limit=Bars-counted_bars;
   
   for(i = 0; i <= limit; i++) {

      counter=i;
      Range=0;
      AvgRange=0;
   
      for (counter=i ;counter<=i+9;counter++)
      {
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
      }

      Range=AvgRange/10;
       
      FasterLWMAnow = iMA(NULL, 0, FasterLWMA, 0, MODE_LWMA, PRICE_CLOSE, i);
      FasterLWMAprevious = iMA(NULL, 0, FasterLWMA, 0, MODE_LWMA, PRICE_CLOSE, i+1);
      FasterLWMAafter = iMA(NULL, 0, SlowerLWMA, 0, MODE_LWMA, PRICE_CLOSE, i-1);

      SlowerLWMAnow = iMA(NULL, 0, SlowerLWMA, 0, MODE_LWMA, PRICE_CLOSE, i);
      SlowerLWMAprevious = iMA(NULL, 0, SlowerLWMA, 0, MODE_LWMA, PRICE_CLOSE, i+1);
      SlowerLWMAafter = iMA(NULL, 0, SlowerLWMA, 0, FasterLWMA, PRICE_CLOSE, i-1);

      fasterSidusEMAnow = iMA(NULL, 0, FasterSidusEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      fasterSidusEMAprevious = iMA(NULL, 0, FasterSidusEMA, 0, MODE_EMA, PRICE_CLOSE, i+1);
      fasterSidusEMAafter = iMA(NULL, 0, FasterSidusEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);

      slowerSidusEMAnow = iMA(NULL, 0, SlowerSidusEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      slowerSidusEMAprevious = iMA(NULL, 0, SlowerSidusEMA, 0, MODE_EMA, PRICE_CLOSE, i+1);
      slowerSidusEMAafter = iMA(NULL, 0, SlowerSidusEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);
      
      RSI=iRSI(NULL,0,21,PRICE_CLOSE,i);
      RSIp=iRSI(NULL,0,21,PRICE_CLOSE,i+1);
      
      CCI=iCCI(NULL,0,50,PRICE_CLOSE,i);
      
      if (   fasterSidusEMAnow > slowerSidusEMAnow &&
             fasterSidusEMAprevious <= slowerSidusEMAprevious &&
             fasterSidusEMAafter > slowerSidusEMAafter )
      { 
         UpTunnel=true; DownTunnel=false; Tup[i] = Low[i] - Range*1;
         if( i<=2 && Alerts && !upalert && Tunnel_Alerts )
         {
            upalert=true; downalert=false;
            Alert (Symbol()," ",Period(),"M  Sidus Tunnel UP ");
            if ( Email_Alerts ) { SendMail("Sidus Tunnel UP "+Symbol(),""); }
         }
      }

      if ( fasterSidusEMAnow < slowerSidusEMAnow &&
           fasterSidusEMAprevious >= slowerSidusEMAprevious &&
           fasterSidusEMAafter < slowerSidusEMAafter )
      {
         DownTunnel=true; UpTunnel=false; Tdown[i] = High[i] + Range*1.2;
         if( i<=2 && Alerts && !downalert && Tunnel_Alerts )
         {
            upalert=false; downalert=true;
            Alert (Symbol()," ",Period(),"M  Sidus Tunnel DOWN ");
            if ( Email_Alerts ) { SendMail("Sidus Tunnel DOWN "+Symbol(),""); }
         }
      }
      
      if (  
           ( // Conditions for up signal for EMA-Sidus crosses
             (( FasterLWMAnow > fasterSidusEMAnow && FasterLWMAnow > slowerSidusEMAnow ) ||
              ( SlowerLWMAnow > fasterSidusEMAnow && SlowerLWMAnow > slowerSidusEMAnow )) &&
             ( FasterLWMAprevious <= fasterSidusEMAprevious || FasterLWMAprevious <= slowerSidusEMAprevious ) &&
             ( SlowerLWMAprevious <= fasterSidusEMAprevious || SlowerLWMAprevious <= slowerSidusEMAprevious ) &&
             // RSI > 50 &&
             // CCI > 0 &&
             UpTunnel
           )
         )
         {   // IF all that above is correct, then do this:
             UpTunnel=false;
             DownTunnel=false;
             Signal=true;
             CrossUp[i] = Low[i] - Range*1.6;
             if(i<=2 && Alerts && !upalert)
               {
                  Alert (Symbol()," ",Period(),"M  Sidus BUY ");
                  if ( Email_Alerts ) { SendMail("Sidus BUY "+Symbol(),""); }
                  upalert=true;
                  downalert=false;
               }
         }
      
      if (  
           ( // Conditions for down signal for EMA-Sidus crosses too
             (( FasterLWMAnow < fasterSidusEMAnow && FasterLWMAnow < slowerSidusEMAnow ) ||
              ( SlowerLWMAnow < fasterSidusEMAnow && SlowerLWMAnow < slowerSidusEMAnow )) &&
             ( FasterLWMAprevious >= fasterSidusEMAprevious || FasterLWMAprevious >= slowerSidusEMAprevious ) &&
             ( SlowerLWMAprevious >= fasterSidusEMAprevious || SlowerLWMAprevious >= slowerSidusEMAprevious ) &&
             // RSI < 50 &&
             // CCI < 0 &&
             DownTunnel
           )
         )
         {   // IF all that above is correct, then do this:
             UpTunnel=false;
             DownTunnel=false;
             Signal=true;
             CrossDown[i] = High[i] + Range*1.2;
             if(i<=2 && Alerts && !downalert)
               {
                  Alert (Symbol()," ",Period(),"M  Sidus SELL ");
                  if ( Email_Alerts ) { SendMail("Sidus SELL "+Symbol(),""); }
                  downalert=true;
                  upalert=false;
               }
         }
   }
   
   return(0);
}

Comments