//+------------------------------------------------------------------+ //| 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]); } }
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features: