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

 
BooGUY:

On a fractal! I tried it with a stop-loss - it sucks, I would like to try it with stops on fractals, but I don't know how to write it in the condition. Or how to write it in an EA, I have written an entry condition, something like this

if(iOpen(NULL,PERIOD_H1,1)<iClose(NULL,PERIOD_H1,1)&&

iOpen(NULL,PERIOD_M30,1)<iClose(NULL,PERIOD_M30,1)&&

iOpen(NULL,PERIOD_M15,1)<iClose(NULL,PERIOD_M15,1)&&

iOpen(NULL,PERIOD_M5,1)<iClose(NULL,PERIOD_M5,1)

{...???

}


I doubt from your code that the conversation is about a fractal. some opening and closing prices on 4 periods.
 
BooGUY:

On a fractal! I tried it with a stop loss - it's losing, I would like to try it with stops on fractals, but I don't know how to write it in the condition. Or how to write it in an EA, I have written an entry condition, something like this

if(iOpen(NULL,PERIOD_H1,1)<iClose(NULL,PERIOD_H1,1)&&

iOpen(NULL,PERIOD_M30,1)<iClose(NULL,PERIOD_M30,1)&&

iOpen(NULL,PERIOD_M15,1)<iClose(NULL,PERIOD_M15,1)&&

iOpen(NULL,PERIOD_M5,1)<iClose(NULL,PERIOD_M5,1)

{...???

}

To test the strategy, it is easier for you to find a trailing stop function by fractals and include it into your EA. Or you can write it yourself.

The function will move the stop of each open position to the necessary fractal set in the settings. And then, based on the test results, we can already think about the advisability of using either this trawl, or closing of market positions when the price reaches the fractal level. Neither of them is an easy thing to do.

The standard function iFractals() will help you. It returns the price at which the fractal is found, as specified in the function parameters.

 

help please, my indicator measures the maximum minute movement for the current hour on an hour timeframe, the first 6 hours (bars) it measures everything adequately, and then starts some illegal values come up below the code itself and the indicator, tell me where I went wrong, although I do not care values beyond 3 bars, but I fear that errors may occur on the first bar

#property indicator_separate_window
#property indicator_buffers 1       // Количество буферов
#property indicator_color1 Blue     // Цвет первой линии
#property indicator_minimum 0
#property indicator_maximum 25
double Buf_0[];             // Объявление массивов (под буферы индикатора)
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
SetIndexBuffer(0,Buf_0);         // Назначение массива буферу   
SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);// Стиль линии 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
int i;                           // Индекс бара       
int Counted_bars;                // Количество просчитанных баров
int m;
int MaxSpeed;
int Speed; 
//--------------------------------------------------------------------   
Counted_bars=IndicatorCounted(); // Количество просчитанных баров    
i=Bars-Counted_bars-1;           // Индекс первого непосчитанного   
while(i>=0)                      // Цикл по непосчитанным барам     
 {
 
 MaxSpeed=0;
 if (Period()==PERIOD_H1)
  {
  m=59;
  while (m>=0)
   {
   Speed=(iOpen(Symbol(),PERIOD_M1,m+60*i)-iClose(Symbol(),PERIOD_M1,m+60*i))/Point;
   if (MaxSpeed<Speed)
    {
    MaxSpeed=Speed;
    }
   m--;
   }
  }
 if (Period()==PERIOD_M1)
  {
  m=0;
  while (m>=0)
   {
   Speed=(iOpen(Symbol(),PERIOD_M1,m+i)-iClose(Symbol(),PERIOD_M1,m+i))/Point;
   if (MaxSpeed<Speed)
    {
    MaxSpeed=Speed;
    }
   m--;
   }
  }      
 Buf_0[i]=MaxSpeed;             // Значение 0 буфера на i-ом баре      
 i--;                          // Расчёт индекса следующего бара     
 }   
//----
   return(0);
  }
//+------------------------------------------------------------------+
i think i may have some errors on the first bar.
Files:
speed.mq4  3 kb
 
Lots and lots of MASD Maybe someone knows where to bend one of these????
 
LazarevDenis:

help please, my indicator measures the maximum minute movement for the current hour on an hour timeframe, the first 6 hours (bars) it measures everything adequately, and then starts some illegal values come up below the code itself and the indicator, advise where I went wrong, although I do not care values beyond 3 bars, but I fear that errors may occur on the first bar

i originally had a different indicator, i took it apart and "soldered" my code


What did you want to get?
 

Vinin:

What did you want to get?


I want the indicator to show the maximum value of iOpen-iClose among the minute bars, but for HOUR, for example for an hour of 59 minute bars iOpen-iClose = 3 (for example) and one minute bar iOpen-iClose = 10 and on an hour timeframe, it must show 10 without any deviations and I need the indicator to close orders, if a minute rate goes too fast in the wrong direction, then the adviser will be a signal to close

This is the first version of it and later I want it to be able to detect which way the price is going.

 

If you click on a graphical object, e.g. a Horizontal Line, you can see a "Description" in the window that opens.

- Is it possible to add a "Description" from the code?

Thank you!

 
chief2000:

If you click on a graphical object, e.g. a Horizontal Line, you can see a "Description" in the window that opens.

- Is it possible to add a "Description" from the code?

Thank you!

https://docs.mql4.com/ru/objects/ObjectSetText
 

Just what I needed! Thank you!

 

LazarevDenis

The initial count is 59 bars, which is incorrect. There may be gaps in minutes, and the last hour bar may contain fewer minutes.

You should take the hour bar open and close time (Time[i]). Use this time to calculate offsets for iBarShift minutes, and then calculate the maximum within this range of offsets.

By the way, what should the indicator show on a minute period?

If the number is positive the price goes upwards, if the number is negative - downwards, returning the number modulo it will show the strength of the movement.