Help needed with a Range indicator for specified hours

 

Hi,

I have been trying without progress (im nothing more than a cut and paste guy) to create an indicator which does the following.

 

Gives the average daily range ADR for a specified period (x) days but only for the specified hours (start - end)

I want to have an indicator I can place on GPBUSD that will take the past 5 days data (excluding sunday) and only between the hours of 5pm and 8am and display that range.

So in effect I will have a indicator displaying the average range of 5 days during the time the market was closed.

 

I have tried to play around with an ADR indicator but as im only a cut and paste guy Im finding it really tough to get anywhere.

 

If anyone can help it would be appreciated.

 

Regards

Console 

 
console:

Hi,

I have been trying without progress (im nothing more than a cut and paste guy) to create an indicator which does the following.

 

Gives the average daily range ADR for a specified period (x) days but only for the specified hours (start - end)

I want to have an indicator I can place on GPBUSD that will take the past 5 days data (excluding sunday) and only between the hours of 5pm and 8am and display that range.

So in effect I will have a indicator displaying the average range of 5 days during the time the market was closed.

 

I have tried to play around with an ADR indicator but as im only a cut and paste guy Im finding it really tough to get anywhere.

 

If anyone can help it would be appreciated.

 

Regards

Console 

Hey. By ADR indicator do you mean the average true range?
 

console: I have been trying without progress (im nothing more than a cut and paste guy) to create an indicator which does the following.

I want to have an indicator I can place on GPBUSD that will take the past 5 days data (excluding sunday) and only between the hours of 5pm and 8am and display that range.

So in effect I will have a indicator displaying the average range of 5 days during the time the market was closed.

  1. Since there are no slaves here, you have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt and the nature of your problem.
  2. This will start you off:
    Not compiled, not tested.
    #define HR2400 86400       // 24 * 3600
    int      TimeOfDay(datetime when){  return( when % HR2400            );    }
    datetime DateOfDay(datetime when){  return( when - TimeOfDay(when)   );    }
    #define HR1700 28800 // 17*3600 5 PM
    #define HR0800 28800 //  8*3600 8 AM
    double AveRange(int nBars = 5, int iDay=0, int timeFrom=HR1700, timeTo=HR0800){
       double   sum=0;   for(int nSum=0; nSum < nBars; nSum++){
          while(true){                                       #define DOW_SUNDAY 0
             datetime today       = iTime(NULL, PERIOD_D1, iDay);
             if(TimeDayOfWeek(today) != DOW_SUNDAY) break;
             iDay++;
          }
          if(timeFrom > timeTo)   iDay++;
          while(true){
             datetime yesterday   = iTime(NULL, PERIOD_D1, iDay);
             if(TimeDayOfWeek(yesterday) != DOW_SUNDAY)   break;
             iDay++;
          }
          int      iTo      = iBarShift(NULL,0,     today + timeTo),
                   iFrom    = iBarShift(NULL,0, yesterday + timeFrom);
    
          // Not including To bar.
          double   iHi      = iHighest(NULL,0, MODE_HIGH, iFrom-iTo, iTo+1),
                   iLo      = iLowest( NULL,0, MODE_LOW,  iFrom-iTo, iTo+1);
          sum += High[iHi] - Low[iLo];
       }
       return(sum/nSum);
    }
    Not compiled, not tested.
  3. If the market is closed there is NO movement, there are no bars.