♥ 0 |
Hi guys
Marked as spam
|
Private answer
Based on feedback from Hanan Marco I have revised the code to include a user input for the start date. The previous version did not include a start date and the “prefetch” of historical data was making it impossible to test the code for proper computations. What’s prefetch? http://toslc.thinkorswim.com/center/howToTos/tutorials/Advanced/Chapter-12—Past-Offset-and-Prefetch.html I have included a screenshot along with the code. In the screenshot you can see the start point and I have marked the first two crossing AFTER the start point with red arrows. Four bars after the first crossing we see the lower plot begin to display a value. The value matches the range displayed via the Magenta colored vertical lines covering the four bars after the first crossing. You can also see that for bars after the second crossing, the lower plot is adjusted to account for both the first and second crossings. Note: In order for the start point to plot, the startDate input must be set to a day the markets were open.
If this new answer properly addresses the initial request please be sure to give this answer an up-vote. This will cause this answer to sort to the top of the listings so it is the first answer other viewers will see. Marked as spam
|
|||||
Private answer
Well there is still a lot of details missing. I have to make several assumptions so you will need to provide additional details after you work with the code. What I do here is not restricted to one year. You will control that by plotting one year of daily bars on your chart. The values are measured for all bars on the chart. So we count each crossing and keep a running total. Then we check each bar to see if there was a crossing 4 bars ago. When we find a crossing 4 bars ago we get the highest high in 4 bars and subtract the lowest low in 4 bars. This is the purest interpretation of the “price range” as you described it. We then compute the total sum of all occurrences on the chart and use that to compute the average post crossing “price range”. This code only computes the cross above. In order to do cross below you will need to replicate some lines of code and modify them to track the other side. Here is the code. Screenshot below shows what it looks like on a chart.
Marked as spam
|
|||||
Private answer
Hi First of all, thank you very much for the help and the code, it is not obvious and I thank you.
Marked as spam
|
Please log in to post questions.
Yes!
this answer properly addresses the initial request .
I learned so much from this thread
Thank you !