Bollinger band with text display
Posted: Wed Apr 21, 2021 1:13 pm
Hi
Would somebody please help me
I am trying to display text on a Bollinger band such as "TL" for top line whenever the top band is crossed
I would like to display TL above the band and a few candles before the breach but I do not know how to display text on a chart and at a specific period and price
I have 3 global variables that contain:
G_TL_LITERAL, contains the literal as I may want to change it to just "T" depending on what it looks like. I may also want to alter the text type, size and font
G_TL_PRIOR_PRDS contains the number of periods before the current period to start the text display
G_TL_PIP_GAP contains the number of pips above the current price that TL must be displayed at
My code is as follows:
----------------------------------------------------------------------------------
-- Check if the TL is breaching
----------------------------------------------------------------------------------
if source:tick(-1) > TL:tick(-1) and -- The Top Line is being breached
G_TL_DISPLAYED ~= period then -- and not yet displayed this candle
G_TL_DISPLAYED = period; -- Set the "displayed" indicator for this candle
--------------------------------------------------------------------------------
-- calculate the position to display the literal and display it
--------------------------------------------------------------------------------
end
As I understand it:
1. the period to start the display should be "period - G_TL_PRIOR_PRDS" and
2. the price to display it at should be "source:tick(-1) + (G_TL_PIP_GAP/10000)"
but after that I am stuck
Assistance would be greatly appreciated
Would somebody please help me
I am trying to display text on a Bollinger band such as "TL" for top line whenever the top band is crossed
I would like to display TL above the band and a few candles before the breach but I do not know how to display text on a chart and at a specific period and price
I have 3 global variables that contain:
G_TL_LITERAL, contains the literal as I may want to change it to just "T" depending on what it looks like. I may also want to alter the text type, size and font
G_TL_PRIOR_PRDS contains the number of periods before the current period to start the text display
G_TL_PIP_GAP contains the number of pips above the current price that TL must be displayed at
My code is as follows:
----------------------------------------------------------------------------------
-- Check if the TL is breaching
----------------------------------------------------------------------------------
if source:tick(-1) > TL:tick(-1) and -- The Top Line is being breached
G_TL_DISPLAYED ~= period then -- and not yet displayed this candle
G_TL_DISPLAYED = period; -- Set the "displayed" indicator for this candle
--------------------------------------------------------------------------------
-- calculate the position to display the literal and display it
--------------------------------------------------------------------------------
end
As I understand it:
1. the period to start the display should be "period - G_TL_PRIOR_PRDS" and
2. the price to display it at should be "source:tick(-1) + (G_TL_PIP_GAP/10000)"
but after that I am stuck
Assistance would be greatly appreciated