Help with coloring the first bar of this indicator correctly...

J

Jenz56

New member
It's been a while since I did much think-scripting, and I'm having a little trouble getting the first bar to behave the way that I'd like it to.

Anyway, this is a Cumulative $Tick Counter that I'm working on. I'd like the first bar to start out yellow if it's negative and magenta if it's positive.

I know that I've got some other refinements to do as well (e.g. it's only set to work on a 15 min chart)

Any help/suggestions are greatly appreciated!


------------
Code:
declare lower;

def newDay = GetDay() != GetDay()[1];
def tickData = hlc3(symbol="$TICK");
def openTime = 930;
def closeTime = 1600;

def firstBarOfDay = if SecondsTillTime(openTime) < 0 and SecondsfromTime(openTime) == 900 then 1 else 0;

def cumulativeTickCount = if SecondsTillTime(openTime) < 0 and SecondsTillTime(closeTime) > 0 then tickData + cumulativeTickCount[1] else 0;

plot cumulativeTickPlot = if cumulativeTickCount != 0 then cumulativeTickCount else Double.nan;
cumulativeTickPlot.setPaintingStrategy(PaintingStrategy.Histogram);

cumulativeTickPlot.AssignValueColor(if firstBarOfDay then color.green else if cumulativeTickPlot > cumulativeTickPlot[1] then color.magenta else color.yellow);

AddVerticalLine(newDay, "New Day", color.gray, curve.Short_Dash);
 

Similar threads

Top