#_i_FD_FS_Separate_W[1]
Download scriptThis script is designed as a sophisticated technical analysis tool for the MetaTrader platform. It focuses on identifying and visualizing complex patterns in market price movements by using mathematical principles typically found in signal processing.
Core Logic and Methodology
1. Frequency Analysis (Fourier Transformation) The primary logic of this script is based on decomposing price action into various "frequencies." In simple terms, it treats a series of historical prices like a musical chord and tries to identify the individual notes that make up that sound. It does this by analyzing how much of the price movement repeats at different intervals.
2. Harmonic Decomposition The script calculates several different harmonics (mathematical components) of the market data. By breaking the price down into these components, it can distinguish between "noise" (random, small fluctuations) and meaningful underlying trends or cycles.
3. Data Processing
- Input Period: The tool looks at a specific window of time (determined by the user settings) to calculate these patterns.
- Calculation: It performs complex trigonometric calculations (Sine and Cosine) to map out how the price interacts with different cycles over that period.
- Ranking: The logic identifies the strongest components of these signals, prioritizing the ones that carry the most weight in defining the current market structure.
Visual Representation and Outputs
The script provides three distinct types of visual feedback on your chart:
- Multi-Line Mapping: It generates seven distinct lines (represented by different colors). Each line corresponds to a different harmonic component identified during the analysis. These lines allow you to see the various "layers" of price movement simultaneously.
- Dynamic Trend Lines: In addition to the background mapping, the script identifies the most significant components and projects them onto the chart as horizontal trend lines.
- Projections: These projected lines are placed in a forward-looking manner (to the right of the current price). They represent the calculated "amplitude" of the primary harmonics, providing a visual boundary of where these specific market cycles may reach based on the current mathematical profile.
Summary for the User
Instead of simply looking at past price history, this tool uses a mathematical "lens" to see the underlying cycles driving the market. By visualizing these harmonics as colored lines and projected boundaries, it helps traders identify the structure of the current trend and anticipate potential areas of interest based on cyclical behavior.
//+------------------------------------------------------------------+
//| i_FD_FS.mq4 |
//| |
//| dmfedoseev@yandex.ru |
//+------------------------------------------------------------------+
#property copyright ""
#property link "dmfedoseev@yandex.ru"
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 Red
#property indicator_color2 Orange
#property indicator_color3 Yellow
#property indicator_color4 Lime
#property indicator_color5 Blue
#property indicator_color6 DodgerBlue
#property indicator_color7 DarkViolet
//---- input parameters
extern int i_Period=240;
int LastTime;
double A[],B[],R[],RM[];
int RN[];
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,ExtMapBuffer5);
SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(5,ExtMapBuffer6);
SetIndexStyle(6,DRAW_LINE);
SetIndexBuffer(6,ExtMapBuffer7);
IndicatorShortName("FSSW");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("FSSW_Line_1");
ObjectDelete("FSSW_Line_2");
ObjectDelete("FSSW_Line_3");
ObjectDelete("FSSW_Line_4");
ObjectDelete("FSSW_Line_5");
ObjectDelete("FSSW_Line_6");
ObjectDelete("FSSW_Line_7");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
if(Time[0]!=LastTime){
LastTime=Time[0];
for(int i=0;i<Bars;i++){
ExtMapBuffer1[i]=EMPTY_VALUE;
ExtMapBuffer2[i]=EMPTY_VALUE;
ExtMapBuffer3[i]=EMPTY_VALUE;
ExtMapBuffer4[i]=EMPTY_VALUE;
ExtMapBuffer5[i]=EMPTY_VALUE;
ExtMapBuffer6[i]=EMPTY_VALUE;
ExtMapBuffer7[i]=EMPTY_VALUE;
}
//ìàêñèìîàëüíîäîïóñòèïîå êîëè÷åñòâî ãàðìîíèê
int N=i_Period;
int M=MathFloor(N/2);
ArrayResize(A,M);
ArrayResize(B,M);
ArrayResize(R,M);
for (i=0;i<M;i++){
A[i]=0;
B[i]=0;
for(int j=0;j<N;j++){
A[i]+=Price(j,"c")*MathCos(i*6.28*j/N);
B[i]+=Price(j,"c")*MathSin(i*6.28*j/N);
}
A[i]=2*A[i]/N;
B[i]=2*B[i]/N;
R[i]=MathSqrt(MathPow(A[i],2)+MathPow(B[i],2));
}
ArrayResize(RM,8);
ArrayResize(RN,8);
for(i=1;i<M;i++){
for(j=1;j<8;j++){
if(R[i]>RM[j]){
RM[j]=R[i];
RN[j]=i;
break;
}
}
}
for(i=0;i<N;i++){
ExtMapBuffer1[i]=A[1]*MathCos(1*6.28*i/(N-1))+B[1]*MathSin(1*6.28*i/(N-1));
ExtMapBuffer2[i]=A[2]*MathCos(2*6.28*i/(N-1))+B[2]*MathSin(2*6.28*i/(N-1));
ExtMapBuffer3[i]=A[3]*MathCos(3*6.28*i/(N-1))+B[3]*MathSin(3*6.28*i/(N-1));
ExtMapBuffer4[i]=A[4]*MathCos(4*6.28*i/(N-1))+B[4]*MathSin(4*6.28*i/(N-1));
ExtMapBuffer5[i]=A[5]*MathCos(5*6.28*i/(N-1))+B[5]*MathSin(5*6.28*i/(N-1));
ExtMapBuffer6[i]=A[6]*MathCos(6*6.28*i/(N-1))+B[6]*MathSin(6*6.28*i/(N-1));
ExtMapBuffer7[i]=A[7]*MathCos(7*6.28*i/(N-1))+B[7]*MathSin(7*6.28*i/(N-1));
//Alert()
}
}
int win_idx=WindowFind("FSSW");
string Name;
int t1;
double p1;
color Col;
Name="FSSW_Line_1";
t1=Time[0]+5*Period()*60;
p1=R[1];
Col=indicator_color1;
if(ObjectFind(Name)!=win_idx){
ObjectCreate(Name,OBJ_TREND,win_idx,t1,p1,t1,-p1);
}
ObjectSet(Name,OBJPROP_RAY,false);
ObjectSet(Name,OBJPROP_COLOR,Col);
ObjectSet(Name,OBJPROP_TIME1,t1);
ObjectSet(Name,OBJPROP_TIME2,t1);
ObjectSet(Name,OBJPROP_PRICE1,p1);
ObjectSet(Name,OBJPROP_PRICE2,-p1);
Name="FSSW_Line_2";
t1=Time[0]+6*Period()*60;
p1=R[2];
Col=indicator_color2;
if(ObjectFind(Name)!=win_idx){
ObjectCreate(Name,OBJ_TREND,win_idx,t1,p1,t1,-p1);
}
ObjectSet(Name,OBJPROP_RAY,false);
ObjectSet(Name,OBJPROP_COLOR,Col);
ObjectSet(Name,OBJPROP_TIME1,t1);
ObjectSet(Name,OBJPROP_TIME2,t1);
ObjectSet(Name,OBJPROP_PRICE1,p1);
ObjectSet(Name,OBJPROP_PRICE2,-p1);
Name="FSSW_Line_3";
t1=Time[0]+7*Period()*60;
p1=R[3];
Col=indicator_color3;
if(ObjectFind(Name)!=win_idx){
ObjectCreate(Name,OBJ_TREND,win_idx,t1,p1,t1,-p1);
}
ObjectSet(Name,OBJPROP_RAY,false);
ObjectSet(Name,OBJPROP_COLOR,Col);
ObjectSet(Name,OBJPROP_TIME1,t1);
ObjectSet(Name,OBJPROP_TIME2,t1);
ObjectSet(Name,OBJPROP_PRICE1,p1);
ObjectSet(Name,OBJPROP_PRICE2,-p1);
Name="FSSW_Line_4";
t1=Time[0]+8*Period()*60;
p1=R[4];
Col=indicator_color4;
if(ObjectFind(Name)!=win_idx){
ObjectCreate(Name,OBJ_TREND,win_idx,t1,p1,t1,-p1);
}
ObjectSet(Name,OBJPROP_RAY,false);
ObjectSet(Name,OBJPROP_COLOR,Col);
ObjectSet(Name,OBJPROP_TIME1,t1);
ObjectSet(Name,OBJPROP_TIME2,t1);
ObjectSet(Name,OBJPROP_PRICE1,p1);
ObjectSet(Name,OBJPROP_PRICE2,-p1);
Name="FSSW_Line_5";
t1=Time[0]+9*Period()*60;
p1=R[5];
Col=indicator_color5;
if(ObjectFind(Name)!=win_idx){
ObjectCreate(Name,OBJ_TREND,win_idx,t1,p1,t1,-p1);
}
ObjectSet(Name,OBJPROP_RAY,false);
ObjectSet(Name,OBJPROP_COLOR,Col);
ObjectSet(Name,OBJPROP_TIME1,t1);
ObjectSet(Name,OBJPROP_TIME2,t1);
ObjectSet(Name,OBJPROP_PRICE1,p1);
ObjectSet(Name,OBJPROP_PRICE2,-p1);
Name="FSSW_Line_6";
t1=Time[0]+10*Period()*60;
p1=R[6];
Col=indicator_color6;
if(ObjectFind(Name)!=win_idx){
ObjectCreate(Name,OBJ_TREND,win_idx,t1,p1,t1,-p1);
}
ObjectSet(Name,OBJPROP_RAY,false);
ObjectSet(Name,OBJPROP_COLOR,Col);
ObjectSet(Name,OBJPROP_TIME1,t1);
ObjectSet(Name,OBJPROP_TIME2,t1);
ObjectSet(Name,OBJPROP_PRICE1,p1);
ObjectSet(Name,OBJPROP_PRICE2,-p1);
Name="FSSW_Line_7";
t1=Time[0]+11*Period()*60;
p1=R[7];
Col=indicator_color7;
if(ObjectFind(Name)!=win_idx){
ObjectCreate(Name,OBJ_TREND,win_idx,t1,p1,t1,-p1);
}
ObjectSet(Name,OBJPROP_RAY,false);
ObjectSet(Name,OBJPROP_COLOR,Col);
ObjectSet(Name,OBJPROP_TIME1,t1);
ObjectSet(Name,OBJPROP_TIME2,t1);
ObjectSet(Name,OBJPROP_PRICE1,p1);
ObjectSet(Name,OBJPROP_PRICE2,-p1);
//----
return(0);
}
//+------------------------------------------------------------------+
double Price(int ii, string PT){
if(PT=="c" || PT=="C"){
return(Close[ii]);
}
}
Comments