Renko 1st Bar OPEN value for today

 

Hello,

I've been working on creating some indicator which will be working on Renko Charts. I need to access the Open value of the 1st bar for today on RENKO CHART. I Can access open with "PERIOD_D1", but that gives me Open value according to normal chart not according to Renko Chart. I dont understand what function shall I use to pick that value for today 1st Renko bar.

Renko 1st Bar


As You can see in this picture I shared, period separators showing the change of day. At that time the 1st Renko bar's Open value is required.

Kindly Help if there is some possible solution to this problem.

Thank You

 
You are working with an offline chart. As long as the generator creates valid history including time, you find the opening bar and use Open[] just like you'd do with a timebased chart.
Not compiled, not tested.
#define HR2400 86400       // 24 * 3600
int      TimeOfDay(datetime when){        return( when % HR2400          );   }
datetime DateOfDay(datetime when){        return( when - TimeOfDay(when) );   }
datetime Today(    datetime when=0){      if(when == 0)  when = TimeCurrent();
                                          return(DateOfDay( TimeCurrent() )); }
//datetime Tomorrow( datetime when=0){      if(when == 0)  when = TimeCurrent();
//                                          return(Today(when) + HR2400);       }
//datetime Yesterday(datetime when=0){      if(when == 0)  when = TimeCurrent();
//   int iD1 = iBarShift(NULL, PERIOD_D1, Today(when) - 1);
//                                       return( iTime(NULL, PERIOD_D1, iD1) ); }

int       iBOD = iBarShift(NULL,0, Today() );
double dailyOpen =Open[iBOD];
Not compiled, not tested.
 
int DAY = 86400;
datetime MIDNIGHT = (TimeCurrent() / DAY) * DAY; // time at today midnight
int lastBar = iBarShift(Symbol(), 0, MIDNIGHT-1, false); // this index belongs to the last on yesterday with Renko
int firstBar = lastBar - 1;
double openPrice = Open[firstBar];

Just a suggestion, no idea if it compiles. It needs additional check if the first bar already started (lastBar must be >= 1)

PS. Looking at your Renko chart, many wicks seem defective, they should extend behind the preceded candle body in all turning points.

 
Thank you guys, I'll try to test the codes you shared. If there is some issue i'll write again :)
 
jp_forex:

Hello,

I've been working on creating some indicator which will be working on Renko Charts. I need to access the Open value of the 1st bar for today on RENKO CHART. I Can access open with "PERIOD_D1", but that gives me Open value according to normal chart not according to Renko Chart. I dont understand what function shall I use to pick that value for today 1st Renko bar.


As You can see in this picture I shared, period separators showing the change of day. At that time the 1st Renko bar's Open value is required.

Kindly Help if there is some possible solution to this problem.

Thank You




with an offlinechart created with renko

then starting with new day we not start with new bar at offlinechart !!!!

i think i would do it this way

int lastbarforseparator = 0;
int baratseparator;
string var1=TimeToStr(TimeCurrent(),TIME_DATE);
string var2=TimeToStr(Time[0],TIME_DATE);
string var3=TimeToStr(Time[lastbarforseparator],TIME_DATE);

if (var1 != var2)Print("1st bar for today is not opend");
while(var2 == var3)
  {
  lastbarforseparator++;
  var3=TimeToStr(Time[lastbarforseparator],TIME_DATE);
  }
baratseparator = lastbarforseparator-1;
double dailyOpen =Open[baratseparator];

to check if the date is different

 
Ovo:

Just a suggestion, no idea if it compiles. It needs additional check if the first bar already started (lastBar must be >= 1)

PS. Looking at your Renko chart, many wicks seem defective, they should extend behind the preceded candle body in all turning points.


The value that is returned is fine, about that lastBar check, i'll check that when 1st Renko bar formed.

About the Renko chart, Wicks are not defective, its just that they didnt moved in that direction with specified Brick Size so just left Wicks behind :)

 
jp_forex:

The value that is returned is fine, about that lastBar check, i'll check that when 1st Renko bar formed.

About the Renko chart, Wicks are not defective, its just that they didnt moved in that direction with specified Brick Size so just left Wicks behind :)


look to the wick in the first circle from a green bar that doesn't look like it should be.... with renko bars
 
deVries:


with an offlinechart created with renko

then starting with new day we not start with new bar at offlinechart !!!!

i think i would do it this way

to check if the date is different


The approach you used is doing also well for me just as Ovo's code is also giving me required result. I'll check them both at 1st Renko bar if they giving me Perfect result.

 
AnyWay, THANK YOU guys. This forum always help when I see no option to move on. Thanks to all Good people over here :D
 
deVries:

look to the wick in the first circle from a green bar that doesn't look like it should be.... with renko bars

Oh yes, There was some news that day. Actually Renko charts us M2 timeframe & we run the Renko Chart EA on M1 timeframe. Untill the M1 candle closes, Renko just creates candles but donot make them permanent untill that M1 candle closes. As it closes, it creates those renko bars accordingly. Im Not very sure as I have tested Renko on Bigger time frames before using them & I noticed this thing. May be im wrong.