#property copyright "" #property link "" #property indicator_separate_window #property indicator_buffers 8 #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 #property indicator_color8 DimGray //---- input parameters extern int iPeriod=240; extern int iStartFrom=1; extern string AddToObjName="1"; extern color HandlerColor=Gray; extern color TextColor=Black; string ObjNPref="Spectrometr"; string ShortName; int LastTime; double A[],B[],R[],F[]; //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; double ExtMapBuffer5[]; double ExtMapBuffer6[]; double ExtMapBuffer7[]; double ExtMapBuffer8[]; int LastLeftBar; int LastRightBar; int LastLeftTime; int LastRightTime; int LastStartFrom; int LastiStartFrom; int LastiPeriod; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init(){ ShortName=ObjNPref+"_"+AddToObjName; ObjNPref=ObjNPref+"_"+AddToObjName+"_"; IndicatorShortName(ShortName); SetIndexStyle(0,DRAW_LINE,DRAW_LINE,2); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_LINE,DRAW_LINE,2); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(2,DRAW_LINE,DRAW_LINE,2); SetIndexBuffer(2,ExtMapBuffer3); SetIndexStyle(3,DRAW_LINE,DRAW_LINE,2); SetIndexBuffer(3,ExtMapBuffer4); SetIndexStyle(4,DRAW_LINE,DRAW_LINE,2); SetIndexBuffer(4,ExtMapBuffer5); SetIndexStyle(5,DRAW_LINE,DRAW_LINE,2); SetIndexBuffer(5,ExtMapBuffer6); SetIndexStyle(6,DRAW_LINE,DRAW_LINE,2); SetIndexBuffer(6,ExtMapBuffer7); SetIndexStyle(7,DRAW_LINE,DRAW_LINE,2); SetIndexBuffer(7,ExtMapBuffer8); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- fObjDeleteByPrefix(ObjNPref); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start(){ string ObjName=ObjNPref+"Нулевая линия"; if(ObjectFind(ObjName)!=WindowFind(ShortName)){ LastStartFrom=iStartFrom;// LastLeftBar=iStartFrom+iPeriod-1; LastRightBar=iStartFrom; LastLeftTime=Time[LastLeftBar]; LastRightTime=Time[LastRightBar]; fObjTrendLine(ObjName,LastLeftTime,0,LastRightTime,0,false,HandlerColor,3,WindowFind(ShortName),0,true); } int NowLeftTime=ObjectGet(ObjName,OBJPROP_TIME1); int NowRightTime=ObjectGet(ObjName,OBJPROP_TIME2); if(NowRightTime>Time[1])NowRightTime=Time[1]; int NowLeftBar=iBarShift(NULL,0,NowLeftTime,false); int NowRightBar=iBarShift(NULL,0,NowRightTime,false); iPeriod=NowLeftBar-NowRightBar+1; int LastStartFromTime=iBarShift(NULL,0,LastRightTime,false); iStartFrom=(NowRightBar-LastStartFromTime)+LastStartFrom; LastStartFrom=iStartFrom; LastLeftBar=iStartFrom+iPeriod-1; LastRightBar=iStartFrom; LastLeftTime=Time[LastLeftBar]; LastRightTime=Time[LastRightBar]; fObjTrendLine(ObjName,LastLeftTime,0,LastRightTime,0,false,HandlerColor,3,WindowFind(ShortName),0,true); ObjName=ObjNPref+"iPeriod"; fObjLabel(ObjName,80,5,"Period: "+iPeriod,3,TextColor,8,WindowFind(ShortName),"Arial Black",false); ObjName=ObjNPref+"iStartFrom"; fObjLabel(ObjName,10,5,"StartFrom: "+iStartFrom,3,TextColor,8,WindowFind(ShortName),"Arial Black",false); //===================================================================================================== static int LastBars=0; if(iStartFrom==LastiStartFrom && iPeriod==LastiPeriod)if(Bars0){ return(MathArctan(1)*2); } else{ if(aS<0){ return(MathArctan(1)*6); } } } else{ if(aS>0){ if(aC>0){ return(MathArctan(aS/aC)); } else{ return(MathArctan(aS/aC)+MathArctan(1)*4); } } else{ if(aC>0){ return(MathArctan(aS/aC)+MathArctan(1)*8); } else{ return(MathArctan(aS/aC)+MathArctan(1)*4); } } } } void fObjDeleteByPrefix(string aPrefix){ for(int i=ObjectsTotal()-1;i>=0;i--){ if(StringFind(ObjectName(i),aPrefix,0)==0){ ObjectDelete(ObjectName(i)); } } }