Lower close after 3 consecutive higher closes


Category:
0
0

Hello Peter,

I need help with my scan. I want at least a minimum of 3 consecutive prices close above le previous price condition. And my scan responds when the price clove below the previous close. I think this will require a while loop. With the wizard, I see you have explained only the offset option which is for the for loop.

Marked as spam
Posted by (Questions: 16, Answers: 12)
Asked on April 9, 2023 2:46 am
100 views
0
Private answer

The Condition Wizard does not support looping structures. If you wanted to build this sort of scan using the condition wizard you would need to add four separate conditions. The screenshot below shows how to build it using the condition wizard. The result is the following line of code:

close from 3 bars ago is greater than close from 4 bars ago and close from 2 bars ago is greater than close from 3 bars ago and close from 1 bars ago is greater than close from 2 bars ago and close is less than close from 1 bars ago

But I find it much easier to just write it out in the following way:

input consecutiveBars = 3;
def higherCloses = Sum(close > close[1], consecutiveBars) >= consecutiveBars;
plot scan = higherCloses[1] and close < close[1];

Notice the second solution is much easier to read and it also includes a user input so you can adjust the number of consecutive higher closes required in the pattern. And it does not include any looping structures.

FYI, looping structures are very rarely required in any solution for Thinkorswim. Which is a good thing, because the looping structure provided by Thinkorswim is utterly miserable to use.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on April 9, 2023 10:21 am
0
Pete, To apply your second solution to the volume. What can I change close and higercloses variable to?
( at September 17, 2023 11:39 am)
0
My best suggestion is that you just built it yourself using the Condition Wizard. As shown in the screenshot I included with my solution. Just replace the word "close" with "volume" everywhere that it occurs in each of those four conditions. I assure you, if you take the time to learn how to use the Condition Wizard it will open up doors you never knew where even there: https://www.hahn-tech.com/thinkorswim-condition-wizard/
( at September 17, 2023 12:10 pm)
0
I take you advice seriously. I have learn a lot from you Pete.
( at September 17, 2023 1:11 pm)