Percentage Probability of Specific Percentage Market Moves

Forums ProRealTime English forum ProBuilder support Percentage Probability of Specific Percentage Market Moves

  • This topic has 13 replies, 2 voices, and was last updated 2 years ago by avatarBard.
Viewing 14 posts - 1 through 14 (of 14 total)
  • #181953

    Hi,
    I was wondering what the best way would be to code an indicator that will help me determine the percentage frequency of specific percentage market price moves over a fixed period, like 15 trading days (or 3 weeks, which for an option will be 21 days to expiry (DTE)?

    For example, how many 5% moves have there been over a 15 day period in the last 10 years of the Dow Jones? I would like to know the probabilities in percentage terms of that 15 day look back period and the number of times the Dow has exceeded a 5% move so I can determine (based on the past) the likelihood of a similar move occurring now.

    I have seen lots of great indicator on here that can measure breakout percentage/quantities or the number of new highs or lows but was interested in determining specific percentage market moves.

    I’d prefer to take trades where past movements have indicated that there is a 95.4% chance that the target strike price is not reached! This is the objective using an options short Strangle (sell higher strike 38,000 call = bearish and sell lower 34,000 strike put = bullish), basically you want the price to stay in the range, so for example one of the two legs will be a short Put at 34,000 (bullish). If interested please take a look at this discussion on option strike price probabilities and whether strikes will be hit:

    https://www.prorealcode.com/topic/how-to-add-options-probabilities

    I know trader Victor Sperandeo used to keep metrics on the Dow Jones that would enable him to quickly evaluate and compare the health of a current bull move (in length and magnitude) with previous historic bull market runs. I also got a reply from a trader on Quora (pls see quote below), who thinks in similar metrics, having asked him about probabilities that the Dow would reach certain levels. Please see bold below marking the values I’d like to return in an indicator.

    (Referring to the Dow Jones which was then trading at 35,805 that week)
    Over the last 10 years, over three weeks (15 trading days the DJI has dropped farther than -5.1% (your 34,000 option strike) in 4.3% of cases. (My Note: 15 days is the time to expiry for an option on the Dow. Also 1,805 points represents a 5.1% move from the current market price to option Strike price of 34,000).

    It has risen more than 6.1%, your 38,000 strike, in just 2.6% of cases. (My Note: The option position is a Strangle selling short both the Call at 38,000 and the out at 34,000. Options profit is derived if the price stays within the 34,000-38,000 range).

    That’s with 2,755 samples. So history says you have a 92.1% chance of expiring at full profit. (My Notes, I think he meant 93.1% derived from 100% – (4.3%+2.6%))

    HOWEVER, the DJI is currently at an all-time high. In the past 10 years, the max gain 15 trading days after a new high has been 5.3%, so your odds there are (is a) “black swan” (is) remote. And it has dropped worse than -5.1% at 15 days after reaching a peak just 11 times in the past 10 years — 3.25% of the 338 samples.

    What’s the best way to code something similar that allows you to input what ever percentage market move your concerned may occur, ones which you don’t want to reach your strikes and also shows that as a percentage so that it gives you a reading of 4.3% if the .DJI has dropped farther than -5.1% (34,000 strike) for that specific DTE 15 day period?

    Cheers for any input.

    #182130

    There you go:

     

    #182296

    Thanks so much @Robertogozzi,

    I applied the indicator to the Dow for approx. the last 10 years and the tally is 38. That is 38 times the Dow has risen more than 5% in a 15 day period.

    What I’d like to do now is be able to express that tally as a percentage to give an indication of the probability of similar events occurring using 10 years of data:

    Over the last 10 years, over <b>15 trading days</b> the DJI has dropped farther than<b> -5.1%</b> <b>in 4.3% of cases… </b>It has risen more than 6.1% <b>in just 2.6% of cases… </b>And it has dropped worse than -5.1% at 15 days after reaching a peak just 11 times in the past 10 years<b> — 3.25% of the 338 samples.
    </b>

    So we have to know the number of times the event has occurred over the 10 years, tally it and then rank it.

    I’ve attempted to use the rank code from here:
    https://www.prorealcode.com/prorealtime-indicators/atr-percentile-rank/

    I have:<b></b>

    but I’m not sure how to write a statement to define “T” so it can then be used (like ATR was) to deduce its rank?
    And then will that rank of the Tally (nos of times the mkts fallen more than 5% in a 15 day period, for example) express the frequency of “5% moves” as occurring only in “4.3% of cases?” Surely it will just tell you that the frequency of 5% falls as a percentile? Eg Tally = 38 times and that will then be in the — I’m guessing — 99th percentile because the Tally indicator keeps increasing and the last value is the highest compared to all other “records” hit? So, I’m still not quite clear how to get that specific percentage like 4.3%? That maybe because it’s 2.45 in the morning! 😀

    Cheers for any further thoughts,

    Best
    Bard

    #182301

    This should do:

     

    #182315

    I want to point out that in line 6 I set p as the default value for BarStart, but I think that 1 or 0 (no difference among the two) could be a better choice to scan ALL possible big moves, if you want to consider big moves as two, when they occur on consecutive days. If today a big move occurs, what if tomorrow the spike continues its movement? Shall it be considered another separate big move as it’s a different 15-period chunk?

    If yes, then 0 or 1 is the correct value. If, instead, you prefer to count a new big move after some retracement shows, then p, or any value in between(or even greater), could be a better choice.

    You may have p=15 and BarStart=8, if you think 8 periods are enough for a pullback to show.

    As always it’s up to anyone to define the correct values that best suit their attitude.

     

     

    #182350

    Sorry, the above code (my last code posted) is incorrect, as it misses BarInc, the value to determine how often Big Moves have to be tallied. Furtehemore, even the percentage calculation is wrong as n and t need to be swapped:

    In my text-only post any reference to BarStart must be replaced by BarInc.

    #182501

    Hi @Robertogozzi, Thanks very much for the new updated version of code. For some reason my last post didn’t get posted, it should have been just before your last #182350 post above.

    I’d written:


    I understand what you’re saying about whether to consider a two day continuation of a spike as a separate event or not.

    I would regard that as two events in two separate periods of 15 days. I could be trading options on the first Monday of that 3 week period to expiry and there could be a sudden eg, -2% spike down move and then I’ll want to know if I trade again on Tuesday, what is the percentage chance that there is another down move again (which threatens my new Tuesday strikes now with 14 days to expiry (DTE)) and which meets my criteria of trying to assess and avoid a -5.1% down move mentioned by the trader I quoted above. (5.1% because its the Current Dow price minus the Strike Price of the bullish Short Put that gives us that -5.1%).

    Now with 14 DTE, what are the odds in percentage terms of that Tuesdays option trades having Strikes equalling or exceeding that 5.1% move? Applying the Tally and the updated percent and BarInc version, I still am unclear how I can get that figure of 4.3%* (the version before the last gave 2.15% and the current version gives 4640% — Pls see image and question below here).

    (*From the traders comment about how “Over the last 10 years, over 15 trading days the DJI has dropped farther than -5.1% (your 34,000 option strike) in 4.3% of cases).”

    I’m still unsure if I have a 95.4% (2 Std Dev move which is where I have been looking for Strikes) chance of succeeding and using Strikes that are 5.1% from the current price (and also 2 Std Devs from the current Dow price)?

    (Note: When I use Chrome on this Macbook and hit send I get no opportunity to edit my comment. So I used my Safari browser and I get an option to edit a post but now my bold font instructions have been reduced to exposed html code appearing in my comments?)

    Does that make sense?

    Cheers
    Bard


    I was wondering how are n and t now swapped, as they look exactly the same in the last two versions of code?

    I’m not clear how using a 0 or 1 for BarInc in line 6 or a 2 would actually make a binary decision whether to tally consecutively or in chunks of 15 days? I’ve left it set to p (which equals 15) to make it look at each 15 day period. The latest version gives a reading in 4640% though probably because I have misconfigured it although I posted the version above?

    Also, how do we make it assess/calculate for 10 years, or eg the last 5 or 2 years and can it distinguish between up or down moves?

    Lastly, how do we achieve this result?: “In the past 10 years, the max gain 15 trading days after a new high has been 5.3%, so your odds there is a “black swan” is remote. And it has dropped worse than -5.1% at 15 days after reaching a peak just 11 times in the past 10 years — 3.25% of the 338 samples.” I was looking at this indicator and thinking this could calculate this, right?: https://www.prorealcode.com/prorealtime-indicators/break-out-analysis-tool-v3-update/

    because I notice that is has a ‘HighBreakPerc’ and ‘LowBreakPerc’ setting that can be set to display “Percentage above or below highest high to set break level at (+ = above hh and – = below hh).”

    I appreciate the help!

    Best,
    Bard

    #182507

    Hi @Robertogozzi, I’ve been looking into the questions I asked above and looking how to set a specific time period to look back at (like the 10 years in my original post) and I came across this piece of code:

    AnchorDate = 20111126 //Date anchor YYYYMMDD format

    if date=anchordate then
    startbar=barindex
    endif

    lookback = max(1,barindex-startbar)

    I’ve added it to the indicator and it seem to work so I am wondering is that the best way to be able to set a precise lookback period?

    (Note: There’s no Add PRT Code in either Chrome of Safari and if I use the Text instead of Visual editor option I can insert code (using Chrome or Safari) but it attaches html instructions?)

    #182511

    The code for the self-adjusting startbar is a smart solution.

    Testing again the above code, I realized that my post #182350, while correcting an error, contained a new one in the percentage calculation, indeed the first formula was correct:

    n and t shouldn’t have been swapped. My fault.

    1 user thanked author for this post.
    #182544

    Hi @Robertogozzi, thanks for the update, of course, it’s easy to miss.

    Did you get a chance to look at the post prior to my Anchordate post, as there were still questions I don’t quite understand still about the “max gain after a new high” and the BarInc settings? https://www.prorealcode.com/topic/percentage-probability-of-specific-percentage-market-moves/#post-182501

    Cheers,
    Bard

    #182551

    BarInc sets how large a data chunk is (as can be seen from the attached screenshot). 0 or 1 means that ANY 15-period move is tallied, even if adjacent to the previous on (in my pic I outlined 4 occurrences but ALL 15 occurrences would have been tallied), while with a value equal to the periods (or any value in between), that data chunk will report only 1 occurrence, until another 15-period starts.

    I didn’t delve into that indicator, but as I could read from the details posted in the library it seems to do what you want. Did you try it?

     

     

    #182716

    Thanks for taking to the trouble of marking up your image @Robertogozzi. Re: BarInc, I think I’ve got it, if my own image posted below is correct? I wasn’t quite sure about your image with BarInc = 15, so I’ve added both conditions 0,1 and 15 to my image.

    How do I show the difference between negative and positive percent moves/tallies?

    I was also looking at code to write this part: “The max gain 15 trading days <i>after</i> a new high has been  5.3%.” I’ve looked through lots of code here but am still struggling to find the simplest way to code that?

    Cheers again for any insights.

    #182717

    The image didn’t attach. Also lost ability to edit previous post (Safari user) and menu to add PRT code is missing in both Chrome and Safari?

     

     

    #182720

    I didn’t delve into that indicator, but as I could read from the details posted in the library it seems to do what you want. Did you try it?

    Maybe, if I have interpreted it correctly?:

    “Percentage above (or below) highest high to set break level at (+ = above hh and – = below hh).”

    Which I think means you can look for consecutive 15 period chunks where a high of eg 6.1% has been made? Pls see screenshots of indicator first one with the 6.1% gain and -5.1% fall and the second image with high and low percents of 9% and -9%, (which represents — if the Dow is at 34,000 — the distance of a higher short Call, Strike 37,000 and lower short Put, Strike 34,000 in percent from the current price).

    These percent occurrence readings (highlighed in my images) don’t match the veteran traders Dow analysis in my original above.
    For my -5.1% image the result for the percentage of times there is a low breakout (of -5.1%) is 4% (trader stated: 4.3%). Okay.. but for the +6.1% gain I get 0.64% (trader gets 2.6%). Our “Market Health” indicator above gets even more different results?

    Here is yours and Vonasi’s code that I used attached below:

Viewing 14 posts - 1 through 14 (of 14 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login