Sonic_StoIK

Download script
Author: Copyright � 2008, DGC & Sonic
Sonic_StoIK

The Sonic_StoIK script is a technical analysis tool designed to identify potential market trends and entry points by processing multiple financial indicators simultaneously. Instead of relying on a single metric, it evaluates the "health" of the market through several layers of data to generate visual signals for traders.

Core Logic Overview

The script operates by analyzing four distinct sets of logic:

1. The Regular Signal System This is the primary mechanism for identifying trading opportunities. It looks for a specific "confluence"—a situation where multiple conditions align at once. For a Buy signal to appear, the following must occur simultaneously:

  • Momentum: The Stochastic oscillator must be moving upward and remain above its signal line.
  • Trend Strength: The i-Trend indicator must show positive strength (specifically exceeding a pre-defined threshold).
  • Relative Strength: The RSI (Relative Strength Index) must be above a neutral midpoint.
  • Market Pressure: The DeMaker and Force Index indicators must both confirm positive buying pressure.

Conversely, a Sell signal is triggered only when all of these conditions flip to their negative counterparts (downward momentum, downward trend strength, lower RSI, and bearish market pressure).

2. The AES Signal System This serves as an alternative or supplementary signal logic. It focuses on:

  • Momentum Shifts: Comparing current values against previous ones to detect immediate changes in velocity.
  • Short-term Oscillations: Using a faster Stochastic calculation to identify quick turns in the market price.

3. Trend Filtering (SMA) The script includes an optional Simple Moving Average (SMA) filter. This acts as a "big picture" guide. If enabled, it checks if the current price is trading above or below a long-term average. This allows traders to ensure they are only taking signals that align with the broader market direction (e.g., only buying when the price is in a general uptrend).

4. Momentum Filtering (RSI) A second optional filter utilizes the RSI to determine the market's current bias. It checks whether the RSI is above or below a 50-level midpoint, providing another layer of confirmation regarding whether the market currently has more buying or selling weight.

Visual Presentation

The tool translates these complex calculations into a dedicated visual window on the trading platform:

  • Histograms: Used to display the Regular and AES signals clearly.
  • Lines: Used to visualize the status of the SMA and RSI filters, allowing the user to see how the filters are reacting in real-time compared to the primary signals.
Indicators Used
Stochastic oscillatorRelative strength indexDeMarker indicatorForce indexBill Williams Accelerator/Decelerator oscillatorBill Williams Awesome oscillatorMoving average indicator
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
Sonic_StoIK
//+--------------------------------------------------------------------------+
//|                                                   Sonic_StoIK.mq4        |
//|                                            Copyright © 2008, Sonicdeejay |
//|                                                                          |
//+--------------------------------------------------------------------------+
#property copyright "Copyright © 2008, DGC & Sonic"
#property link      "http://tinyurl.com/497h3s/"

#include <WinUser32.mqh>

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Brown
#property indicator_width1 2
#property indicator_color2 DodgerBlue
#property indicator_width2 2
#property indicator_color3 Red
#property indicator_width3 2
#property indicator_color4 White
#property indicator_width4 1
#property indicator_style4 2
#property indicator_level1 0
#property indicator_minimum -1.2
#property indicator_maximum 1.2

extern string SEP1 = "----SIGNAL CONTROLS----";
extern bool Show_Sonic_Signals = true;
extern bool Show_AES_Signals = false;
extern string SEP2 = "----FILTER CONTROLS----";
extern bool Show_SMA_Filter = false;
extern int SMA_Filter_Period = 200;
extern bool Show_RSI_Filter = false;
extern int RSI_Filter_Period = 45;
/*extern string SEP3 = "----ALERT CONTROLS----";
extern bool Popup_Alerts_On = false;
extern bool Audio_Alerts_On = false;
extern bool EMail_Alerts_On = false;
extern int Alert_Signal = 0;
extern bool Alert_SMA_Filtered = false;
extern bool Alert_RSI_Filtered = false;
*/
double OzFX_Regular[];
double OzFX_AES[];
double Filter_SMA[];
double Filter_RSI[];
double   ItrendLevel           = 0.0018;  //iTrend line must be above this level
int iLastRegular;
double dLastAES;
int k;

bool bAlertSounded;

int init()
{
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexBuffer(0, OzFX_Regular);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(1, OzFX_AES);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(2, Filter_SMA);
   SetIndexStyle(3, DRAW_LINE);
   SetIndexBuffer(3, Filter_RSI);
   iLastRegular = 0;
   dLastAES = 0;
   bAlertSounded = false;
   return(0);
}

int start()
{


  
  
   for (k = Bars - 205; k >= 0; k --)
   {
   
  //--- Stochastics
  double sMain        = iStochastic(NULL,0,14,5,5,MODE_SMA,0,MODE_MAIN,k);
  double sSignal      = iStochastic(NULL,0,14,5,5,MODE_SMA,0,MODE_SIGNAL,k);
  
  double sMainprev        = iStochastic(NULL,0,14,5,5,MODE_SMA,0,MODE_MAIN,k+1);
  double sSignalprev      = iStochastic(NULL,0,14,5,5,MODE_SMA,0,MODE_SIGNAL,k+1);
  
  //--- i-Trend Index
  double iTredn1      =iCustom(NULL, 0, "i_Trend", 0, 0, 0, 20, 2, 13, 300, 0,  k); //green
  double iTredn2      =iCustom(NULL, 0, "i_Trend", 0, 0, 0, 20, 2, 13, 300, 1, k); //red
  
  
  //--- RSI
  double sRSI         = iRSI(NULL,0,14,0,k); 
  double sRSIL1       = 51;
  double sRSIL2       = 49;
  
   //DeMaker and FI
  double  DEM  = iDeMarker(NULL, 0, 14, k); 
  double  DEML = 0.5; 
  double  FI = iForce(NULL, 0, 14, 1, PRICE_CLOSE, k);
  
/*---------------------*/            
/*  OZFX REGULAR CODE  */
/*---------------------*/
      OzFX_Regular[k] = 0;
      if ((sMain>sSignal)&& (sMain>sMainprev)&&(iTredn1>ItrendLevel && iTredn1>iTredn2)&& (sRSI>=sRSIL1)&&(DEM>DEML)&&(FI>0)) // BUY
      {
         if (iLastRegular != 1) OzFX_Regular[k] = 1;
         iLastRegular = 1;
      }   
      
     if ((sMain<sSignal)&&(sMain<sMainprev)&&(iTredn2>ItrendLevel && iTredn2>iTredn1)&& (sRSI<=sRSIL2)&&(DEM<DEML)&&(FI<0)) // SELL
       
      {         if (iLastRegular != -1) OzFX_Regular[k] = -1;
         iLastRegular = -1;
      }   
      if (Show_Sonic_Signals == false) OzFX_Regular[k] = 0.0;
      
/*-----------------*/            
/*  OZFX AES CODE  */
/*-----------------*/
      OzFX_AES[k] = 0;
      if (/*iAC(Symbol(), 0, k) > 0 &&*/
          iAC(Symbol(), 0, k) > iAC(Symbol(), 0, k + 1) &&
          iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, k)
          > iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, k) /*&&
          iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, k + 1)
          < iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, k + 1) &&
          iAO(Symbol(), 0, k) > iAO(Symbol(), 0, k + 1)*/)
      {
         if (dLastAES != 0.7) OzFX_AES[k] = 0.7;
         dLastAES = 0.7;
      }   
      
      if (/*iAC(Symbol(), 0, k) < 0 &&*/
          iAC(Symbol(), 0, k) < iAC(Symbol(), 0, k + 1) &&
          iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, k)
          < iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, k) /*&&
          iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, k + 1)
          > iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, k + 1) &&
          iAO(Symbol(), 0, k) < iAO(Symbol(), 0, k + 1)*/)
      {
         if (dLastAES != -0.7) OzFX_AES[k] = -0.7;
         dLastAES = -0.7;
      }   
      if (Show_AES_Signals == false) OzFX_AES[k] = 0.0;             
/*-------------------*/            
/*  SMA FILTER CODE  */
/*-------------------*/            
      Filter_SMA[k] = 0;
      if (Close[k] > iMA(Symbol(), 0, SMA_Filter_Period, 0, MODE_SMA, PRICE_CLOSE, k))
         Filter_SMA[k] = 1;
      if (Close[k] <= iMA(Symbol(), 0, SMA_Filter_Period, 0, MODE_SMA, PRICE_CLOSE, k))
         Filter_SMA[k] = -1;
      if (Show_SMA_Filter == false) Filter_SMA[k] = EMPTY_VALUE;

/*-------------------*/            
/*  RSI FILTER CODE  */
/*-------------------*/            
      Filter_RSI[k] = 0;
      if (50 > iRSI(Symbol(), 0, RSI_Filter_Period, PRICE_CLOSE, k))
         Filter_RSI[k] = -1;
      if (50 <= iRSI(Symbol(), 0, RSI_Filter_Period, PRICE_CLOSE, k))
         Filter_RSI[k] = 1;
      if (Show_RSI_Filter == false) Filter_RSI[k] = EMPTY_VALUE;
   }

   return(0);
}

Comments