Скачать MetaTrader 5
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий
В сервисе Фриланс участвуют тысячи разработчиков. Присоединяйся!
Forex Trader
114375
Forex Trader 2005.11.09 08:08 
Ищу индикатор, который рисует кривые линии PivotPoints по дням. Например нижепредставленный индикатор может рисовать только прямые линии, расчитанные по заданному дню через ВЕСЬ график. То есть для других дней эта информация естественно некорректна и требуется во входных переменных ручками указывать смещение расчётной свечки, чтобы посмотреть Pivot Points для другого дня (И КАК ЭТО УЖЕ ДОСТАЛО!!!). Хотелось бы чтобы на графике над каждым днём отображались правильные линии PivotPoints, рассчитанные по предыдущему дню. А также чтобы при изменении временного периода на графике (например на M15, H1) эти линии правильно соответствовали дню, который они представляют.

Заранее ОГРОМНЕЙЩЕЕ СПАСИБО тому, кто располагает таким индикатором или сможет сделать его из представленного ниже индикатора. Ведь в других торговых платформах данный индикатор входит просто в стандартный комплект и на сайтах можно частенько встретить картинки с ломанными линиями Pivot Points по дням!!!

//+------------------------------------------------------------------+
//|                                                          PV4.mq4 |
//|                                                        Jim Arner |
//|                                            Modified by Bill Sica |
//+------------------------------------------------------------------+

#property indicator_chart_window
//---- input parameters
extern int day=1; //1 - вчерашний день, 2 - позавчерашний день
extern string Diapazon = "D1"; // D1 - день, H4 - 4 часа, H1 - 1 час
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
  {
//---- indicators

//---- indicators

   

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double yesterday_high;
   double yesterday_low;
   double yesterday_close;
   double array_price[][6];
   double P,S1,R1,S2,R2,S3,R3,M0,M1,M2,M3,M4,M5;

//---- TODO: add your code here

ArrayInitialize(array_price,0);
if (Diapazon == "W1") ArrayCopyRates(array_price,(Symbol()), PERIOD_W1);
if (Diapazon == "D1") ArrayCopyRates(array_price,(Symbol()), PERIOD_D1);
if (Diapazon == "H4") ArrayCopyRates(array_price,(Symbol()), PERIOD_H4);
if (Diapazon == "H1") ArrayCopyRates(array_price,(Symbol()), PERIOD_H1);

yesterday_high = array_price[day][3];
yesterday_low = array_price[day][2];
yesterday_close = array_price[day][4];

P = ((yesterday_high + yesterday_low + yesterday_close)/3);

R1 = (2*P)-yesterday_low;
S1 = (2*P)-yesterday_high;

R2 = (P-S1)+R1;
S2 = P-(R1-S1);

	R3 = (2*P)+(yesterday_high-(2*yesterday_low));
	
//R3 = R2+(P-S1);
   S3 = (2*P)-((2* yesterday_high)-yesterday_low);
   
//S3 = S2-(R1-S1);

M0 = (S3+S2)/2;
M1 = (S2+S1)/2;
M2 = (S1+P)/2;
M3 = (P+R1)/2;
M4 = (R1+R2)/2;
M5 = (R2+R3)/2;

Comment("\nR3=",R3,"\nM5=",M5,"\nR2=",R2,"\nM4=",M4,"\nR1=",R1,"\nM3=",M3,"\nP=",P,"\nM2=",M2,"\nS1=",S1,"\nM1=",M1,"\nS2=",S2,"\nM0=",M0,"\nS3=",S3);

ObjectDelete("P_Line");
ObjectDelete("M0_Line");
ObjectDelete("M1_Line");
ObjectDelete("M2_Line");
ObjectDelete("M3_Line");
ObjectDelete("M4_Line");
ObjectDelete("M5_Line");
ObjectDelete("R2_Line");
ObjectDelete("S2_Line");

ObjectCreate("P_Line", OBJ_HLINE,0, CurTime(),P);
ObjectSet("P_Line",OBJPROP_COLOR,Yellow);
ObjectSet("P_Line",OBJPROP_STYLE,STYLE_SOLID);

ObjectCreate("M0_Line", OBJ_HLINE,0, CurTime(),M0);
ObjectSet("M0_Line",OBJPROP_COLOR,Lime);
ObjectSet("M0_Line",OBJPROP_STYLE,STYLE_SOLID);

ObjectCreate("M1_Line", OBJ_HLINE,0, CurTime(),M1);
ObjectSet("M1_Line",OBJPROP_COLOR,Lime);
ObjectSet("M1_Line",OBJPROP_STYLE,STYLE_SOLID);

ObjectCreate("M2_Line", OBJ_HLINE,0, CurTime(),M2);
ObjectSet("M2_Line",OBJPROP_COLOR,Lime);
ObjectSet("M2_Line",OBJPROP_STYLE,STYLE_SOLID);


ObjectCreate("M3_Line", OBJ_HLINE,0, CurTime(),M3);
ObjectSet("M3_Line",OBJPROP_COLOR,Red);
ObjectSet("M3_Line",OBJPROP_STYLE,STYLE_SOLID);


ObjectCreate("M4_Line", OBJ_HLINE,0, CurTime(),M4);
ObjectSet("M4_Line",OBJPROP_COLOR,Red);
ObjectSet("M4_Line",OBJPROP_STYLE,STYLE_SOLID);

ObjectCreate("M5_Line", OBJ_HLINE,0, CurTime(),M5);
ObjectSet("M5_Line",OBJPROP_COLOR,Red);
ObjectSet("M5_Line",OBJPROP_STYLE,STYLE_SOLID);

ObjectCreate("R2_Line", OBJ_HLINE,0, CurTime(),R2);
ObjectSet("R2_Line",OBJPROP_COLOR,Red);
ObjectSet("R2_Line",OBJPROP_STYLE,STYLE_DOT);

ObjectCreate("S2_Line", OBJ_HLINE,0, CurTime(),S2);
ObjectSet("S2_Line",OBJPROP_COLOR,Lime);
ObjectSet("S2_Line",OBJPROP_STYLE,STYLE_DOT);


ObjectsRedraw();

   return(0);
  }
//+------------------------------------------------------------------
Forex Trader
114375
Forex Trader 2005.11.09 11:03  
посмотрите, как сделан нижеприведённый индикатор.
//+------------------------------------------------------------------+
//|                                             DaylyPivotPoints.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//|               written especially for Mohamed Talib, Seattle, USA |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int       ExtFormula=0;
extern int       ExtHowManyDays=30;
extern bool      ExtDraw=true;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
//---- clear buffers when reinitializing
   ArrayInitialize(ExtMapBuffer1,0.0);
   ArrayInitialize(ExtMapBuffer2,0.0);
//---- set labels for DataWindow
   if(ExtDraw)
     {
      if(ExtFormula==0)
        {
         SetIndexLabel(0,"Pivot");
         SetIndexLabel(1,NULL);
        }
       else
        {
         SetIndexLabel(0,"Resistance");
         SetIndexLabel(1,"Support");
        }
     }
    else
     {
      SetIndexLabel(0,NULL);
      SetIndexLabel(1,NULL);
     }
//---- force daily data load
   iBars(NULL,PERIOD_D1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- deleting our lines
   ObjectDelete("P_Line");
   ObjectDelete("R0.5_Line");
   ObjectDelete("R1_Line");
   ObjectDelete("R1.5_Line");
   ObjectDelete("R2_Line");
   ObjectDelete("R2.5_Line");
   ObjectDelete("R3_Line");
   ObjectDelete("S0.5_Line");
   ObjectDelete("S1_Line");
   ObjectDelete("S1.5_Line");
   ObjectDelete("S2_Line");
   ObjectDelete("S2.5_Line");
   ObjectDelete("S3_Line");
//   Comment("");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int    begin_bar, first_bar, last_bar, cnt;
   double yesterday_high, yesterday_low, yesterday_close, today_open;
   double P, S, R, S05, R05, S10, R10, S15, R15, S20, R20, S25, R25, S30, R30;
//---- test parameters
   if(ExtFormula<0 || ExtFormula>3) return(-1);
   if(Period()>=PERIOD_D1)          return(-1);
//---- if daily data not loaded yet
   while(true)
     {
      if(iTime(NULL,PERIOD_D1,0)>=(Time[0]-PERIOD_D1*60)) break;
      Sleep(1000);
     }
//---- set check beginning
   if(ExtHowManyDays<1) begin_bar=iBars(NULL,PERIOD_D1)-2;
   else                 begin_bar=ExtHowManyDays-1;
//---- case of recounting current pivot only
   if(ExtDraw==false || counted_bars>0) begin_bar=0;
//----
   for(cnt=begin_bar; cnt>=0; cnt--)
     {
      yesterday_close=iClose(NULL,PERIOD_D1,cnt+1);
      today_open=iOpen(NULL,PERIOD_D1,cnt);
      yesterday_high=iHigh(NULL,PERIOD_D1,cnt+1);
      yesterday_low=iLow(NULL,PERIOD_D1,cnt+1);
      P = (yesterday_high + yesterday_low + yesterday_close + today_open) / 4;
      switch(ExtFormula)
        {
         case 1 :
            R = P + P - yesterday_low;
            S = P + P - yesterday_high;
            break;
         case 2 :
            R = P + yesterday_high - yesterday_low;
            S = P - yesterday_high + yesterday_low;
            break;
         case 3 :
            R = P + P - yesterday_low - yesterday_low + yesterday_high;
            S = P + P - yesterday_high - yesterday_high + yesterday_low;		
        }
      if(ExtDraw==true)
        {
         first_bar=iBarShift(NULL,0,iTime(NULL,PERIOD_D1,cnt))-2;
         if(cnt>0) last_bar=iBarShift(NULL,0,iTime(NULL,PERIOD_D1,cnt-1))-1;
         else last_bar=0;
         while(first_bar>=last_bar)
           {
            if(first_bar==last_bar && last_bar>0) break;
            if(ExtFormula==0) ExtMapBuffer1[first_bar]=P;
            else
              {
               ExtMapBuffer1[first_bar]=R;
               ExtMapBuffer2[first_bar]=S;
              }
             first_bar--;
           }
        }
     }
   P = (yesterday_high + yesterday_low + yesterday_close)/3;

   R10 = (2*P)-yesterday_low;
   S10 = (2*P)-yesterday_high;

   R05 = (P+R10)/2;
   S05 = (P+S10)/2;

   R20 = P+(yesterday_high-yesterday_low);
   S20 = P-(yesterday_high-yesterday_low);

   R15 = (R10+R20)/2;
   S15 = (S10+S20)/2;

   R30 = 2*P+(yesterday_high-2*yesterday_low);
   S30 = 2*P-(2*yesterday_high-yesterday_low);		

   R25 = (R20+R30)/2;
   S25 = (S20+S30)/2;

// Comment("High= ",yesterday_high,"\nLow= ",yesterday_low,"\nClose= ",yesterday_close,"\n      R3.0= ",R30,"\n     R2.5= ",R25,"\n    R2.0= ",R20,"\n   R1.5= ",R15,"\n  R1.0= ",R10,"\n R0.5= ",R05,"\nPivot= ",P,"\n S0.5= ",S05,"\n  S1.0= ",S10,"\n   S1.5= ",S15,"\n    S2.0= ",S20,"\n     S2.5= ",S25,"\n      S3.0= ",S30);
	
   ObjectCreate("P_Line", OBJ_HLINE, 0, 0, P);
   ObjectSet("P_Line", OBJPROP_COLOR, Yellow);
   ObjectSet("P_Line", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSetText("P_Line","P");

   ObjectCreate("R0.5_Line", OBJ_HLINE, 0, 0, R05);
   ObjectSet("R0.5_Line", OBJPROP_COLOR, GreenYellow);
   ObjectSet("R0.5_Line", OBJPROP_STYLE, STYLE_DOT);
   ObjectSetText("R0.5_Line","R0.5 "+DoubleToStr(R05,Digits));

   ObjectCreate("R1_Line", OBJ_HLINE, 0, 0, R10);
   ObjectSet("R1_Line", OBJPROP_COLOR, YellowGreen);
   ObjectSet("R1_Line", OBJPROP_STYLE, STYLE_DOT);
   ObjectSetText("R1_Line","R1.0 "+DoubleToStr(R10,Digits));

   ObjectCreate("R1.5_Line", OBJ_HLINE, 0, 0, R15);
   ObjectSet("R1.5_Line", OBJPROP_COLOR, GreenYellow);
   ObjectSet("R1.5_Line", OBJPROP_STYLE, STYLE_DOT);
   ObjectSetText("R1.5_Line","R1.5 "+DoubleToStr(R15,Digits));

   ObjectCreate("R2_Line", OBJ_HLINE, 0, 0, R20);
   ObjectSet("R2_Line", OBJPROP_COLOR, YellowGreen);
   ObjectSet("R2_Line", OBJPROP_STYLE, STYLE_DOT);
   ObjectSetText("R2_Line","R2.0 "+DoubleToStr(R20,Digits));

   ObjectCreate("R2.5_Line", OBJ_HLINE, 0, 0, R25);
   ObjectSet("R2.5_Line", OBJPROP_COLOR, GreenYellow);
   ObjectSet("R2.5_Line", OBJPROP_STYLE, STYLE_DOT);
   ObjectSetText("R2.5_Line","R2.5 "+DoubleToStr(R25,Digits));

   ObjectCreate("R3_Line", OBJ_HLINE, 0, 0, R30);
   ObjectSet("R3_Line", OBJPROP_COLOR, YellowGreen);
   ObjectSet("R3_Line", OBJPROP_STYLE, STYLE_DOT);
   ObjectSetText("R3_Line","R3.0 "+DoubleToStr(R30,Digits));

   ObjectCreate("S0.5_Line", OBJ_HLINE, 0, 0, S05);
   ObjectSet("S0.5_Line", OBJPROP_COLOR, Salmon);
   ObjectSet("S0.5_Line", OBJPROP_STYLE, STYLE_DOT);
   ObjectSetText("S0.5_Line","S0.5 "+DoubleToStr(S05,Digits));

   ObjectCreate("S1_Line", OBJ_HLINE, 0, 0, S10);
   ObjectSet("S1_Line", OBJPROP_COLOR, Salmon);
   ObjectSet("S1_Line", OBJPROP_STYLE, STYLE_DOT);
   ObjectSetText("S1_Line","S1.0 "+DoubleToStr(S10,Digits));

   ObjectCreate("S1.5_Line", OBJ_HLINE, 0, 0, S15);
   ObjectSet("S1.5_Line", OBJPROP_COLOR, Salmon);
   ObjectSet("S1.5_Line", OBJPROP_STYLE, STYLE_DOT);
   ObjectSetText("S1.5_Line","S1.5 "+DoubleToStr(S15,Digits));

   ObjectCreate("S2_Line", OBJ_HLINE, 0, 0, S20);
   ObjectSet("S2_Line", OBJPROP_COLOR, Salmon);
   ObjectSet("S2_Line", OBJPROP_STYLE, STYLE_DOT);
   ObjectSetText("S2_Line","S2.0 "+DoubleToStr(S20,Digits));

   ObjectCreate("S2.5_Line", OBJ_HLINE, 0, 0, S25);
   ObjectSet("S2.5_Line", OBJPROP_COLOR, Salmon);
   ObjectSet("S2.5_Line", OBJPROP_STYLE, STYLE_DOT);
   ObjectSetText("S2.5_Line","S2.5 "+DoubleToStr(S25,Digits));

   ObjectCreate("S3_Line", OBJ_HLINE, 0, 0, S30);
   ObjectSet("S3_Line", OBJPROP_COLOR, Salmon);
   ObjectSet("S3_Line", OBJPROP_STYLE, STYLE_DOT);
   ObjectSetText("S3_Line","S3.0 "+DoubleToStr(S30,Digits));
//---- force objects drawing
   ObjectsRedraw();
//----
   return(0);
  }
//+------------------------------------------------------------------+


только линии не ломаные, а прерывистые. чтобы их сделать ломаными, 130 строку замените на

         first_bar=iBarShift(NULL,0,iTime(NULL,PERIOD_D1,cnt))-1;
Forex Trader
114375
Forex Trader 2005.11.10 13:56  
СПАСИБО ОГРОМНОЕ за ПОМОЩЬ!!!
По приведённому образцу сделал индикатор, о котором давно мечтал! Вот выкладываю код двух индикаторов.
Первый индикатор для вывода точек R1, R2, P, S1, S2, а второй индикатор служит для вывода точек M0, M1, M2, M3, M4 и M5. Я подключаю к графику сразу оба. Необходимость деления индикатора на два была вызвана ограничением по количеству буферов.
//+------------------------------------------------------------------+
//|                                             DaylyPivotPoints.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//|               written especially for Mohamed Talib, Seattle, USA |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Lime
#property indicator_color2 Lime
#property indicator_color3 Magenta
#property indicator_color4 Magenta
#property indicator_color5 Yellow


//---- input parameters

extern int       ExtHowManyDays=-1;
extern bool      ExtDraw=true;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexEmptyValue(2,0.0);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexEmptyValue(3,0.0);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexEmptyValue(4,0.0);
      
//---- clear buffers when reinitializing
   ArrayInitialize(ExtMapBuffer1,0.0);
   ArrayInitialize(ExtMapBuffer2,0.0);
   ArrayInitialize(ExtMapBuffer3,0.0);
   ArrayInitialize(ExtMapBuffer4,0.0);
   ArrayInitialize(ExtMapBuffer5,0.0);
  

  
//---- force daily data load
   iBars(NULL,PERIOD_D1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- deleting our lines
  
//   Comment("");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int    begin_bar, first_bar, last_bar, cnt;
   double yesterday_high, yesterday_low, yesterday_close, today_open;
   double P, S1, S2, S3, R1, R2, R3, M0, M1, M2, M3, M4, M5;
//---- test parameters
  
   if(Period()>=PERIOD_D1)          return(-1);
//---- if daily data not loaded yet
   while(true)
     {
      if(iTime(NULL,PERIOD_D1,0)>=(Time[0]-PERIOD_D1*60)) break;
      Sleep(1000);
     }
//---- set check beginning
   if(ExtHowManyDays<1) begin_bar=iBars(NULL,PERIOD_D1)-2;
   else                 begin_bar=ExtHowManyDays-1;
//---- case of recounting current pivot only
   if(ExtDraw==false || counted_bars>0) begin_bar=0;
//----
   for(cnt=begin_bar; cnt>=0; cnt--)
     {
      yesterday_close=iClose(NULL,PERIOD_D1,cnt+1);
      today_open=iOpen(NULL,PERIOD_D1,cnt);
      yesterday_high=iHigh(NULL,PERIOD_D1,cnt+1);
      yesterday_low=iLow(NULL,PERIOD_D1,cnt+1);
      //P = (yesterday_high + yesterday_low + yesterday_close + today_open) / 4;
      
      P = ((yesterday_high + yesterday_low + yesterday_close)/3);
     
R1 = (2*P)-yesterday_low;
S1 = (2*P)-yesterday_high;

R2 = (P-S1)+R1;
S2 = P-(R1-S1);

	R3 = (2*P)+(yesterday_high-(2*yesterday_low));
	
//R3 = R2+(P-S1);
   S3 = (2*P)-((2* yesterday_high)-yesterday_low);
   
//S3 = S2-(R1-S1);

M0 = (S3+S2)/2;
M1 = (S2+S1)/2;
M2 = (S1+P)/2;
M3 = (P+R1)/2;
M4 = (R1+R2)/2;
M5 = (R2+R3)/2;      
         
      if(ExtDraw==true)
        {
         //first_bar=iBarShift(NULL,0,iTime(NULL,PERIOD_D1,cnt))-2;
         first_bar=iBarShift(NULL,0,iTime(NULL,PERIOD_D1,cnt));

         if(cnt>0) last_bar=iBarShift(NULL,0,iTime(NULL,PERIOD_D1,cnt-1));
         else last_bar=0;
         while(first_bar>=last_bar)
           {
            if(first_bar==last_bar && last_bar>0) break;
            
            else
              {
               ExtMapBuffer1[first_bar]=S1;
               ExtMapBuffer2[first_bar]=S2;
               ExtMapBuffer3[first_bar]=R1;
               ExtMapBuffer4[first_bar]=R2;
               ExtMapBuffer5[first_bar]=P;
              
              }
             first_bar--;
           }
        }
     }
 
  
//---- force objects drawing
   ObjectsRedraw();
//----
   return(0);
  }
//+------------------------------------------------------------------+




//+------------------------------------------------------------------+
//|                                             DaylyPivotPoints.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//|               written especially for Mohamed Talib, Seattle, USA |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Lime
#property indicator_color2 Lime
#property indicator_color3 Lime
#property indicator_color4 Magenta
#property indicator_color5 Magenta
#property indicator_color6 Magenta

//---- input parameters

extern int       ExtHowManyDays=-1;
extern bool      ExtDraw=true;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexEmptyValue(2,0.0);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexEmptyValue(3,0.0);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexEmptyValue(4,0.0);
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexEmptyValue(5,0.0);
      
//---- clear buffers when reinitializing
   ArrayInitialize(ExtMapBuffer1,0.0);
   ArrayInitialize(ExtMapBuffer2,0.0);
   ArrayInitialize(ExtMapBuffer3,0.0);
   ArrayInitialize(ExtMapBuffer4,0.0);
   ArrayInitialize(ExtMapBuffer5,0.0);
   ArrayInitialize(ExtMapBuffer6,0.0);
  

  
//---- force daily data load
   iBars(NULL,PERIOD_D1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- deleting our lines
  
//   Comment("");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int    begin_bar, first_bar, last_bar, cnt;
   double yesterday_high, yesterday_low, yesterday_close, today_open;
   double P, S1, S2, S3, R1, R2, R3, M0, M1, M2, M3, M4, M5;
//---- test parameters
  
   if(Period()>=PERIOD_D1)          return(-1);
//---- if daily data not loaded yet
   while(true)
     {
      if(iTime(NULL,PERIOD_D1,0)>=(Time[0]-PERIOD_D1*60)) break;
      Sleep(1000);
     }
//---- set check beginning
   if(ExtHowManyDays<1) begin_bar=iBars(NULL,PERIOD_D1)-2;
   else                 begin_bar=ExtHowManyDays-1;
//---- case of recounting current pivot only
   if(ExtDraw==false || counted_bars>0) begin_bar=0;
//----
   for(cnt=begin_bar; cnt>=0; cnt--)
     {
      yesterday_close=iClose(NULL,PERIOD_D1,cnt+1);
      today_open=iOpen(NULL,PERIOD_D1,cnt);
      yesterday_high=iHigh(NULL,PERIOD_D1,cnt+1);
      yesterday_low=iLow(NULL,PERIOD_D1,cnt+1);
      //P = (yesterday_high + yesterday_low + yesterday_close + today_open) / 4;
      
      P = ((yesterday_high + yesterday_low + yesterday_close)/3);
     
R1 = (2*P)-yesterday_low;
S1 = (2*P)-yesterday_high;

R2 = (P-S1)+R1;
S2 = P-(R1-S1);

	R3 = (2*P)+(yesterday_high-(2*yesterday_low));
	
//R3 = R2+(P-S1);
   S3 = (2*P)-((2* yesterday_high)-yesterday_low);
   
//S3 = S2-(R1-S1);

M0 = (S3+S2)/2;
M1 = (S2+S1)/2;
M2 = (S1+P)/2;
M3 = (P+R1)/2;
M4 = (R1+R2)/2;
M5 = (R2+R3)/2;      
         
      if(ExtDraw==true)
        {
         //first_bar=iBarShift(NULL,0,iTime(NULL,PERIOD_D1,cnt))-2;
         first_bar=iBarShift(NULL,0,iTime(NULL,PERIOD_D1,cnt));

         if(cnt>0) last_bar=iBarShift(NULL,0,iTime(NULL,PERIOD_D1,cnt-1));
         else last_bar=0;
         while(first_bar>=last_bar)
           {
            if(first_bar==last_bar && last_bar>0) break;
            
            else
              {
               ExtMapBuffer1[first_bar]=M0;
               ExtMapBuffer2[first_bar]=M1;
               ExtMapBuffer3[first_bar]=M2;
               ExtMapBuffer4[first_bar]=M3;
               ExtMapBuffer5[first_bar]=M4;
               ExtMapBuffer6[first_bar]=M5;
              }
             first_bar--;
           }
        }
     }
 
  
//---- force objects drawing
   ObjectsRedraw();
//----
   return(0);
  }
//+------------------------------------------------------------------+
Forex Trader
114375
Forex Trader 2005.11.10 18:06  
вот попроще..если нада канешна

#property copyright "pyrodex"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 LawnGreen
#property indicator_color5 Blue
#property indicator_color6 Blue
#property indicator_color7 Blue

int d;
double pivotPoint, r1, r2, r3, s1, s2, s3;
double highLine, lowLine;
double pivotLine[], r1Line[], r2Line[], r3Line[], s1Line[], s2Line[], s3Line[]; 


int init()
{

 	d = TimeDay(Time[Bars - 1]);
 	highLine = High[Bars - 1];
	lowLine = Low[Bars - 1];	
	 
	SetIndexStyle(0,DRAW_LINE, STYLE_DASH,1);
	SetIndexBuffer(0, r3Line);
	SetIndexDrawBegin(0,0);

	SetIndexStyle(1,DRAW_LINE, 0,1);
	SetIndexBuffer(1, r2Line);
	SetIndexDrawBegin(1,0);

	SetIndexStyle(2,DRAW_LINE, 0,1);
	SetIndexBuffer(2, r1Line);
	SetIndexDrawBegin(2,0);

	SetIndexStyle(3,DRAW_LINE, 0,1);
	SetIndexBuffer(3, pivotLine);
	SetIndexDrawBegin(3,0);

	SetIndexStyle(4,DRAW_LINE, 0,1);
	SetIndexBuffer(4, s1Line);
	SetIndexDrawBegin(4,0);

	SetIndexStyle(5,DRAW_LINE, 0,1);
	SetIndexBuffer(5, s2Line);
	SetIndexDrawBegin(5,0);

	SetIndexStyle(6,DRAW_LINE, STYLE_DASH,1);
	SetIndexBuffer(6, s3Line);
	SetIndexDrawBegin(6,0);

	return(0);
}



int deinit()
{
	return(0);
}


int start()
{
	int i, l;
	
	l = Bars - 1 - IndicatorCounted();
	if (l == 0) l = 1;
	for (i = l; i >= 0; i--) {
		if (TimeDay(Time[i]) != d) {
			d = TimeDay(Time[i]);
			pivotPoint = (highLine + lowLine + Close[i + 1]) / 3;
			r3 = highLine + 2 * (pivotPoint - lowLine);
			r1 = 2 * pivotPoint - lowLine;
			s1 = 2 * pivotPoint - highLine;
			s3 = lowLine - 2 * (highLine - pivotPoint);
			r2 = pivotPoint + (r1 - s1);
			s2 = pivotPoint - (r1 - s1);			
			highLine = High[i];
			lowLine = Low[i];		
		}
		
		if (Low[i]  < lowLine) lowLine = Low[i];
		if (High[i] > highLine) highLine = High[i];

		r3Line[i] = r3;
		r2Line[i] = r2;
		r1Line[i] = r1;
		pivotLine[i] = pivotPoint;
		s1Line[i] = s1;
		s2Line[i] = s2;
		s3Line[i] = s3;
	
		Comment("R3=", r3, "  R2=", r2, "  R1=", r1, "  P=", pivotPoint, "  S1=", s1, "  S2=", s2, "  S3=", s3);
	}
		
	return(0);
}
Forex Trader
114375
Forex Trader 2005.11.11 07:08  
Спасибо за ещё один пример хорошего индикатора!

Пожелание к разработчикам Метатрейдера - Очень хотелось бы, чтобы в будущих версиях дистрибутивов Метатрейдера данный индикатор входил в состав стандартных индикаторов, так как вообще не понятно как можно торговать без такого очень необходимого инструмента?
Forex Trader
114375
Forex Trader 2005.11.11 18:35  
так как вообще не понятно как можно торговать без такого очень необходимого инструмента?

Да можно вапщето ;)
Forex Trader
114375
Forex Trader 2005.11.11 18:37  
Как же вы пацаки пепелац без гравицапы выпускаете?
Forex Trader
114375
Forex Trader 2005.11.12 12:29  
[quote]
так как вообще не понятно как можно торговать без такого очень необходимого инструмента?

у каждого своя стратегия :)
/
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий