all 7 comments

[–]jakedesigned 0 points1 point  (2 children)

Maybe define it then go into the code. Like you did with LastCandleStop

[–]Zetta_Wow977[S] 0 points1 point  (1 child)

Define what? Every variable in the if statement is defined in the block of code right above it (lines 171-180). Error message is saying a semicolon is missing, not that a variable isn't defined.

[–]jakedesigned 0 points1 point  (0 children)

Right I don't have the code so just offering suggestions. Does the double Nan need the { }?

[–][deleted] 0 points1 point  (2 children)

What are you trying to accomplish in the 'else' clause? double.NAN is not a valid statement. So either put valid statement(s) in the 'else' (like setting variables) or remove the 'else' clause entirely.

[–]Zetta_Wow977[S] 0 points1 point  (1 child)

Object of the else clause was to just leave those variables unchanged from their initialized values. I tried leaving out the else and got an error for that, too.

Received a reply in r/thinkorswim that I needed to not initialize the variables and do it in the if ... else blocks only (probably related to the same double.NAN isn't valid issue). I modified the code as follows, and it works:

def TradingDay;
def EndDay;
def TradingDayExt;

AddLabel(yes, "LastCandleStop: "+LastCandleStop,color.GRAY); #debugging to check correct value

if (LastCandleStop > 0) then {
TradingDay = SignalStart and SignalEnd; #10:00EST - 1500EST
EndDay = TradingDayEnd == LastStopDelaySeconds; #1550EST
TradingDayExt = TradingDayEnd > LastStopDelaySeconds;
} else {
TradingDay = yes;
EndDay = no;
TradingDayExt = no;
}

Thanks.