Session high for Conditional Order script


Hey Pete! I was having trouble posting this, so I’m not certain if this is the right section. From your videos, I know recursion is a no-no for Thinkorswim’s custom code order conditions. Is there any way to reference today’s high of the day without using recursion? It has to be done using the “1-minute” chart setting. You’re the best!

Marked as spam
Posted by (Questions: 5, Answers: 1)
Asked on March 26, 2024 12:33 pm
Private answer

I moved your question out of the "Watch Lists" topic and into the "Strategy Guide" topic because this is where we discuss items related to the Conditional Order tool on Thinkorswim. I also updated the title of your question to better describe the context of your request and the solution I am providing. This should make it easier for other visitors to locate this solution using the search function.

Yes, there is a way to write a script to read the highest high of the current session without using recursive variables. It's a pretty nifty trick, which I leaned from one of the Thinkorswim support staff.

Here it is:

def currentDay = GetDay() == GetLastDay();
plot highOfSession = HighestAll(if currentDay then high else Double.NaN);

You can replace the plot with def if you want to use that value elsewhere in your script. It only works for the current session. And this technique may also work for the session low. (In which case you would replace HighestAll with LowestAll and replace high with low).

With further modifications, it may even be used to capture the session open. But that would require the application of another trick to make that work.

def currentDay = GetDay() == GetLastDay();
def newDay = GetDay() <> GetDay()[1];
plot sessionOpen = HighestAll(if newDay and currentDay then open else Double.NaN);

So there we have solutions to read the current session's high, low and open. Each without using recursive variables.

Marked as spam
Posted by (Questions: 37, Answers: 4097)
Answered on March 26, 2024 12:48 pm
Wow!! That’s awesome Pete. Thanks for sharing!
( at March 26, 2024 10:03 pm)