Помогите переделать Pivot

  • Автор темы Автор темы Azerus
  • Дата начала Дата начала

Azerus

Прохожий
Господа, есть стандартный Pivot:

DialyPivot.mq4 |
//| These are the main pivots used by Thomas DeMark |
//| Written by: Ice |
//| |
//+------------------------------------------------------------------+
#property copyright "2005 Free software for trader"

#property indicator_chart_window
#property indicator_buffers 7

#property indicator_color1 Blue
#property indicator_color2 Yellow
#property indicator_color3 Red
#property indicator_color4 Green
#property indicator_color5 Lime
#property indicator_color6 White
#property indicator_color7 Indigo

//---- input parameters\

datetime BT[];
double YesterdayHigh[50];
double YesterdayLow[50];
double YesterdayClose[50];
//---- buffers

double PivotArray[];
double R1Array[];
double S1Array[];
double R2Array[];
double S2Array[];
double R3Array[];
double S3Array[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
// Pivot
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,PivotArray);
IndicatorShortName("TDPivot");
SetIndexLabel(0,"Pivot");

// Resistance 1
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,R1Array);
SetIndexLabel(1,"R1");

// Support 1
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,S1Array);
SetIndexLabel(2,"R1");

// Resistance 2
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,R2Array);
SetIndexLabel(3,"R2");

// Support 2
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,S2Array);
SetIndexLabel(4,"S2");

// Resistance 3
SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(5,R3Array);
SetIndexLabel(5,"R3");

// Support 3
SetIndexStyle(6,DRAW_LINE);
SetIndexBuffer(6,S3Array);
SetIndexLabel(6,"S2");
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();

ArrayResize(BT, Bars); Print("Bars = " + Bars);
// Fill BT with bar open TIME
ArrayCopySeries(BT, MODE_TIME);
// Fill temp arrays with High, Low and Close prices per day
ArrayCopySeries(YesterdayHigh, MODE_HIGH, Symbol(), PERIOD_D1);
ArrayCopySeries(YesterdayLow, MODE_LOW, Symbol(), PERIOD_D1);
ArrayCopySeries(YesterdayClose, MODE_CLOSE, Symbol(), PERIOD_D1);

int od = 0;
int dd = 0;


double Pivot;
double R1;
double S1;
double R2;
double S2;
double R3;
double S3;
//Cycle through all the bars and fill the indicator bars with the Pivot point values
for (int i = 0; i <= Bars; i++) {
if (TimeDay(BT) != od) {
dd++;
Pivot = (YesterdayHigh[dd] + YesterdayLow[dd] + YesterdayClose[dd])/3;
R1 = (2*Pivot)-YesterdayLow[dd];
S1 = (2*Pivot)-YesterdayHigh[dd];
R2 = Pivot-S1+R1;
S2 = Pivot-R1+S1;
R3 = YesterdayHigh[dd]+2*(Pivot-YesterdayLow[dd]);
S3 = YesterdayLow[dd]-2*(YesterdayHigh[dd]-Pivot);
od = TimeDay(BT);
}

PivotArray = Pivot;
R1Array=R1;
S1Array=S1;
R2Array=R2;
S2Array=S2;
R3Array=R3;
S3Array=S3;
}
//----
return(0);
}
//+------------------------------------------------------------------+



Необходимо заменить формулы Pivota, S1, R1 на следующие (С_PL_Dot, С_Res11, С_Sup11, соответственно):

//

double C_PL_Dot(int i)
{
double Result = (
((High[i+1] + Low[i+1]+Close[i+1]) / 3) +
((High[i+2] + Low[i+2]+Close[i+2]) / 3) +
((High + Low+Close) / 3)
) / 3;
return (NormalizeDouble(Result,4));
}

double C_dot11(int i) /* 1-1 Dot */
{
double Result = (High + Low + Close)/3;
return (NormalizeDouble(Result,4));
}

double C_Res11(int i) /* 1-1 High */
{
double Result = (C_dot11(i) * 2) - Low;
return (NormalizeDouble(Result,4));
}

double C_Sup11(int i) /* 1-1 Low */
{
double Result = (C_dot11(i) * 2) - High;
return (NormalizeDouble(Result,4));
}


Уровни S2, R2, S3, R4 - не нужны.

При попытке простой замены ничего хорошего не происходит. Не откажите в любезности поправить код.
Заранее благодарен!

P.S. Исходный Pivot прикрепляю
 

Вложения

Верх