Greetings!
I'm trying to find out if there's a way to add a custom column in the "position statement" on the Monitor tab under "activity and Positions" section.
I would like to get some kind of visual indicator of earnings in next 3 days. I know ToS has the built in icons that show that, but I want something more obvious
I want to create a column that shows a colored background, Orange or red along with days to earnings
I have this so far, but I'm not getting it to show the background color:
for reference, I have this daily squeeze column that i had downloaded some time ago, it perfectly shows the coloem background color and value
can anyone please guide me?
I'm trying to find out if there's a way to add a custom column in the "position statement" on the Monitor tab under "activity and Positions" section.
I would like to get some kind of visual indicator of earnings in next 3 days. I know ToS has the built in icons that show that, but I want something more obvious
I want to create a column that shows a colored background, Orange or red along with days to earnings
I have this so far, but I'm not getting it to show the background color:
Code:
declare lower;
def offset = GetEventOffset(Events.EARNINGS, 0);
def hasEarnings = !IsNaN(offset) && offset <= 0;
def daysToEarnings = if hasEarnings then -offset else 0;
def isBefore = if hasEarnings then HasEarnings(EarningTime.BEFORE_MARKET) else no;
def isAfter = if hasEarnings then HasEarnings(EarningTime.AFTER_MARKET) else no;
def earnHourOffset = if isBefore then -1.0 else if isAfter then 6.5 else 0.0;
def earnBarTimeMs = if hasEarnings then GetValue(GetTime(), offset) else Double.NaN;
def earningsTimeMs = earnBarTimeMs + earnHourOffset * 3600000;
def nowMs = GetTime() + SecondsFromTime(0930) * 1000;
def hoursToEarnings = (earningsTimeMs - nowMs) / 3600000;
plot signal = if hasEarnings then daysToEarnings else 0;
signal.AssignValueColor(Color.WHITE);
AssignBackgroundColor(
if hasEarnings && hoursToEarnings > 0 && hoursToEarnings <= 48 then Color.RED
else if hasEarnings && daysToEarnings <= 5 then CreateColor(255, 165, 0)
else Color.CURRENT
);
for reference, I have this daily squeeze column that i had downloaded some time ago, it perfectly shows the coloem background color and value
Code:
input BollingerDeviations = 2.0; input BollingerLength = 20.0; input KeltnerFactor = 1.5; input KeltnerLength = 20; input price = close; def bk = reference BollingerBands("num_dev_up" = BollingerDeviations, "length" = BollingerLength )."upperband" - reference KeltnerChannels("factor" = KeltnerFactor, "length" = KeltnerLength)."Upper_Band"; def grnconsecdots = if bk[0] > 0 and bk[1] > 0 and bk[2] > 0 and bk[3] > 0 and bk[4] > 0 and bk[5] > 0 and bk[6] > 0 then 7 else if bk[0] > 0 and bk[1] > 0 and bk[2] > 0 and bk[3] > 0 and bk[4] > 0 and bk[5] > 0 then 6 else if bk[0] > 0 and bk[1] > 0 and bk[2] > 0 and bk[3] > 0 and bk[4] > 0 then 5 else if bk[0] > 0 and bk[1] > 0 and bk[2] > 0 and bk[3] > 0 then 4 else if bk[0] > 0 and bk[1] > 0 and bk[2] > 0 then 3 else if bk[0] > 0 and bk[1] > 0 then 2 else if bk[0] > 0 then 1 else 0; def redconsecdots = if bk[0] < 0 and bk[1] < 0 and bk[2] < 0 then 3 else if bk[0] < 0 and bk[1] < 0 then 2 else if bk[0] < 0 then 1 else 0; plot signal = if grnconsecdots > 0 then grnconsecdots else redconsecdots + 10; signal.AssignValueColor (Color.BLACK); AssignBackgroundColor( if bk[0] < 0 then Color.RED else if grnconsecdots < 7 then Color.GREEN else Color.BLACK);
can anyone please guide me?