Вы упускаете торговые возможности:
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Регистрация
Вход
Вы принимаете политику сайта и условия использования
Если у вас нет учетной записи, зарегистрируйтесь
//+------------------------------------------------------------------+ //| i_P_and_F.mq4 | //| | //| | //+------------------------------------------------------------------+ #property copyright "RealJin" #property link "much-love@yandex.ru" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 RoyalBlue //#property indicator_color3 Yellow //---- input parameters extern int Box=5; extern int Reverse_Boxes=3; //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; //double ExtMapBuffer3[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE,0,2); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_LINE,0,2); SetIndexBuffer(1,ExtMapBuffer2); //SetIndexStyle(2,DRAW_ARROW); //SetIndexArrow(2,159); //SetIndexBuffer(2,ExtMapBuffer3); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //---- static double Start_Price; static int Trend; static double End_Point; int limit; int counted_bars=IndicatorCounted(); // определим количество просчитаных баров у индикатора if(counted_bars>0){ counted_bars--; } limit=Bars-counted_bars; // определяем границу до которой рассчитываем значения индикатора for(int i=limit-1;i>=0;i--){ if(Trend==0){ if(Start_Price==0){ Start_Price=Open[i]; } if(High[i]>=Start_Price+Box*Point && Low[i]>Start_Price+Box*Point){ Trend=1; End_Point=Start_Price+Box*Point*MathFloor((High[i]-Start_Price)/(Box*Point)); } if(Low[i]<=Start_Price+Box*Point && High[i]<Start_Price+Box*Point){ Trend=2; End_Point=Start_Price-Box*Point*MathFloor((Start_Price-Low[i])/(Box*Point)); } ExtMapBuffer1[i]=End_Point; } if(Trend==1){ //есть ли разворот if(Low[i]<=End_Point-Reverse_Boxes*Box*Point){ Trend=2; Start_Price=End_Point; End_Point=Start_Price-Box*Point*MathFloor((Start_Price-Low[i])/(Box*Point)); } if(High[i]>=End_Point+Box*Point){ End_Point=Start_Price+Box*Point*MathFloor((High[i]-Start_Price)/(Box*Point)); } ExtMapBuffer1[i]=End_Point; continue; } if(Trend==2){ //есть ли разворот if(High[i]>=End_Point+Reverse_Boxes*Box*Point){ Trend=1; Start_Price=End_Point; End_Point=Start_Price+Box*Point*MathFloor((High[i]-Start_Price)/(Box*Point)); } if(Low[i]<=End_Point-Box*Point){ End_Point=Start_Price-Box*Point*MathFloor((Start_Price-Low[i])/(Box*Point)); } ExtMapBuffer1[i]=End_Point; continue; } } static int Trend2; for(i=limit-2;i>=0;i--){ ExtMapBuffer2[i]=EMPTY_VALUE; if(ExtMapBuffer1[i]>ExtMapBuffer1[i+1]){ Trend2=1; } if(ExtMapBuffer1[i]<ExtMapBuffer1[i+1] || Trend2==2){ Trend2=2; ExtMapBuffer2[i]=ExtMapBuffer1[i]; ExtMapBuffer2[i+1]=ExtMapBuffer1[i+1]; } } /* for(i=Bars-2;i>=0;i--){ ExtMapBuffer3[i]=EMPTY_VALUE; if(ExtMapBuffer1[i]!=ExtMapBuffer1[i+1]){ ExtMapBuffer3[i]=ExtMapBuffer1[i]; } } */ //---- return(0); } //+------------------------------------------------------------------+Спасибо большое за поддержку Realjin. Погоняю немного индикатор.
Пожалуй можно как-то и одноцветные складывать.
//+------------------------------------------------------------------+ //| i_P_and_F.mq4 | //| | //| | //+------------------------------------------------------------------+ #property copyright "RealJin" #property link "much-love@yandex.ru" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 RoyalBlue //#property indicator_color3 Yellow //---- input parameters extern int Box=5; extern int Reverse_Boxes=3; double Start_Price; int Trend; double End_Point; //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; //double ExtMapBuffer3[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE,0,2); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_LINE,0,2); SetIndexBuffer(1,ExtMapBuffer2); //SetIndexStyle(2,DRAW_ARROW); //SetIndexArrow(2,159); //SetIndexBuffer(2,ExtMapBuffer3); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //---- Start_Price=0; Trend=0; End_Point=0; for(int i=Bars-1;i>=0;i--){ if(Trend==0){ if(Start_Price==0){ Start_Price=Open[i]; } if(High[i]>=Start_Price+Box*Point && Low[i]>Start_Price+Box*Point){ Trend=1; End_Point=Start_Price+Box*Point*MathFloor((High[i]-Start_Price)/(Box*Point)); } if(Low[i]<=Start_Price+Box*Point && High[i]<Start_Price+Box*Point){ Trend=2; End_Point=Start_Price-Box*Point*MathFloor((Start_Price-Low[i])/(Box*Point)); } ExtMapBuffer1[i]=End_Point; } if(Trend==1){ //есть ли разворот if(Low[i]<=End_Point-Reverse_Boxes*Box*Point){ Trend=2; Start_Price=End_Point; End_Point=Start_Price-Box*Point*MathFloor((Start_Price-Low[i])/(Box*Point)); } if(High[i]>=End_Point+Box*Point){ End_Point=Start_Price+Box*Point*MathFloor((High[i]-Start_Price)/(Box*Point)); } ExtMapBuffer1[i]=End_Point; continue; } if(Trend==2){ //есть ли разворот if(High[i]>=End_Point+Reverse_Boxes*Box*Point){ Trend=1; Start_Price=End_Point; End_Point=Start_Price+Box*Point*MathFloor((High[i]-Start_Price)/(Box*Point)); } if(Low[i]<=End_Point-Box*Point){ End_Point=Start_Price-Box*Point*MathFloor((Start_Price-Low[i])/(Box*Point)); } ExtMapBuffer1[i]=End_Point; continue; } } static int Trend2; for(i=Bars-1;i>=0;i--){ ExtMapBuffer2[i]=EMPTY_VALUE; if(ExtMapBuffer1[i]>ExtMapBuffer1[i+1]){ Trend2=1; } if(ExtMapBuffer1[i]<ExtMapBuffer1[i+1] || Trend2==2){ Trend2=2; ExtMapBuffer2[i]=ExtMapBuffer1[i]; ExtMapBuffer2[i+1]=ExtMapBuffer1[i+1]; } } /* for(i=Bars-2;i>=0;i--){ ExtMapBuffer3[i]=EMPTY_VALUE; if(ExtMapBuffer1[i]!=ExtMapBuffer1[i+1]){ ExtMapBuffer3[i]=ExtMapBuffer1[i]; } } */ //---- return(0); } //+------------------------------------------------------------------+Если надо, чтобы строилось по Close, то везде, где есть High или Low, заменить их на Close, да и Open тоже.