percent up or down in a specified period of time


0
0

Hey, I am trying to do condition wizard or chart studies that show periods in a chart where the stock changed by a percentage in a given period. I contributed 10 dollars. I am a rookie with think or swim so I’ll try to explain as best I can what I am looking for. I linked a similar condition wizard scenario where you did a video of a scan or study where you put in code to look for three consecutive days (candlestick) with daily 2% gain.

I listed three examples.

1 – 1yr 1day chart

  • I want to show the periods where the stock went up by 10% in a 5 day stretch

2 – 1day 1min chart

  • show the periods throughout the day where the stock rose by at least 3% (whether it happened over a 5 min span or 30min or whenever)

3 – 1 yr 1 day chart

  • show the days where the asking price rose over 10% from open.
Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on August 1, 2022 4:32 pm
128 views
0
Private answer

You left out some of the most important details. The rest of our viewers will be frustrated that you did not provide a link to the video you mentioned in your question. So I will provide that link here:

https://www.hahn-tech.com/thinkorswim-condition-wizard/

And here is a link to the previous Q&A Forum post from which the example in that video was taken:

https://www.hahn-tech.com/ans/scan-for-three-consecutive-days-of-two-percent-daily-gain/

You posted this question in the "Alerts and Notifications" topic. However in your question you requested "...chart studies that show...". However the context of the question is dictated by the topic in which you posted the question. So this solution is for a custom scan or study alert. You can plot this as a lower study if you like. Or you can add it to a custom watchlist column.

I have included user inputs to make this solution adjustable. You can select the number of bars and the percent threshold (use negative values for down trending price action). I even included two user inputs allowing users to chose which price to use for the percent change computation (another important details you omitted).

input numberOfBars = 5;
input percentThreshold = 10.0;
input startingPrice = close;
input endingPrice = close;
def percentChangeOverBars = 100 * (endingPrice / startingPrice[numberOfBars] - 1);
plot signal = percentChangeOverBars > percentThreshold;

Notice the code does not have any elements which determine the time frame selected. It simply measures the number of bars. So you can adjust the time frame and user inputs to suit each of your three examples.

If you had provided current screenshots showing examples of these price patterns I would have also included screenshots showing how this solution would detect those patterns.

Marked as spam
Posted by (Questions: 37, Answers: 4116)
Answered on August 1, 2022 9:25 pm