Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 383

 
konam1:
Good afternoon everyone. Tracking the values of the parabolic at the opening of each hourly candle.
When I run it through the history, the iSAR of the zero bar coincides with the point on the chart, except when the parabolic changes position from top to bottom and vice versa.
if (newbarall!=(iTime(Symbol(),60,0))
{
newbarall=iTime(Symbol(),60,0);
Print (iTime(Symbol(),60,0));
Print ("SAR = ",NormalizeDouble(iSAR(Symbol(),60,0.02,0.2,0),Digits);
};
Hence the following questions:
Why is the zero bar parabolic counted incorrectly precisely at these moments?
And, actually, how to avoid it, because when the bar opens, the point appears and is static without recalculation during the formation of the candle.
Please help). Thank you!

If you observe the parabolic point on the zero candle, it is not static after all - it changes its position, and not only when you change position up and down, but in general - sometimes it shifts slightly at one position (without going up and down)

 

Hello, could you tell me why the horizontal lines are not being deleted?

   if(SellInvertedHammer == true)
   {
      //if ((Open1 < Close1 && delta_minus < 0) || (Open1 >= Close1 && delta_plus > 0))
      {
         if(!ObjectCreate(ChartID(),"Arrow_Down_InvertedHammer"+IntegerToString(InvertedHammerCandle),OBJ_ARROW_DOWN,0,TimeCurrent(),High[1] + 70*Point))
               {
               Print("Не удалось создать метку вниз");
               }
               ObjectSetInteger(ChartID(),"Arrow_Down_InvertedHammer"+IntegerToString(InvertedHammerCandle),OBJPROP_COLOR,clrRed);//--- установка цвета
               ObjectSetInteger(ChartID(),"Arrow_Down_InvertedHammer"+IntegerToString(InvertedHammerCandle),OBJPROP_STYLE,STYLE_SOLID);//--- установка стиля линии
               ObjectSetInteger(ChartID(),"Arrow_Down_InvertedHammer"+IntegerToString(InvertedHammerCandle),OBJPROP_WIDTH,1);//--- установка толщины линии
               ObjectSetInteger(ChartID(),"Arrow_Down_InvertedHammer"+IntegerToString(InvertedHammerCandle),OBJPROP_BACK,false);//--- отображение на переднем (false) или заднем (true) плане
               InvertedHammerCandle ++;
         Print ("Перевернутый молот");
         Print ("Дельта+ = " + IntegerToString (delta_plus));
         Print ("Дельта- = " + IntegerToString (delta_minus));
         Print ("Объем = " + IntegerToString (volume));
         Print ("Кумулитивная дельта = " + IntegerToString (cum_delta));
         
         if(!ObjectCreate(ChartID(),"UpLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle),OBJ_HLINE,0,TimeCurrent(),UpLine_InvertedHammer))
         {
         Print("Не удалось создать верхнюю линию");
         }
         ObjectSetInteger(ChartID(),"UpLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle),OBJPROP_COLOR,clrBlueViolet);//--- установим цвет прямоугольника 
         ObjectSetInteger(ChartID(),"UpLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle),OBJPROP_STYLE,STYLE_SOLID);//--- установим стиль линий прямоугольника 
         ObjectSetInteger(ChartID(),"UpLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle),OBJPROP_WIDTH,1);//--- установим толщину линий прямоугольника 
         ObjectSetInteger(ChartID(),"UpLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle),OBJPROP_BACK,false);//--- отобразим на переднем (false) или заднем (true) плане 
         
         
         if(!ObjectCreate(ChartID(),"DownLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle),OBJ_HLINE,0,TimeCurrent(),DownLine_InvertedHammer))
         {
         Print("Не удалось создать нижнюю линию");
         }
         ObjectSetInteger(ChartID(),"DownLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle),OBJPROP_COLOR,clrSlateBlue);//--- установим цвет прямоугольника 
         ObjectSetInteger(ChartID(),"DownLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle),OBJPROP_STYLE,STYLE_SOLID);//--- установим стиль линий прямоугольника 
         ObjectSetInteger(ChartID(),"DownLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle),OBJPROP_WIDTH,1);//--- установим толщину линий прямоугольника 
         ObjectSetInteger(ChartID(),"DownLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle),OBJPROP_BACK,false);//--- отобразим на переднем (false) или заднем (true) плане 
         lineInvertedHammerCandle ++;
                         
      }

   }
   if(ma2 > UpLine_InvertedHammer && ma2 > DownLine_InvertedHammer && ma1 > UpLine_InvertedHammer && ma1 > DownLine_InvertedHammer)
               {
                  UpLine_InvertedHammer = 0;
                  DownLine_InvertedHammer = 0;
               }
      
   if (ma2 < UpLine_InvertedHammer && ma2 > DownLine_InvertedHammer && ma1 < UpLine_InvertedHammer && ma1 < DownLine_InvertedHammer)
         {
            
             if(!ObjectCreate(ChartID(),"Arrow_Sell_InvertedHammer"+IntegerToString(InvertedHammerCandleSell),OBJ_ARROW_SELL,0,TimeCurrent(),Low[1] + 50*Point))
                {
                Print("Не удалось создать метку вниз");
                }
                ObjectSetInteger(ChartID(),"Arrow_Sell_InvertedHammer"+IntegerToString(InvertedHammerCandleSell),OBJPROP_COLOR,clrRed);//--- установка цвета
                ObjectSetInteger(ChartID(),"Arrow_Sell_InvertedHammer"+IntegerToString(InvertedHammerCandleSell),OBJPROP_STYLE,STYLE_SOLID);//--- установка стиля линии
                ObjectSetInteger(ChartID(),"Arrow_Sell_InvertedHammer"+IntegerToString(InvertedHammerCandleSell),OBJPROP_WIDTH,1);//--- установка толщины линии
                ObjectSetInteger(ChartID(),"Arrow_Sell_InvertedHammer"+IntegerToString(InvertedHammerCandleSell),OBJPROP_BACK,false);//--- отображение на переднем (false) или заднем (true) плане
                InvertedHammerCandleSell ++;
                Print("Точка входа SELL по разворотной свече 'Перевернутый молот'");
                UpLine_InvertedHammer = 0;
                DownLine_InvertedHammer = 0;
                
                int upline;
                int downline;
                upline = ObjectFind(ChartID(),"UpLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle));
                downline = ObjectFind(ChartID(),"DownLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle));
                if(upline > -1 && downline > -1)
                  {
                   ObjectDelete("UpLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle));
                   ObjectDelete("DownLine_InvertedHammer"+IntegerToString(lineInvertedHammerCandle));
                   Print("Линии удалены");
                  }
                  Print("Не удалось удалить верхнюю и нижнюю линии");
                
          }

This is part of the whole code. I'll post the whole code if necessary


Thank you

 

- I want to learn how to write an EA in MT4 or MT5, I need an experienced EA writer who can explain all the nuances of the code in practice and help me write code. I do not need help in writing a ready-made EA, I have some experience of trading and ideas to check everything in the test and understand how to use in conditions, I need to learn how to write different conditions.

 
Artyom Trishkin:

If you observe the point of the parabolic on the zero candle, it is not static after all - it changes its position, and not only when you change position up and down, but in general - sometimes it shifts a little at one position (without up/down transition)


Nevertheless, the history is a complete match, except for the "transition" moments. I'm even happy with a 1-2 point error. At the "transition" it could be 20 pips or more.

The question is the same, how to avoid it. Thanks

 
konam1:

Nevertheless, the history is a complete match, except for the "transition" moments. I'm even happy with a 1-2 point error. At the "transition" it could be 20 pips or more.

The question is the same, how to avoid it. Thank you

What is this construction anyway?

if(newbarall!=(iTime(Symbol(),60,0)))
  {
   newbarall=iTime(Symbol(),60,0);  
   Print(iTime(Symbol(),60,0));
   Print("SAR = ",NormalizeDouble(iSAR(Symbol(),60,0.02,0.2,0),Digits));
  };

What does it give?

Why do you print the time in such a way?

And why do you print the value of the parabolic in this way?

 
Artyom Trishkin:

What kind of design is this, anyway?

What is the benefit of such a design?

Why do you print the time in this way?

Why do you print the value of the parabolic in this way?


-This construction gives the fulfillment of the condition when a new hour candle appears: If the time of the hour candle does not match the value in the variable newbarall, then we write a new time to the variable and fulfill the condition.

Time of opening of one-hour candle is printed

- The value of the parabolic is rounded to 4 decimal places to be identical to what is shown on the chart.

 
konam1:

-This design gives a condition when a new one-hour candle occurs: If the time of the one-hour candle does not match the value in the newbarall variable, then write a new time to the variable and fill in the condition.

Time of opening of one-hour candle is printed

- The parabolic value is rounded to 4 decimal places to be identical to what is shown on the chart

1. No, it does not

2. Let it be like this

3. Are you sure you are printing a real number with that function?

4. Why do you need ; after the closing parenthesis?

 
Artyom Trishkin:

1. No, it does not

2. Let it be this way

3. Are you sure you are printing a real number with that function?

4. Why do you need ; after the closing parenthesis?


1. Nevertheless, the algorithm works only on the opening of a candle, what is the error in such a construction?

3. The numbers printed are 1.1820, for instance, so I am sure.

4. A part of the code is given.

 
konam1:

1. nevertheless, the algorithm only works on the opening of a candle, what is the error in such a design?

3. numbers 1.1820 are printed for example, so sure.

4. a part of the code is given.

1. Well, maybe I missed it - it's half past five in the morning...

3. DoubleToString()

4. But you have a condition and a compound operator:

if(condition) { }

I don't see any other way of interpreting it. Why do you need ";" after the operator?

 
konam1:
Hence the following questions:
Why is the zero bar parabolic counted incorrectly at these exact moments?
And, in fact, how to avoid it, because when the bar opens the point appears and is static without recalculation during the formation of the candle.
Please help). Thank you!

The statement "the point appears and is static without recalculation during the formation of a candle" is not correct, if the price breaks the parabolic, the point is redrawn.
You need to recalculate the parabolic every tick, because the breakout can happen at any time, not only at bar opening.

Reason: