Swing relations code for amibroker

#1
Hey guys, I am really new to amibroker and I am moving from another software that had a swing relations color coding built into it. However I need to make a change as this program is costing too much.

I was wondering if anyone could help with this color coding?
I need to base the color coding on the previous and current day high/low.

On a bar chart;

if high is higher than previous candle and low is higher than previous candle (color green)

if high is lower than previous candle and low is lower than previous candle (color red)

if high is lower than previous candle and low is higher than previous candle (inside bar: color the same color as previous bar)

if high is higher than the previous candle and low is lower than the previous candle (outside bar: color blue)


So yeah if anyone can help with this code it would be very much appreciated.
 
#2
Hey guys, I am really new to amibroker and I am moving from another software that had a swing relations color coding built into it. However I need to make a change as this program is costing too much.

I was wondering if anyone could help with this color coding?
I need to base the color coding on the previous and current day high/low.

On a bar chart;

if high is higher than previous candle and low is higher than previous candle (color green)

if high is lower than previous candle and low is lower than previous candle (color red)

if high is lower than previous candle and low is higher than previous candle (inside bar: color the same color as previous bar)

if high is higher than the previous candle and low is lower than the previous candle (outside bar: color blue)


So yeah if anyone can help with this code it would be very much appreciated.
Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
BarCol = IIf(H > Ref(H,-1) AND L > Ref(L,-1), colorGreen, IIf(H < Ref(H,-1) AND L < Ref(L,-1), colorRed,
		IIf(H > Ref(H,-1) AND L < Ref(L,-1), colorBlue, IIf(H < Ref(H,-1) AND L > Ref(L,-1), colorLightGrey,colorLightGrey))));
BarCol = IIf(BarCol == colorLightGrey, Ref(BarCol,-1), BarCol);
Plot( C, "Close", BarCol, styleBar ); 
_SECTION_END();

Happy :)
 
#3
That was allot easier and faster than I thought it was going to be lol.. thankyou so much!!! When I applied it to my chart it worked great!! I tried to edit the code a little bit to include;

if the low is equal and the high is higher color green and
if the low is lower and the high is equal color red and
if low is equal and high is equal color same as previous

but i keep getting errors any chance you maybe able to help again?
 

Similar threads