♥ 0 |
Hey Pete, I found an old scan you had made that would alert when a price crossed a previous day’s close (shown below). Is there a simple way to add a paintingStrategy to also mark an arrow on the chart when this occurs? Thanks for all your hard work! input alertPeriodStart = 0930;
Marked as spam
|
Private answer
First order of business. Whenever you reference another resource online you really must provide a link to that resource. Providing the code is completely useless unless the viewers can see that code within the original context of which it was created. So here is the link to the post where that code was provided: https://www.hahn-tech.com/ans/stocks-crossing-above-previous-day-close-after-1030/ Notice I have updated the title of your question and also moved this out of the Stock Scanners topic and into the Chart Studies topic. The basic premise of your request is how to convert code that functions as a scan into a form that displays as a chart study. More to the point, you wanted to see how to convert the signal from the scan to display as an arrow on the upper price graph. We do not need to use any of the code you included in your question to demonstrate how to do this. I will use my own generic example so the solution can be understood and applied in whatever fashion the rest of our viewers desire. Here is a generic scan. I have selected to build a moving average crossover study. The example is kept as simple as possible to allow viewers to focus on the most important details and not get confused by all the other elements. Three lines of code, the first two define simple moving average of 8 and 21 periods. The third line of code is the scan statement that evaluates to true when the fast sma crosses above the slow sma:
Now I will show how that gets converted to a chart study:
What changes did I make? A. I changed the first two line from def to plot so that we can see the moving averages on the chart. B. I then added two new lines of code. One that sets the plot style to display as an upward facing arrow. Details here: https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/SetPaintingStrategy And I added another that sets the default color of the scan plot. Details here: https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/SetDefaultColor Screenshot below shows the result. Marked as spam
|
Please log in to post questions.