Coding FIbonacci in a Specific Time Range

 

Hi, i'm currently coding a strategy which requires a Fibonacci in a specific time range.

Let say, the Fibonacci levels has to be drawn based on 1 month highest and lowest point.

 

      int fibHigh = iHighest(NULL, PERIOD_W1, MODE_HIGH, *What to put?*, 1);
      int fibLow  = iLowest(NULL, PERIOD_W1,MODE_LOW, *What to put?*, 1);
   

 

I'm using iHighest and iLowest to look out for the highest and lowest tick, but I have no idea what function/value should I put in the count so that the Fibonacci level can be drawn based on the highest and lowest point of that time range?

Please advice, much obliged! 

 

Hi!

We don't know how you define a month.

Is a calender month or just the last 30 days or 4 to 5 weeks and is the actual week included?

Open a W1 chart and define what you want and fill the parameters of your function calls.

 
kai197:

Hi, i'm currently coding a strategy which requires a Fibonacci in a specific time range.

Let say, the Fibonacci levels has to be drawn based on 1 month highest and lowest point.

I'm using iHighest and iLowest to look out for the highest and lowest tick, but I have no idea what function/value should I put in the count so that the Fibonacci level can be drawn based on the highest and lowest point of that time range?

Please advice, much obliged! 

You have to use the function iBarShift() to identify the bar shift positions, from the dates and times you define. With those bar shifts you can then calculate the starting position and bar count to use in iHighest() and iLowest().

See the following post for an example of its use and adapt it to your own requirements: https://www.mql5.com/en/forum/158978

 
eddie:

Hi!

We don't know how you define a month.

Is a calender month or just the last 30 days or 4 to 5 weeks and is the actual week included?

By calender month.

 

eddie:

Open a W1 chart and define what you want and fill the parameters of your function calls.

What is the parameters should I put if I want the month to be fixed for the next entire trading month? 

Thank you. 

 
kai197: By calender month.  What is the parameters should I put if I want the month to be fixed for the next entire trading month?

To build the dates, you can use the functions TimeToStruct() and StructToTime() so that you have dates specific to the first day of the each calendar month (or whatever criterion, you want to define), which you can then use with iBarShift() and then apply to iHighest() and iLowest() (see my previous post)

PS! Alternatively, just obtain the date/time for the higher Monthly time-frame bars, using iTime(), in order to more easily synchronise with the Weekly time-frame.

Actually it is way easier, to just use the OHLC values from the Monthly bars, as that already tells you the High and Low for the entire month, so there is no need to get it from the weekly bars.

 
FMIC:

To build the dates, you can use the functions TimeToStruct() and StructToTime() so that you have dates specific to the first day of the each calendar month (or whatever criterion, you want to define), which you can then use with iBarShift() and then apply to iHighest() and iLowest() (see my previous post)

PS! Alternatively, just obtain the date/time for the higher Monthly time-frame bars, using iTime(), in order to more easily synchronise with the Weekly time-frame.

Actually it is way easier, to just use the OHLC values from the Monthly bars, as that already tells you the High and Low for the entire month, so there is no need to get it from the weekly bars.

Thks for ur valuable advice!

Let me try first~ 

Reason: