ma_tfx_Kamikaze2
Download scriptThe Kamikaze indicator is designed to provide traders with a visual representation of market momentum by comparing short-term price trends against multiple long-term timeframes simultaneously. Instead of looking at a single chart, this tool synthesizes data from four different time horizons to help identify the overall "flow" of the market.
Core Logic and Functionality
The primary objective of this script is to determine whether the immediate price action is moving in harmony with broader trends. It achieves this through the following logical steps:
- Multi-Timeframe Analysis: The indicator automatically calculates and monitors four distinct timeframes (configured by default as 5, 15, 60, and 120 minutes). By analyzing these different intervals, the tool allows you to see how current price movements relate to both near-term fluctuations and larger institutional trends.
- Dynamic Scaling: To ensure that the data from these different timeframes can be compared accurately on a single chart, the script uses a scaling mechanism. It mathematically adjusts the "weight" of the moving averages based on the current period you are viewing. This ensures that a trend on a 5-minute chart is represented with the same relative significance as a trend on a 2-hour chart.
- Trend Comparison: The logic centers on comparing two types of moving averages:
- A very fast, short-term average (the "Fast" indicator).
- A set of scaled, longer-term averages (the "Slow" indicators) representing the different timeframes.
- Visual Signal Generation: The script evaluates the relationship between the fast price movement and the slow timeframe trends. If the fast price is above the long-term trend, it generates a specific visual signal; if it falls below, it generates an opposing signal. These signals appear as distinct markers on your chart in alternating colors (Blue and Red).
How to Interpret the Results
The indicator acts as a "consensus" tool. By looking at the four sets of signals generated:
- Trend Alignment: When multiple signals align in the same direction (e.g., all Blue), it indicates that the current price momentum is synchronized across multiple timeframes, suggesting a stronger, more stable trend.
- Divergence Detection: If the signals are mixed, it suggests that while the price might be moving in one direction on a small scale, it may be struggling against a larger trend on a bigger scale.
Essentially, this tool simplifies complex multi-timeframe analysis into a single visual display, helping you identify when the "fast" market moves are backed by the "slow" market structure.
//+------------------------------------------------------------------+
//| Kamikaze.mq4 |
//| Copyright © 2009, klentz |
//| periods are fixed: 5, 15, 30, 60 minutes |
//+------------------------------------------------------------------+
//mod
#property copyright "klentz"
#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red
#property indicator_color5 Blue
#property indicator_color6 Red
#property indicator_color7 Blue
#property indicator_color8 Red
#property indicator_minimum -0.5
#property indicator_maximum 5
extern int MA1 = 3;
extern int MA2 = 50;
extern int MAmode = 0;
extern int MAprice = PRICE_TYPICAL;
extern int TF1=5;
extern int TF2=15;
extern int TF3=60;
extern int TF4=120;
double buffer1[], buffer2[], buffer3[], buffer4[], buffer5[], buffer6[], buffer7[], buffer8[];
int init()
{
for (int i=0; i<8; i++)
{
SetIndexStyle(i,DRAW_ARROW); SetIndexArrow(i,110); SetIndexEmptyValue(i,EMPTY_VALUE);
}
SetIndexBuffer(0,buffer1); SetIndexBuffer(1,buffer2); SetIndexBuffer(2,buffer3); SetIndexBuffer(3,buffer4);
SetIndexBuffer(4,buffer5); SetIndexBuffer(5,buffer6); SetIndexBuffer(6,buffer7); SetIndexBuffer(7,buffer8);
return(0);
}
int start()
{
int limit;
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
limit = Bars - counted_bars;
for(int i = 0; i < limit; i++)
{
if (TF1==0)TF1=Period();
if (TF2==0)TF2=Period();
if (TF3==0)TF3=Period();
if (TF4==0)TF4=Period();
int SMAscale1= MathCeil (MA2*TF1/Period()); if (SMAscale1<=MA1)SMAscale1=MA1+1;
int SMAscale2= MathCeil (MA2*TF2/Period()); if (SMAscale2<=MA1)SMAscale2=MA1+1;
int SMAscale3= MathCeil (MA2*TF3/Period()); if (SMAscale3<=MA1)SMAscale3=MA1+1;
int SMAscale4= MathCeil (MA2*TF4/Period()); if (SMAscale4<=MA1)SMAscale4=MA1+1;
double sma1 = iMA(NULL, 0, MA1 , 0, MAmode, MAprice, i);
double sma21 = iMA(NULL, 0, SMAscale1 , 0, MAmode, MAprice, i);
double sma22 = iMA(NULL, 0, SMAscale2 , 0, MAmode, MAprice, i);
double sma23 = iMA(NULL, 0, SMAscale3 , 0, MAmode, MAprice, i);
double sma24 = iMA(NULL, 0, SMAscale4 , 0, MAmode, MAprice, i);
buffer1[i]=EMPTY_VALUE; buffer2[i]=EMPTY_VALUE; buffer3[i]=EMPTY_VALUE; buffer4[i]=EMPTY_VALUE;
buffer5[i]=EMPTY_VALUE; buffer6[i]=EMPTY_VALUE; buffer7[i]=EMPTY_VALUE; buffer8[i]=EMPTY_VALUE;
if (sma1-sma21 > 0) buffer1[i] = 4; else buffer2[i] = 4;
if (sma1-sma22 > 0) buffer3[i] = 3; else buffer4[i] = 3;
if (sma1-sma23 > 0) buffer5[i] = 2; else buffer6[i] = 2;
if (sma1-sma24 > 0) buffer7[i] = 1; else buffer8[i] = 1;
string name1= MA2+","+SMAscale1;
string name2= MA2+","+SMAscale2;
string name3= MA2+","+SMAscale3;
string name4= MA2+","+SMAscale4;
SetIndexLabel(0,name1);
SetIndexLabel(2,name2);
SetIndexLabel(4,name3);
SetIndexLabel(6,name4);
IndicatorShortName("ma1 "+MA1+", ma2 "+MA2+" ");
}
return(0);
}
Comments