TNTOutburst
New member
I'm trying to make a study that tells me what percent of the time since the market last opened that a stock was increasing.
I made this code, but it just uses the last 300 bars.
I found this code which tells me the number of bars since the market opened but I get a "Only constants expected here" when I put it in the Sum().
Is there a way to get the number of bars since the market opened another way?
Code:
def pos = (Average(close, 8) / Average(close, 8)[6]) > 1;
def neg = (Average(close, 8) / Average(close, 8)[6]) < 1;
def percent = Sum(pos, 300) / (Sum(pos, 300) + Sum(neg, 300));
Code:
def condition = if SecondsFromTime(0930) == 0 && SecondsTillTime(0930) == 0 then barNumber() else 0;
def StartBar = condition;
def StartBarOpen = if barNumber() == StartBar then 1 else StartBarOpen[1]+1;
plot count = StartBarOpen;
Is there a way to get the number of bars since the market opened another way?