# Plot text : show percentage of Daily Open-Close compared to avg. Also display "Large" when > 85%

I Am trying to work out some basic code (i'm guessing it is for someone).
I want to compare the selected bar abs open-close to the average of the previous 10. I wanted to display this as a percentage on the chart, I also want the word "large" to show below it when its above 85%. I think i have most of it nutted out. Just struggling with the last part.

Hope someone can help!

Cheers.

``````AOCR = (abs(Ref(Open,-1)- Ref(Close, -1)) + abs(Ref(Open,-2)- Ref(Close, -2)) + abs(Ref(Open,-3)- Ref(Close, -3)) + abs(Ref(Open,-4)- Ref(Close, -4)) + abs(Ref(Open,-5)- Ref(Close, -5)) + abs(Ref(Open,-6)- Ref(Close, -6)) + abs(Ref(Open,-7)- Ref(Close, -7)) + abs(Ref(Open,-8)- Ref(Close, -8)) + abs(Ref(Open,-9)- Ref(Close, -9)) + abs(Ref(Open,-10)- Ref(Close, -10)))/10 ;

LARGE= abs(Open - Close) > (0.85 *AOCR);
SMALL = abs (Open - Close) <= (0.85 * AOCR);
DOCR = (abs(Open - Close) / AOCR)*100 ;

GfxSetTextColor(colorBlueGrey);
GfxSelectFont("Times New Roman", 20, 700, True );
GfxTextOut(NumToStr( DOC) + "% of Daily Open Close Avg", 15 , 30 );

GfxSetTextColor(colorBlueGrey);
GfxSelectFont("Times New Roman", 20, 700, True );
IIf(LARGE == 1,GfxTextOut("LARGE", 15 , 60 ),Null);
``````

You need to understand the difference between IIf function and if statement. Also read here.

``````AOCR = (abs(Ref(Open,-1)- Ref(Close, -1)) + abs(Ref(Open,-2)- Ref(Close, -2)) + abs(Ref(Open,-3)- Ref(Close, -3)) + abs(Ref(Open,-4)- Ref(Close, -4)) + abs(Ref(Open,-5)- Ref(Close, -5)) + abs(Ref(Open,-6)- Ref(Close, -6)) + abs(Ref(Open,-7)- Ref(Close, -7)) + abs(Ref(Open,-8)- Ref(Close, -8)) + abs(Ref(Open,-9)- Ref(Close, -9)) + abs(Ref(Open,-10)- Ref(Close, -10)))/10 ;

LARGE= abs(Open - Close) > (0.85 *AOCR);
SMALL = abs (Open - Close) <= (0.85 * AOCR);
DOCR = (abs(Open - Close) / AOCR)*100 ;

GfxSetTextColor(colorBlueGrey);
GfxSelectFont("Times New Roman", 20, 700, True );
GfxTextOut(NumToStr( DOCR) + "% of Daily Open Close Avg", 15 , 30 );

GfxSetTextColor(colorBlueGrey);
GfxSelectFont("Times New Roman", 20, 700, True );
If(SelectedValue(LARGE) == 1)
GfxTextOut("LARGE", 15 , 60 );
``````
1 Like