Multiple timeframe ribbons on one chart

#1
I have attached the .afl code for a trading system I located on another website. How can I convert the "minute" timeframes to Range bars?

I have been working on trying to do this for months, but have not
been successful.

Ultimately, I would like to create "ribbons" at the bottom of the chart
that show when each timeframe (range bar timeframe) are in
agreement. It has been done in the attached .afl, but it is
in minutes and I would like to convert it to range bars.

If someone could help me with converting the code from
minutes to range bars, then I think I can use that code to
trigger alerts using other indicators....at least that is my
goal.

If someone could assist me, I would greatly appreciate it.

Thank you,
Ev
 
#2
brevco,

Although, I am not an afl expert, and thus may not be able to help you, I am curious to know what are range bars and how do they help in bettering the chart presentation? PLease give more details at least to understand your requirements. If you have any chart based on range bars, your enclosing the chart would be appreciated.

Regards.
 
#3
Hello,

When you set the "range", then you know in advance exactly how many points or "ticks" it needs to move before the next candle (or "range bar") forms. I went to google and typed in "range bars" and came up with the following explanation from the Stocks and Commodities website that I beleive will help.

Range bars are a unique way of building price charts and are excellent in finding the underlying trend and movement of the current bar. Since each bar on the chart has the same range (high to low), it reduces the volatility and noise within the range of the bar.

Range bars are generated continuously as a new tick is formed outside the minimum price range. They are closely related to point & figure or renko charts, which are also based on equal price range change. The range bar chart is a study of pure price movement, and time is not taken into consideration while plotting the price action. Range bar movement is not time-dependent but does depend on price movement when a preset range of a price bar is complete; hence, the time axis (x-axis) on a range bar chart is irrelevant.

When range bars are constructed, chart dependency on the time scale (x-axis) has been removed as it produces its own price scale on the y-axis. This helps remove gaps and produce clear levels of support & resistance. Range bars also work with other trend indicators, all instruments, and all time frame trading. Range bar charts are great for observing active market activity and are helpful in identifying support & resistance lines, buy/sell signals, and trendlines.

I currently use range bars to trade with the CCI.

I hope this helps.

Just this morning, I found something very similar to what I am looking for that someone posted on another website. It was written for the MT4 trading platform and someone converted it to AFL for Amibroker. When I put it on my range bar chart I received an error. The chart needs to be set in minutes. So, I would still need to figure out how to convert it to range bars.

I've attached the file in a word document so it can be cut and pasted into your formula window of Amibroker.

If anyone can figure out how to convert this to range bars, I would be very grateful.

Thank you,

Evelyn
 
#4
Hello,

I tried to attach a screenshot of a range bar chart, and evidently, the file exceeds the limit allowed for this forum. :(

I'm sure a screenshot could be found through searching Google.

Evelyn
 

kenneth

Well-Known Member
#5
Hi Brevco
Chadrakant has written one for EOD too
/ Define label bar (x) position location
#pragma nocache
blankRightBars = 5; //insert actual blank right bars specified in Preferences
barsInView = Status("lastvisiblebarindex") - Status("firstvisiblebarindex") - blankRightBars;
Offset = Param("Offset Bar", 0.95, 0, 1, 0.01);
textOffset = BarCount - (Offset * barsInView);


TimeFrameSet( inDaily) ;
HaClose =EMA((O+H+L+C)/4,3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
X=Haopen<Ref( Haopen,-1) OR AlmostEqual( Haopen,Ref(Haopen,-1));
Color = IIf( Haopen > Haclose, colorRed, IIf( X,7,14));
Plot(20,"", Color,styleHistogram|styleOwnScale|styleNoLabel, 0, 100 );
Plot( 21,"",colorBlack,styleOwnScale|styleArea|styleNoLabel,0, 100 );
PlotText("DAILY TREND", textoffset, 81.05, colorWhite);
CondB=Haopen > Haclose;CONDS=Haopen < Haclose;
event1=condS;
PlotShapes( IIf(event1 ,shapeDigit1,0) ,5, 0,81.0);
event2=CondB;
PlotShapes( IIf(event2 ,shapeDigit1,0) , 4, 0,81.0);



TimeFrameRestore();
TimeFrameSet( inWeekly) ;
HaClose =EMA((O+H+L+C)/4,3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
X=Haopen<Ref( Haopen,-1) OR AlmostEqual( Haopen,Ref(Haopen,-1));
Color = IIf( Haopen > Haclose, colorRed, IIf( X,7,14));
Plot(40,"", Color, styleHistogram|styleOwnScale|styleNoLabel, 0, 100 );
Plot( 41,"",colorBlack,styleOwnScale|styleArea|styleNoLabel,0, 100 );
PlotText(" WEEKLY TREND", textoffset, 81.20, colorWhite);
CondB1=Haopen > Haclose;CONDS1=Haopen < Haclose;
event3=condS1;
PlotShapes( IIf(event3 ,shapeDigit2,0) ,5, 0,81.20);
event4=CondB1;
PlotShapes( IIf(event4 ,shapeDigit2,0) , 4, 0,81.2);


TimeFrameRestore();
TimeFrameSet( 10*inDaily) ;
HaClose =EMA((O+H+L+C)/4,3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
X=Haopen<Ref( Haopen,-1) OR AlmostEqual( Haopen,Ref(Haopen,-1));
Color2 = IIf( Haopen > Haclose, colorRed, IIf( X,7,14));
Plot(60,"", Color2, styleHistogram|styleOwnScale|styleNoLabel, 0, 100 );
Plot( 61,"",colorBlack,styleOwnScale|styleArea|styleNoLabel,0, 100 );
PlotText("2 WEEK TREND", textoffset, 81.40, colorWhite);
CondB2=Haopen > Haclose;CONDS2=Haopen < Haclose;
event4=condS2;
PlotShapes( IIf(event4 ,shapeDigit3,0) ,5, 0,81.40);
event5=CondB2;
PlotShapes( IIf(event5 ,shapeDigit3,0) , 4, 0,81.4);


TimeFrameRestore();
TimeFrameSet(20*inDaily) ;
HaClose =EMA((O+H+L+C)/4,3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
X=Haopen<Ref( Haopen,-1) OR AlmostEqual( Haopen,Ref(Haopen,-1));
Color4 = IIf( Haopen > Haclose, colorRed, IIf( X,7,14));
Plot(80,"", Color4, styleHistogram|styleOwnScale|styleNoLabel, 0, 100 );
Plot( 81,"",colorBlack,styleOwnScale|styleArea|styleNoLabel,0, 100 );
PlotText("MONTHLY TREND", textoffset, 81.55, colorWhite);
CondB3=Haopen > Haclose;CONDS3=Haopen < Haclose;
event6=condS3;
PlotShapes( IIf(event6 ,shapeDigit4,0) ,5, 0,81.65);
event7=CondB3;
PlotShapes( IIf(event7 ,shapeDigit4,0) , 4, 0,81.65);

TimeFrameRestore();
Sell=CondB AND CondB1 AND CondB2 OR Condb3;
Buy= CondS AND CondS1 AND CondS2 OR Conds3;
//Cover= Cond1 AND Cond2 OR Cond2 AND Cond3 OR Cond1 AND Cond3 ;
//Sell= Cond4 AND Cond5 OR Cond5 AND Cond6 OR Cond4 AND Cond6;
Buy=ExRem (Buy,Sell);Sell=ExRem(Sell,Buy);
PlotShapes(shapeCircle*Buy, colorGreen,0,81.85);
PlotShapes(shapeCircle*Sell, colorRed,0,81.85);
GraphXSpace = 15;

//......................................
_SECTION_END();
Regards
ken
 
#7
Thank you, Kenneth.

Since I trade intraday, it would be great to have this for
range bars. This is definitely heading in the right direction
and it is probably the closest I've gotten to finding what I've
been searching for.

I can probably figure out how to convert this to minute
bars so it can be traded intraday, but I am still searching
for a way to convert it to range bars. This is beautiful
though. :)

I think this would be great to use for longer term
such as trading options....hopefully I'll get back into
that again soon.

Thanks again for responding and sharing this with me. I'm
getting closer!

:) Evelyn
 

kenneth

Well-Known Member
#9
Hi Evelyn,

Is there any progress or any development on multiple time frame ribbon. I think there is an error if you see today's Nifty. I hope you are reading Traderji and have seen the new AFL for the multiple TF

Regards
Ken
 

karthikmarar

Well-Known Member
#10
in AB the time scale is fixed. creating range bars means you have to have a chart with different time scale compression for each bar. This is not possible in AB. I think the only thing we can do is to have an exploration to create the bar data with time stamp and export this data to excel for creating a chart.
 

Similar threads