[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 270

 
Solree:
Ahahaha. Well, I'm not that new...

Well, then either the code in the studio or the telepaths.
 

I can't throw all the code, the customer would complain. But I have already thrown the part where it fails. The rest of the code has nothing to do with this problem. For some reason, this particular loop produces incorrect values when I run MT with an induke that was previously placed on it. If I don't get any ideas without providing the whole code, I will have to keep thinking by myself :(

 
Just noticed that if you restart MT again, it works correctly...
 
Solree:

I can't throw the whole code, the customer will scold me. But I have already thrown the part where it fails. The rest of the code is not related to the problem. I have a feedback loop, that loop produces incorrect values for some reason, when I run MT with an indicator hooked to it earlier. If I don't get any ideas without providing the whole code, I will have to keep thinking by myself :(


Please, do the prints more often and analyze the log.

By the way, in that code it is not clear what value the variable "count" has.

 
count - number of bars to be analysed later. But exactly y for some reason does not start from the first bar, which is now, but from the first bar, which was when MT was closed with the index. i = position to start with, y will then still be used in intermediate cycles, so specially created i. z is the bar from which everything will count. Here y outputs old bar, which was before MT was closed, and everything else starts counting from it.
 

Hello ! Could you please tell me how this can happen ?

i = 2, Open[i-2] = 1.5715
14:21:15 2011.01.12 18:08 My Fr Chekulaeva1 GBPUSD,M1: Low[i] = 1.5713, Low[i-1] = 1.5714
14:21:15 2011.01.12 18:08 My Fr Chekulaev1 GBPUSD,M1: Low[i+1] = 1.5714, Low[i-2] = 1.5715
14:21:15 2011.01.12 18:08 My Fr Chekulaev1 GBPUSD,M1: Open[i-2]-(Low[i]-1*PointX) = 0.0004
14:21:15 2011.01.12 18:08 My Fr Chekulaev1 GBPUSD,M1: 1*PointX = 0.0001

This is an excerpt from the log data during testing. 15-(13-1) should be 3. But in the tester it is 4. What is wrong?

 

Hi all, I am asking for help again with the MACD. I am having trouble finding a specific MACD histogram value (bar size). I need to calculate the value of the current (e.g. =-0.001131) bar, the previous one - any bar... and find the difference, e.g. between the current and the previous bar.

 
Ivan1:

Hi all, I am asking for help again with the MACD. I am having trouble finding a specific MACD histogram value (bar size). I need to calculate the value of the current (e.g. =-0.001131) bar, the previous one - any bar... and find the difference, e.g. between the current and the previous bar.

https://www.mql5.com/ru/forum/134688/page256
 
Solree:
Just noticed that if you restart MT again, it works correctly...

The indicator is quite easy to tweak to the right state. And most of the problems will disappear. But the problem area is small. The problem is a little wider
 

Well, that's it then:

#property indicator_chart_window

extern int count = 1500;

color colors[4];
bool check = true;
int tempCount;

int init()
{
    colors[0] = Blue;
    colors[1] = Purple;
    colors[2] = Orange;
    colors[3] = Red;

    tempCount = count;

    return;
}

int deinit()
{
    ObjectDelete("ResistLine0");
    ObjectDelete("ResistLine1");
    ObjectDelete("ResistLine2");
    ObjectDelete("ResistLine3");

    return;
}

int start()
{
    if (Period() != 60)
    {
        ObjectDelete("ResistLine0");
        ObjectDelete("ResistLine1");
        ObjectDelete("ResistLine2");
        ObjectDelete("ResistLine3");
        
        check = true;
    }
    
    if (TimeHour(Time[1]) == 8 && !check)
        check = true;
    
    if (count != tempCount)
    {
        tempCount = count;
        check = true;
    }

    if (check && Period() == 60)
    {
        ObjectDelete("ResistLine0");
        ObjectDelete("ResistLine1");
        ObjectDelete("ResistLine2");
        ObjectDelete("ResistLine3");
    
        int temp[20];
        int i, y, x, z;
        double price; //Она нужна для заполнения и выбора
        
        for (y = 1; y <= 24; y++)
            if (TimeHour(Time[y]) == 8)
            {//Тут y будет не корректным, когда запускаешь МТ с уже повешенным индюком
                i = y;
                z = y;
                x = i+count;
                
                break;
            }

        for (; i <= x; i++)
        {
            //Тут заполняется temp
        }
        
        double levels[4];
        i = z;
        
        //Тут выбираются нужные элементы из temp

        for (y = 0; y < 4; y++)
            createLine("ResistLine"+y, levels[y], colors[y], i);
        
        check = false;
    }

    return;
}

void createLine(string name, double price, color c, int i)
{
    ObjectCreate(name, OBJ_TREND, 0, Time[i], NormalizeDouble(price, Digits), Time[i]+(24*3600), NormalizeDouble(price, Digits));
    ObjectSet(name, OBJPROP_COLOR, c);
    ObjectSet(name, OBJPROP_WIDTH, 2);
    ObjectSet(name, OBJPROP_BACK, true);
    ObjectSet(name, OBJPROP_RAY, false);
}

Well actually only removed the algorithms for selecting and identifying the right item.

Reason: