MultiSSRCplusSM
Download scriptThis script is designed as a sophisticated multi-timeframe analysis tool for the MetaTrader 4 platform. It serves to aggregate market data from various time periods simultaneously, allowing a trader to see how different time horizons (from minutes to days) interact with each other on a single chart.
Core Logic and Functionality
Multi-Timeframe Integration The primary purpose of this script is "Timeframe Synchronization." Instead of forcing you to switch back and forth between different charts to see the bigger picture, the script automatically pulls data from multiple timeframes (such as M15, M30, H1, H4, and D1) based on the specific chart you currently have open.
For example, if you are looking at a 5-minute chart, the script will intelligently calculate and display relevant data from larger windows like the 15-minute or 1-hour charts to give you a sense of the overall market trend.
The "SSRC" Component The script utilizes a logic referred to as "SSRC." It pulls this data across multiple timeframes to provide a layered view of price action. By displaying these different levels, it helps identify whether short-term movements are aligned with long-term trends or if the market is showing signs of divergence.
The "Snake Mood" Component The script incorporates a unique sentiment logic called "Snake Mood." This behaves as a filter or a secondary confirmation signal. It categorizes market "moods" into three distinct states:
- Bullish Momentum: Identified when the mood reaches high positive thresholds.
- Bearish Momentum: Identified when the mood reaches low negative thresholds.
- Neutral/Transitionary: When the market is between these extremes, the logic performs a comparative check against previous data points to determine if the momentum is shifting upward or downward.
How it Works for the User
When you load this script, it identifies your current chart's timeframe and automatically selects a "package" of other timeframes to monitor. It then calculates the SSRC and Snake Mood values for all those periods at once.
The results are displayed visually in a separate window:
- Histograms: These represent the "Snake Mood" levels, providing a quick visual cue of the market's current emotional state or strength.
- Lines: These represent the SSRC data from the various timeframes, allowing you to see the "layers" of the market movement.
Summary of Visual Hierarchy
The logic is designed so that as you move from smaller timeframes to larger ones, the script provides a smoother transition of information. It ensures that if the terminal is restarted or settings are changed, it recalculates the exact "shifted" time positions needed to keep the data aligned perfectly with your current view.
//+------------+-----------------------------------------------------+
//| v.27.04.07 | MultiSSRC_plus_SnakeMood.mq4 |
//+------------+ |
//| | Bookkeeper, 2007, yuzefovich@gmail.com |
//+------------+-----------------------------------------------------+
/********************************************************************/
/************ Presence SSRC.mq4 v.12.04.07 is necessary ************/
/************ Presence Snake.mq4 v.19.04.07 is necessary ************/
/********************************************************************/
/*** Working window Additional windows should be ***/
/*** with indicator open for loading quotations ***/
/*** M1....................M15,M30,H1 ***/
/*** M5....................M15,M30,H1 ***/
/*** M15...................M30,H1,H4 ***/
/*** M30...................H1,H4 ***/
/*** H1....................H4 ***/
/*** H4....................D1 ***/
/*** If the terminal has been switched off, ***/
/*** and then again included, ***/
/*** after loading quotations it is necessary ***/
/*** to restart the indicator ***/
/********************************************************************/
#property copyright ""
#property link "http://www.forexter.land.ru/indicators.htm"
//----
#property indicator_separate_window
#property indicator_maximum 1.3
#property indicator_minimum -1.3
#property indicator_level1 0.9
#property indicator_level2 -0.9
#property indicator_level3 0.7
#property indicator_level4 -0.7
#property indicator_levelcolor Black
#property indicator_levelstyle 0
#property indicator_buffers 6
#property indicator_color1 PaleGreen
#property indicator_color2 LightSalmon
#property indicator_color3 Crimson
#property indicator_color4 MediumVioletRed
#property indicator_color5 BlueViolet
#property indicator_color6 Blue
/********************************************************************/
//---- Snake
extern int SnakeRange =3;
extern int FilterPeriod =21;
extern double MartFiltr =2;
extern int PriceConst =0; // 0 - Close
// 1 - Open
// 2 - High
// 3 - Low
// 4 - (H+L)/2
// 5 - (H+L+C)/3
// 6 - (H+L+2*C)/4
extern bool HardCalc =false;
/********************************************************************/
double SRC1[];
double SRC2[];
double SRC3[];
double SRC4[];
double SMUp[];
double SMDn[];
double SM00[];
/********************************************************************/
int rangeN=14,Maxrange=30,p1,p2,p3,p4,q;
bool First=true;
/********************************************************************/
void deinit() { return; }
/********************************************************************/
void init() { string str,str2; int n=Period(); IndicatorBuffers(7);
SetIndexBuffer(0,SMUp); SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2);
SetIndexBuffer(1,SMDn); SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2);
SetIndexBuffer(2,SRC1); SetIndexStyle(2,DRAW_LINE,EMPTY,2);
SetIndexBuffer(3,SRC2); SetIndexStyle(3,DRAW_LINE,EMPTY,3);
SetIndexBuffer(4,SRC3); SetIndexStyle(4,DRAW_LINE,EMPTY,2);
SetIndexBuffer(5,SRC4); SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(6,SM00); SetIndexStyle(6,DRAW_NONE);
SetIndexEmptyValue(0,0.0); SetIndexEmptyValue(1,0.0);
switch(n) {
case 1: str="M15,M30,H1"; str2="M15"; break;
case 5: str="M15,M30,H1"; str2="M15"; break;
case 15: str="M15,M30,H1,H4"; str2="M30"; break;
case 30: str="M30,H1,H4"; str2="H1"; break;
case 60: str="H1,H4"; str2="H4"; break;
case 240: str="H4,D1"; str2="D1"; break; }
IndicatorShortName("MultiSSRC("+str+") & SMood("+str2+") "); return; }
/********************************************************************/
void start() { int counted_bars=IndicatorCounted();
int n,n1,n2,n3,n4,limit; double sm;
if(Period()>240) { Alert("Period()>H4 - error!"); return; }
if(counted_bars<0) return(-1);
if(First==true) { n=Period(); switch(n) {
case 1: p1=15; p2=30; p3=60; p4=240; q=480; break;
case 5: p1=15; p2=30; p3=60; p4=240; q=96; break;
case 15: p1=15; p2=30; p3=60; p4=240; q=32; break;
case 30: p1=30; p2=60; p3=240; p4=0; q=16; break;
case 60: p1=60; p2=240; p3=0; p4=0; q=8; break;
case 240: p1=240; p2=1440; p3=0; p4=0; q=12; break; }
limit=Bars-(rangeN+FilterPeriod+SnakeRange+4);
for(n=limit;n>=0;n--) {
n1=iBarShift(Symbol(),p1,Time[n]);
SRC1[n]=iCustom(NULL,p1,"SSRC",
SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,n1);
if(p2>0) {
n2=iBarShift(Symbol(),p2,Time[n]);
SM00[n]=iCustom(NULL,p2,"Snake",
SnakeRange,FilterPeriod,MartFiltr,0,HardCalc,4,n2);
if(SM00[n]>0.9 || SM00[n]<-0.9) {
if(SM00[n]>0.9) { SMUp[n]=SM00[n]; SMDn[n]=0; }
if(SM00[n]<-0.9) { SMUp[n]=0; SMDn[n]=SM00[n]; } }
else {
if(SM00[n]!=SM00[n+1]) {
if(SM00[n]>SM00[n+p2/p1]) { SMUp[n]=SM00[n]; SMDn[n]=0; }
if(SM00[n]<SM00[n+p2/p1]) { SMUp[n]=0; SMDn[n]=SM00[n]; } }
else { SMUp[n]=SMUp[n+1]; SMDn[n]=SMDn[n+1]; }
}
SRC2[n]=iCustom(NULL,p2,"SSRC",
SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,n2);
}
if(p3>0) { n3=iBarShift(Symbol(),p3,Time[n]);
SRC3[n]=iCustom(NULL,p3,"SSRC",
SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,n3); }
if(p4>0) { n4=iBarShift(Symbol(),p4,Time[n]);
SRC4[n]=iCustom(NULL,p4,"SSRC",
SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,n4); }
} First=false; }
else { limit=Bars-counted_bars+q+1;
for(n=limit;n>=0;n--) {
n1=iBarShift(Symbol(),p1,Time[n]);
SRC1[n]=iCustom(NULL,p1,"SSRC",
SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,n1);
if(p2>0) { n2=iBarShift(Symbol(),p2,Time[n]);
SM00[n]=iCustom(NULL,p2,"Snake",
SnakeRange,FilterPeriod,MartFiltr,PriceConst,HardCalc,4,n2);
if(SM00[n]>0.9 || SM00[n]<-0.9) {
if(SM00[n]>0.9) { SMUp[n]=SM00[n]; SMDn[n]=0; }
if(SM00[n]<-0.9) { SMUp[n]=0; SMDn[n]=SM00[n]; } }
else {
if(SM00[n]!=SM00[n+1]) {
if(SM00[n]>SM00[n+p2/p1]) { SMUp[n]=SM00[n]; SMDn[n]=0; }
if(SM00[n]<SM00[n+p2/p1]) { SMUp[n]=0; SMDn[n]=SM00[n]; } }
else { SMUp[n]=SMUp[n+1]; SMDn[n]=SMDn[n+1]; }
}
SRC2[n]=iCustom(NULL,p2,"SSRC",
SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,n2); }
if(p3>0) { n3=iBarShift(Symbol(),p3,Time[n]);
SRC3[n]=iCustom(NULL,p3,"SSRC",
SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,n3); }
if(p4>0) { n4=iBarShift(Symbol(),p4,Time[n]);
SRC4[n]=iCustom(NULL,p4,"SSRC",
SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,n4); }
} } return; }
/********************************************************************/
Comments