subway
Download scriptThis tool is designed to provide traders with a visual framework for identifying potential price targets and support levels based on moving averages. It functions by projecting specific numerical offsets from a primary trend line, helping to map out the "geometry" of the market relative to current momentum.
Core Logic and Mechanism
The script operates using three primary components:
1. Trend Identification (Moving Averages) The indicator begins by calculating two Exponential Moving Averages (EMAs). These act as the foundation of the tool, smoothing out price fluctuations to reveal the underlying trend.
- EMA_1: Serves as a secondary reference point for the current price movement.
- EMA_2: Acts as the "anchor" or the primary baseline from which all other levels are measured.
2. Multi-Model Projection System The unique feature of this script is its ability to switch between four different "Models." Each model uses a specific set of mathematical constants (inspired by Fibonacci sequences) to project price levels both above and below the anchor line (EMA_2).
Depending on which model you select in the settings, the tool generates seven distinct price levels:
- Model 1: Uses smaller increments (89, 144, 233) for tighter price action analysis.
- Model 2: Uses medium increments (144, 233, 377).
- Model 3: Uses larger increments (233, 377, 610) for broader market trends.
- Model 4: Uses the widest increments (377, 610, 987) for significant long-term movements.
Each model calculates three levels above the baseline and three levels below it simultaneously, creating a symmetrical "subway map" of potential price zones.
3. Automatic Currency Scaling To ensure accuracy across different types of assets (such as standard Forex pairs vs. JPY pairs), the script includes an automatic detection system. It identifies the currency type and adjusts the calculation units automatically so that the distance between the levels remains proportional regardless of the asset being traded.
User Experience
As the price moves, the indicator dynamically updates these lines on your chart in real-time. Additionally, it provides a text summary on the screen that lists the exact numerical values of all active levels (EMA_1, EMA_2, and all L+ and L- projections), allowing for precise entry and exit planning based on the current market state.
//+------------------------------------------------------------------+
//| Subway.mq4 |
//| Yuriy Tokman (YTG) |
//| http://ytg.com.ua/ |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman (YTG)"
#property link "http://ytg.com.ua/"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Green
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Red
#property indicator_color5 Red
#property indicator_color6 Red
#property indicator_color7 Red
#property indicator_color8 Red
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
enum LM
{
Model_1=1,
Model_2=2,
Model_3=3,
Model_4=4,
};
input LM Level_Model=1;
extern int MA_1=24;
extern int MA_2=28;
double E0[];
double E1[];
double E2[];
double E3[];
double E4[];
double E5[];
double E6[];
double E7[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,E0);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,E1);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,E2);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,E3);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,E4);
SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(5,E5);
SetIndexStyle(6,DRAW_LINE);
SetIndexBuffer(6,E6);
SetIndexStyle(7,DRAW_LINE);
SetIndexBuffer(7,E7);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
int limit=rates_total-prev_calculated;
if(prev_calculated==0)limit--;
else limit++;
double hi=0,lo=0,ce=0;
for(int i=0; i<limit && !IsStopped(); i++)
{
//----
E0[i]=iMA(NULL,0,MA_1,0,MODE_EMA,PRICE_CLOSE,i);
E1[i]=iMA(NULL,0,MA_2,0,MODE_EMA,PRICE_CLOSE,i);
//Model #1 89,144,233
if(Level_Model==1)
{
E2[i]=E1[i]+89*GetPoint();
E3[i]=E1[i]+144*GetPoint();
E4[i]=E1[i]+233*GetPoint();
E5[i]=E1[i]-89*GetPoint();
E6[i]=E1[i]-144*GetPoint();
E7[i]=E1[i]-233*GetPoint();
}
//Model #2 144,233,377
if(Level_Model==2)
{
E2[i]=E1[i]+144*GetPoint();
E3[i]=E1[i]+233*GetPoint();
E4[i]=E1[i]+377*GetPoint();
E5[i]=E1[i]-144*GetPoint();
E6[i]=E1[i]-233*GetPoint();
E7[i]=E1[i]-377*GetPoint();
}
//Model #3 233,377,610
if(Level_Model==3)
{
E2[i]=E1[i]+233*GetPoint();
E3[i]=E1[i]+377*GetPoint();
E4[i]=E1[i]+610*GetPoint();
E5[i]=E1[i]-233*GetPoint();
E6[i]=E1[i]-377*GetPoint();
E7[i]=E1[i]-610*GetPoint();
}
//Model #4 377,610,987
if(Level_Model==4)
{
E2[i]=E1[i]+377*GetPoint();
E3[i]=E1[i]+610*GetPoint();
E4[i]=E1[i]+987*GetPoint();
E5[i]=E1[i]-377*GetPoint();
E6[i]=E1[i]-610*GetPoint();
E7[i]=E1[i]-987*GetPoint();
}
Comment("\nLevel_Model #",Level_Model,"\n\nEMA_1 - ",DoubleToStr(E0[0],Digits),"\nEMA_2 - ",DoubleToStr(E1[0],Digits),
"\n\nL+1 - ",DoubleToStr(E2[0],Digits),"\nL+2 - ",DoubleToStr(E3[0],Digits),
"\nL+3 - ",DoubleToStr(E4[0],Digits),"\n\nL-1 - ",DoubleToStr(E5[0],Digits),
"\nL-2 - ",DoubleToStr(E6[0],Digits),"\nL-3 - ",DoubleToStr(E7[0],Digits));
//----
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
double GetPoint()
{
int vres= StringFind(Symbol(),"JPY");
if(vres == -1) return(0.0001);
return(0.01);
}
//+------------------------------------------------------------------+
Comments