Plot highs on daily for 5 highest volume candles


Category:
0
0

Hi Pete! I’m trying to create a script where I want to plot the highs of the 5 highest volume candles with an added constraint that the prices should be incrementally higher.

By that I mean, if I take the highest volume candle just to the left of today with high P1, then I’m looking for the next one P2 where P2 > P1, then P3 > P2, P4 > P3 and P5 > P4. By extension, these may not end up being the highest volume candles (as they may fall between these candles with lower prices) but it is an added constraint.

It shouldn’t be a lot of code but there are things programmatically that I’m unfamiliar with for thinkscript:
-how to store two arrays of volume and prices
-how to find a position within an array that meets a condition
-how to zero out certain positions in the array if they don’t meet the price constraint

Thanks again for all your help Pete!

Marked as spam
Posted by (Questions: 3, Answers: 11)
Asked on May 29, 2020 5:02 am
102 views
0
Private answer

The solution may be possible on Thinkorswim. But it is well beyond the scope of any solution I can provide in the time I permit for free solutions in the Q&A forum. This solution is not simple at all, firstly because we are dealing with a scripting language. But more specifically because it is one that lacks any method to build and work with custom sized arrays. So the following portions of your request are supported by many other languages. But not the one we have to work with in Thinkorswim:

-how to store two arrays of volume and prices
-how to find a position within an array that meets a condition
-how to zero out certain positions in the array if they don’t meet the price constraint

So for those coming from more formal programing languages this becomes a real challenge. You need to learn to work with the arrays as they exist in Thinkorswim in order to conquer this one. In your description you described a process of working from current bar backward. You can use a "fold" statement to loop backwards through the chart. The "fold" statement is Thinkorswim's feeble attempt to provide some very limited functionality of a For/Loop structure. However for me, (I truly hate to work with that stupid 'fold' statement), I find it easier to build the code reading from left to right.

Sorry, that's all I can offer in the brief amount of time I have to provide solutions here.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 29, 2020 7:56 am