A trend-following strategy. - page 12

 
JLY:

And how do I remove the icons if the line is no longer there?

ObjectDelete(0,"имя значка"+name);
если у значка нет имени, то в данном случае
ObjectDelete(0,name);

You need the time calculation in bars

Do it in bars.

you know the time, i.e. Time[9] was 9 bars.

I only wrote the beginning,

Then do what you want.

 
pako:

Time calculation is needed in bars

do it in bars.

You have the time known, i.e. Time[9] was 9 bars.

I only wrote the beginning,

Then do what you want.

Thank you, only there was no need to create a line (just set parameters), and so everything works.

In the 4-th time in bars through iBarShift was calculated. I used this formula:

datetime time01=time1NEW;datetime time02=time2NEW;
int shift01=iBarShift(0,0,time01);int shift02=iBarShift(0,0,time02);//перевод из скунд в бары
int timeCHANGE=shift01-shift02;//разница между 1-й и 2-й точкой линии
int timeBAR=(shift02-timeCHANGE);//прибавить разницу ко 2-й точке
int timeBARc=Time[timeBAR];//Перевод из баров в секунды

The fifth doesn't have this function, and I don't know how to use Copy*...

 
JLY:

Thanks, but there was no need to create a line (just set parameters), but it works.

In the 4th, the time in bars was counted through iBarShift. This is the formula:

The fifth doesn't have this function, and I don't know how to use Copy* function yet...

iBarShift analog in 5

int iBarShift(string symbol,
                  int tf,
                  datetime time,
                  bool exact=false)
  {
   if(time<0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   datetime Arr[],time1;
   CopyTime(symbol,timeframe,0,1,Arr);
   time1=Arr[0];
   if(CopyTime(symbol,timeframe,time,time1,Arr)>0)
     {
      if(ArraySize(Arr)>2) return(ArraySize(Arr)-1);
      if(time<time1) return(1);
      else return(0);
     }
   else return(-1);
  }
 
In MQL5 constants of periods have changed (new periods M2, M3, M4, M6, M10, M12, H2, H3, H6, H8, H12 have been added), you can use the following function to convert MQL4 periods:
ENUM_TIMEFRAMES TFMigrate(int tf)
  {
   switch(tf)
     {
      case 0: return(PERIOD_CURRENT);
      case 1: return(PERIOD_M1);
      case 5: return(PERIOD_M5);
      case 15: return(PERIOD_M15);
      case 30: return(PERIOD_M30);
      case 60: return(PERIOD_H1);
      case 240: return(PERIOD_H4);
      case 1440: return(PERIOD_D1);
      case 10080: return(PERIOD_W1);
      case 43200: return(PERIOD_MN1);
      
      case 2: return(PERIOD_M2);
      case 3: return(PERIOD_M3);
      case 4: return(PERIOD_M4);      
      case 6: return(PERIOD_M6);
      case 10: return(PERIOD_M10);
      case 12: return(PERIOD_M12);
      case 16385: return(PERIOD_H1);
      case 16386: return(PERIOD_H2);
      case 16387: return(PERIOD_H3);
      case 16388: return(PERIOD_H4);
      case 16390: return(PERIOD_H6);
      case 16392: return(PERIOD_H8);
      case 16396: return(PERIOD_H12);
      case 16408: return(PERIOD_D1);
      case 32769: return(PERIOD_W1);
      case 49153: return(PERIOD_MN1);      
      default: return(PERIOD_CURRENT);
     }
  }
 
JLY:

I've done the drawing by seconds, there are gaps in the weekend, which means you still need to count by bars.

int  PeriodSeconds(
   ENUM_TIMEFRAMES  period=PERIOD_CURRENT      // период графика
   );
Returns the number of seconds in the period.
 
pako:

Thank you very much. Barshift counts.

All that's left to do is to translate the resulting bar into seconds. In 4, it was Time[bar].

In 5, I'm doing it like this according to the rule, but it's not working:

datetime Time[];
int count=1; 
ArraySetAsSeries(Time,true);
int timeBARsec=CopyTime(_Symbol,_Period,timeBAR,count,Time);//Перевод из баров в секунды
 
JLY:

Thank you very much. Barshift counts.

All that's left to do is to translate the resulting bar into seconds. In 4, it was Time[bar].

In the 5th, I'm doing this by the rule, but I can't get it to work:

If I understand the question correctly.

    datetime Time[]; 
    ArraySetAsSeries(Time,true);
    CopyTime(Symbol(),PERIOD_CURRENT,0,100,Time);
    long timeBARsec = Time[2];//Перевод из баров в секунды, в данном случае Time[бар] бар = 2

    Comment("timeBARsec = ",StringToTime(Time[2]));
 
pako:

if I understood the question correctly

Yes, it's working) Thank you very much)

If there is no "end" it is zero and cannot be seen.

Files:
TimeEnd.mq5  5 kb
 

1. Made the hour accuracy for the indicator and the time in the icon description (include the description in the chart properties).

2. Would it be better to put the icons in a buffer? Only how to do this, how to combine time and price in the same buffer?

3. If the line is drawn and there is no icon yet (bar has not appeared), then it gives an error (in the "Experts" tab) and the work with the other icons stops.

2013.09.22 00:10:36 FlatExecution (EURUSD,D1) array out of range in 'FlatExecution.mq5' (124,30)

I.e. array is out of range... The error is in this line:

long timeBARsec=Time[timeBAR];

How can I make my indicator not paralyzed by this error? How do I change the indicator to not paralyze the operation of this error?

Algorithm of trading: Entry by time icon, stop by entry line, exit by entry line icon.

5. Rule of drawing lines: From each fractal to all subsequent ones, from the top to the top and from the bottom to the bottom. Remove lines that are touched by the price and do not draw them.


Files:
 

The problem with the error has been resolved.

The icon is now drawn on the signal bar opening.

If the line is executed, it takes a different appearance, a line is drawn to it and it loses the beam. If the line is not executed, it is yellow.

If the line on which the stop will decrease beyond the 2nd point, you can make a stop after the second point. As a matter of fact the stop can be moved along this line as well, if it is calculated differently.

Drawing remains the same, according to fractals.

Algorithm. The sign does not always mean unambiguous buying or selling. However I think that news influences it somehow. In fact, testing was not carried out because there is no automatic drawing by fractals and corrections of this drawing (removal of the affected lines).

Files: