Higher time frame candlestick on a lower time frame chart

Category: Indicators By: pableitor Created: November 19, 2018, 9:48 AM
November 19, 2018, 9:48 AM
Indicators
18 Comments

This indicator allows you to draw higher TF candles in the price window.The period of the high TF candles is set in minutes (1 Hour 60, 4 hours 240, one day 1440 etc.)
The high TF candle is drawn as red or green rectangle. As it is not possible to fill a rectangle with color I just added a series of segments to “fill” the body of the candle.

The Heikin Ashi version is available here: Higher time frame Heikin Ashi candles on a lower time frame chart

//Higher TF candles by pableitor 2018
// --- settings
// Timeframeminutes = 60
// --- end of settings

defparam calculateonlastbars=3000 //increase this number to get more history
once fcand=1 //flag for first candle in the chart
if fcand=1 then //if first candle in the chart use first open available
 haopen = open
endif
opd= openday

if (openhour = 0) then
 opd = openday + 1
endif

Myminutes = opd*1440 + openhour*60 + openminute  //total minutes since beginning of chart

if (myminutes MOD Timeframeminutes < myminutes[1] MOD Timeframeminutes ) then //new candle
 haopen = open
 hastart = barindex // position of new candle
 //draw candle
 x1=hastart[1]
 x2=barindex[1]
 y1=haopen[1]
 y2=haclose[1]

 DRAWSEGMENT(x1,y1,x2,y1)coloured(r,g,0)
 DRAWSEGMENT(x1,y1,x1,y2)coloured(r,g,0)
 DRAWSEGMENT(x1,y2,x2,y2)coloured(r,g,0)
 DRAWSEGMENT(x2,y1,x2,y2)coloured(r,g,0)

 FOR i = x1 to x2 do
  DRAWSEGMENT(i,y1,i,y2)coloured(r,g,0)
 next
 fcand=0 // reset flag for first candle
endif

haclose=close

r=0
g=200
if haclose<haopen then
 r=200
 g=0
endif
//DRAWCANDLE(haopen,haopen,haclose,haclose) COLOURED(R,G,0,40) BORDERCOLOR(R,G,0,40)
return

 

Download
Filename: Higher-TF-BARS.itf
Downloads: 416
pableitor Master
As an architect of digital worlds, my own description remains a mystery. Think of me as an undeclared variable, existing somewhere in the code.
Author’s Profile

Comments

Logo Logo
Loading...