Time based Renko chart!

 

Hi all,

as you know, renko chart depended on price changes and is independent from Time.

The Renko charts are constructed as follows: the close price of the current period compared with minimal and maximal prices of the previous.

In this thread you give the renko chart ea. Today i want to make some changes in the original code. If the renko box size is for example 10 pips, the renko bar could complete in couple of minutes or hours. I need some changes in this code, so for a defined time period (for example every 1 minute time) you have the last renko bar on chart until new bar completed. As soon as new bar completed it draws new renko bar. If the renko bar is completed and its size is greater than renkobox in less than 1 minute, the new renko bar size is created after one minute with this new size.


i think it must do some changes in this tag:     if(PrevTime < Time[i]) PrevTime = Time[i];  else PrevTime++; 

I do not know exactly how can i modify it in order to upon goal. If anyone has a solution please share it here.

Below you see part of renkochart script:


  if(StrangeSymbolName) SymbolName = StringSubstr(Symbol(), 0, 6);
        else SymbolName = Symbol();
        BoxPoints = NormalizeDouble(BoxSize*Point, Digits);
        PrevLow = NormalizeDouble(BoxOffset*Point + MathFloor(Close[Bars-1]/BoxPoints)*BoxPoints, Digits);
        DnWick = PrevLow;
        PrevHigh = PrevLow + BoxPoints;
        UpWick = PrevHigh;
        PrevOpen = PrevLow;
        PrevClose = PrevHigh;
        CurVolume = 1;
        PrevTime = Time[Bars-1];
    
        // create / open hst file        
        HstHandle = FileOpenHistory(SymbolName + RenkoTimeFrame + ".hst", FILE_BIN|FILE_WRITE);
        if(HstHandle < 0) {
            Print("Error: can\'t create / open history file: " + ErrorDescription(GetLastError()) + ": " + SymbolName + RenkoTimeFrame + ".hst");
            return(-1);
        }
        //
       
        // write hst file header
        int HstUnused[13];
        FileWriteInteger(HstHandle, 400, LONG_VALUE);             // Version
        FileWriteString(HstHandle, "", 64);                    // Copyright
        FileWriteString(HstHandle, SymbolName, 12);            // Symbol
        FileWriteInteger(HstHandle, RenkoTimeFrame, LONG_VALUE);    // Period
        FileWriteInteger(HstHandle, Digits, LONG_VALUE);        // Digits
        FileWriteInteger(HstHandle, 0, LONG_VALUE);            // Time Sign
        FileWriteInteger(HstHandle, 0, LONG_VALUE);            // Last Sync
        FileWriteArray(HstHandle, HstUnused, 0, 13);            // Unused
        //
       
         // process historical data
          int i = Bars-2;
        //Print(Symbol() + " " + High[i] + " " + Low[i] + " " + Open[i] + " " + Close[i]);
        //---------------------------------------------------------------------------
          while(i >= 0) {
          
            CurVolume = CurVolume + Volume[i];
        
            UpWick = MathMax(UpWick, High[i]);
            DnWick = MathMin(DnWick, Low[i]);
 
            // update low before high or the revers depending on is closest to prev. bar
            bool UpTrend = High[i]+Low[i] > High[i+1]+Low[i+1];
        
            while(UpTrend && (Low[i] < PrevLow-BoxPoints || CompareDoubles(Low[i], PrevLow-BoxPoints))) {
                  PrevHigh = PrevHigh - BoxPoints;
                  PrevLow = PrevLow - BoxPoints;
                  PrevOpen = PrevHigh;
                  PrevClose = PrevLow;
 
                FileWriteInteger(HstHandle, PrevTime, LONG_VALUE);
                FileWriteDouble(HstHandle, PrevOpen, DOUBLE_VALUE);
                FileWriteDouble(HstHandle, PrevLow, DOUBLE_VALUE);
 
                if(ShowWicks && UpWick > PrevHigh) FileWriteDouble(HstHandle, UpWick, DOUBLE_VALUE);
                else FileWriteDouble(HstHandle, PrevHigh, DOUBLE_VALUE);
                                                
                FileWriteDouble(HstHandle, PrevClose, DOUBLE_VALUE);
                FileWriteDouble(HstHandle, CurVolume, DOUBLE_VALUE);
                
                UpWick = 0;
                DnWick = EMPTY_VALUE;
                CurVolume = 0;
                CurHigh = PrevLow;
                CurLow = PrevLow;  
                
                if(PrevTime < Time[i]) PrevTime = Time[i];
                else PrevTime++;
            }


 
hmrt135:

Hi all,

as you know, renko chart depended on price changes and is independent from Time.

The Renko charts are constructed as follows: the close price of the current period compared with minimal and maximal prices of the previous.

In this thread you give the renko chart ea. Today i want to make some changes in the original code. 

OK,  have fun,  let us know if you need some help or have a question.
 
RaptorUK:
OK,  have fun,  let us know if you need some help or have a question.


Hi RaptorUk,

I do not know exactly how can i modify that code it in order to upon goal. If you can help me, please share it.

thank you for your response.

 
A goal you have not stated.
 
WHRoeder:
A goal you have not stated.

This is my Target:

write every minute(or any period of time) renkobox in offline history. If new renko bar is completed it will write in offline history. If renkobox in the defined timeperiod is not completed it will rewrite last renkobox.

 

It sounds like what you would end up with is a rather blocky version of a regular 1 minute time chart. There is a renko indicator somewhere I don't remember that plots renko ranges on a timeframe chart. Oh, yeah, I found it again... https://www.mql5.com/en/code/9498 another here... https://www.mql5.com/en/code/7524

Thinking about it again, it sounds like maybe constant range bars might fit your requirements better.

If you want an indicator to show the time renko bricks took to form, then please look at the simple indicator I wrote.

https://www.mql5.com/en/code/12491

Thanks.

 

Hi guys,

is there a way to get only the last Renko Bar direction?

Something like:

if(lastRenkoBar is up)

do something

else

do other things

 Thanks 

Reason: