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

 
novichok2018:

I think I've got it - the line is drawn, but there's only one. I think I understand - there is only one line drawn, but only one. In order to draw other lines, I have to erase this one.

Well, now I have to draw the last line instead of the first one. This is good, of course, but I need all lines to be saved. How do I do that? Thank you.

 
novichok2018:

Now, instead of the first line in the story , the last line is drawn. That's fine, but I need all the lines to be saved. How do I do that? Thank you.

In the line name, add the bar time.

 
Alexey Viktorov:

In the line name, add the bar time.

I don't understand how.

 
Alexey Viktorov:

In the line name, add the bar time.

Where can I read how to add the time in the name and which bar time to add?

 
novichok2018:

Where can I read how to add the time in the name, and which bar time to add?

Only the time definition has to be put before the line name assignment.


        if((op1-lo1)>50 && (cl1-lo1)<10)
        {  Alert("VertLine");
        datetime time=Time[0];
        string obj_name="VertLine"+(string)time;
        color col = clrGreen; 
        ObjectCreate(0,obj_name,OBJ_VLINE,0,time,0,0,0);
        ObjectSetInteger(0,obj_name,OBJPROP_COLOR,col);
        }
 
Alexey Viktorov:
Only the time definition should be put before the line name.


Thank you. When you see the code, everything makes sense. I never would have understood it myself. Nowhere did I see that in order for the lines to stay on the chart, you have to add the bar time to the line name, and why. Am I so inattentive?!

 
novichok2018:

I think I've got it - the line is drawn, but there's only one. I think I understand - there is only one line drawn, but only one. In order to draw other lines, you have to erase this one.

... or assign a line number to the name, because there cannot be more than one line with the same name

 
Alexandr Sokolov:

... there can't be more than one line with the same name

It's true! It turns out to be quite simple... Thank you.

 

Hello again!

I have found an oddity in closing positions: TakeProfit is not triggered when the price reaches it, but on a new bar. What is the reason?

I am attaching the code and the chart.

      if(New_Bar)      
         {
         if(Hour()>9 && Hour()<20)
         {
          if(...ЗДЕСЬ УСЛОВИЕ...) 
          {LotCalc();
      double TP=Ask-300*Point();
             t2=OrderSend(Symbol(),OP_SELL,LOT,Bid,slippage,0,TP,"",magic,0,Red);
            if(t2>0)
           {
            if(OrderSelect(t2,SELECT_BY_TICKET,MODE_TRADES))
            {
             Alert("Открыта SELL");
            }
           }            
         else
            Print("Error opening SELL order : ",GetLastError());
         return; 
            }
         }
         }

excerpt from

 
novichok2018:

Hello again!

I have found an oddity in closing positions: TakeProfit is not triggered when the price reaches it, but on a new bar. What is the reason?

I am attaching the code and chart fragments.


Oh, shit! I was bothering you again! I just scored testing by opening prices, that's what it was doing...