Вопрос жизни и... жизни!

 

ЗЗдравствуйте. Придется захломить форум. В другой ветке не отвечают. Подскажите, пожалуйста, что нужно поменять в коде, чтобы сигнал отображался на минимуме четырех посдених свечей, а не на послденей? Скрин и код прилагается.

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Crimson
#property indicator_color2 Crimson
#property indicator_color3 Crimson
#property indicator_color4 Crimson
#property indicator_color5 Crimson

extern int    Target1    = 20;
extern int    Target2    = 30;
extern int    TakeProfit = 40;
extern int    StopLoss   = 40;
extern bool   IsTime     = false;
extern string TimeStart  = "05:00";
extern string TimeEnd    = "17:00";

double SellBuffer[];
double SellTP1Buffer[];
double SellTP2Buffer[];
double SellTP3Buffer[];
double SellSLBuffer[];

int init()
{
    SetIndexBuffer(0, SellBuffer);
    SetIndexBuffer(1, SellTP1Buffer);
    SetIndexBuffer(2, SellTP2Buffer);
    SetIndexBuffer(3, SellTP3Buffer);
    SetIndexBuffer(4, SellSLBuffer);
    SetIndexStyle(0, DRAW_ARROW);
    SetIndexStyle(1, DRAW_ARROW);
    SetIndexStyle(2, DRAW_ARROW);
    SetIndexStyle(3, DRAW_ARROW);
    SetIndexStyle(4, DRAW_ARROW);
    SetIndexArrow(0, 159);
    SetIndexArrow(1, 178);
    SetIndexArrow(2, 178);
    SetIndexArrow(3, 178);
    SetIndexArrow(4, 251);
    SetIndexLabel(0, "Sell");
    SetIndexLabel(1, "Sell Target1");
    SetIndexLabel(2, "Sell Target2");
    SetIndexLabel(3, "Sell TP");
    SetIndexLabel(4, "Sell SL");
    return(0);
}

int start()
{
    int limit;
    int counted_bars = IndicatorCounted();
    if (counted_bars > 0)
        counted_bars--;
    limit = Bars - counted_bars;
    for (int i = 0; i < limit; i++)
    {
        double main1=iCustom(NULL,0,"MTF_Stochastic",240,1,2,1,0,0,i+1);
        double sig1=iCustom(NULL,0,"MTF_Stochastic",240,1,2,1,0,1,i+1);
        double main2=iCustom(NULL,0,"MTF_Stochastic",240,1,2,1,0,0,i+2);
        double sig2=iCustom(NULL,0,"MTF_Stochastic",240,1,2,1,0,1,i+2);
        double main3=iCustom(NULL,0,"MTF_Stochastic",240,1,2,1,0,0,i+3);
        double sig3=iCustom(NULL,0,"MTF_Stochastic",240,1,2,1,0,1,i+3);
        double main4=iCustom(NULL,0,"MTF_Stochastic",240,1,2,1,0,0,i+4);
        double sig4=iCustom(NULL,0,"MTF_Stochastic",240,1,2,1,0,1,i+4);
        double main5=iCustom(NULL,0,"MTF_Stochastic",240,1,2,1,0,0,i+5);
        double sig5=iCustom(NULL,0,"MTF_Stochastic",240,1,2,1,0,1,i+5);
        string   str = TimeDay(Time[i + 1]) + "." + TimeMonth(Time[i + 1]) + "." + TimeYear(Time[i + 1]) + " ";
        datetime t1  = StrToTime(str + TimeStart + ":00");
        datetime t2  = StrToTime(str + TimeEnd + ":00");
        if (!IsTime || (IsTime && Time[i + 1] >= t1 && Time[i + 1] < t2))
        
        {
            if (main1 == main2 && sig1 == sig2 && 
                main2 == main3 && sig2 == sig3 &&
                main3 == main4 && sig3 == sig4 &&
                main1 < sig1 && main2 < sig2 && main3 < sig3 && main4 < sig4 &&
                main5 > sig5)
            {
                SellBuffer[i + 1]    = Low[i + 1] - 1 * Point;
                SellTP1Buffer[i + 1] = Low[i + 1] - (Target1 + 1) * Point;
                SellTP2Buffer[i + 1] = Low[i + 1] - (Target2 + 1) * Point;
                SellTP3Buffer[i + 1] = Low[i + 1] - (TakeProfit + 1) * Point;
                SellSLBuffer[i + 1]  = Low[i + 1] + (StopLoss - 1) * Point;
            }
        
        
        }
    }
    return(0);
}

Пробывал вместо Low[i + 1] вставить Low[iLowest(NULL,PERIOD_H1,MODE_LOW,3,1)] . Не получается.

 
Вопрос еще открыт
 
сигнал отображался на минимуме четырех посдених свечей, а не на послденей?
пройтись по 4 последним свечам и расставить сигнал.
 
Maniac:

ЗЗдравствуйте. Придется захломить форум. В другой ветке не отвечают. Подскажите, пожалуйста, что нужно поменять в коде, чтобы сигнал отображался на минимуме четырех посдених свечей, а не на послденей? Скрин и код прилагается.

Пробывал вместо Low[i + 1] вставить Low[iLowest(NULL,PERIOD_H1,MODE_LOW,3,1)] . Не получается.

попробуйте вместо 1 поставить i+1 Low[iLowest(NULL,PERIOD_H1,MODE_LOW,3,i+1)]
Причина обращения: