AFL to show High and Low price of candles

shanki99

Well-Known Member
#1
Can someone plz help me with an AFL to get a label on top and Bottom of each candle specifying the High and Low price of the same? Just the last 2 digits with 1 decimal point is enough (bcos of space constraints)

Like as shown in the picture...


This wud be really helpful for scalpers where speed is money....

Thanx in advance
 

asnavale

Well-Known Member
#2
Can someone plz help me with an AFL to get a label on top and Bottom of each candle specifying the High and Low price of the same? Just the last 2 digits with 1 decimal point is enough (bcos of space constraints)


This wud be really helpful for scalpers where speed is money....

Thanx in advance
Hi Shanki99,

Try the following code:

// **********************************************
SetChartBkColor(colorBlack);
SetChartOptions(0, chartShowDates | chartWrapTitle);

PlotOHLC(O, H, L, C, "Close", colorLightGrey, styleCandle | styleNoLabel);

for(i = 0; i<BarCount; i++)
{
PlotText(StrRight(NumToStr(H, 1.2), 5), i, H, colorGreen);
PlotText(StrRight(NumToStr(L, 1.2), 5), i, 0.998 * L, colorRed);
}



// **********************************************

The High and Low of each candle are labelled with last two digits and two decimals.


The out put from the above code is shown in the image below:







-Anant
 

bunny

Well-Known Member
#3
// **********************************************
SetChartBkColor(colorBlack);
SetChartOptions(0, chartShowDates | chartWrapTitle);

PlotOHLC(O, H, L, C, "Close", colorLightGrey, styleCandle | styleNoLabel);

for(i = 0; i<BarCount; i++)
{
PlotText(StrRight(NumToStr(H, 1.2), 5), i, H, colorGreen);
PlotText(StrRight(NumToStr(L, 1.2), 5), i, 0.998 * L, colorRed);
}



// **********************************************

The High and Low of each candle are labelled with last two digits and two decimals.


...

-Anant


:clapping:
 

columbus

Well-Known Member
#5

shanki99

Well-Known Member
#8
no speed slowdown for me...

Really good afl
Also, where do we need to make changes to move the high value , say, few pixels higher? because the lows are a few pixels away, but the value ofr highs is spoiled by the wicks... and wicks are needed :)
I slightly tinkered the code as below...i also changed the Font as Arial Narrow so the numbers shows up nicely



SetChartBkColor(colorWhite);
SetChartOptions(0, chartShowDates | chartWrapTitle);

PlotOHLC(O, H, L, C, "Close", colorLightGrey, styleCandle | styleNoLabel);

for(i = 0; i<BarCount; i++)
{
PlotText(StrRight(NumToStr(H, 0.1), 4), i, H+3, colorDarkGreen);
PlotText(StrRight(NumToStr(L, 0.1), 4), i, L-3, colorRed);
}
 

asnavale

Well-Known Member
#10
Anantji

Btw how to make this code to show only the last 5 or 10 candle's Hi Lo values??

too many numbers in the chart :))
To show the labels on last few candles, change the For loop. For example, to show on last 10 candles, make it as follows:

for(i = BarCount -10; i < BarCount; i++)

No changes to any other lines.

-Anant