TradingView
bmistiaen
27 דצמ׳ 2021 16:19

[BM] SSS 50% Rule Evaluator 

Microsoft CorporationNASDAQ

תיאור

Sara Strat Sniper 50% Rule Evaluator


█ OVERVIEW

This indicator is based on Sara Strat Sniper's - 50% Rule for trading Outside Bars and helps you to evaluate the historical success rate of that rule.


█ FEATURES

Calculation
• You can choose to evaluate only the current bar to see if it forms an outside bar (success) or not (fail), but you can also choose to include the next bar to see if that one forms a compound outside bar.
• You can enable a start and/or end date to limit the calculation period.

Table
• Show or hide the table with the calculation results.
• Show or hide the calculation details (up/down data).
• Position of the table, opacity, cell width and text size can be customized.

Colors
• Table colors can be customized.
• You can choose to show the inside/outside bars in customizable bar colors.
• You can choose to identify successful/failed/recovered outside bars in customizable background colors.


█ LIMITATIONS

• This script uses a special characteristic of the `security()` function allowing the inspection of intrabars — which is not officially supported by TradingView.
• Intrabar inspection only works on some chart timeframes: 5, 10, 15, 30, 45 and 195 minutes, 1, 2, 3, 4, 5, 6, 7 and 8 hours, 1, 2, 3, 4 and 5 days, 1, 2, 3 and 4 weeks, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12 months. The script’s code can be modified to run on other resolutions.
• There is a limit to how far back intrabar calculations can be performed, and is dependant on both the intrabar resolution and your subscription (which determines the number of available bars).
תגובות
Tom4Townsend
Thanks so much for this, hugely helpful!
Can you please clarify if I am interpreting correctly from your writeup - "fail after 1 bar" simply means it didn't yet make the outside bar definition, could be on bar 2, not that it necessarily returned across the low for a "loss," is that correct?
Tom4Townsend
Similarly, we should interpret "success" to mean it completed the outside bar, either in 1 or 2 bars time, whether or not it also bounced below the low/high of the candle where one might put a stop, is that correct?
bmistiaen
@Tom4Townsend, both your interpretations are correct.
sonarika
Thank you!
arasbr
Greetings @bmistiaen

Really cool and useful script, thanks for sharing!

While playing around with the script, I stumbled upon a result that made me wonder. In short, shouldn't a bar that opened below the 50% level of the previous bar, then went below the previous low and above the 50% mark, but not above the previous high, be considered a failed 3-up?

I thought it should, hence I did some debugging to understand why the script did not identify the bar as a failed bar. I'll provide the details next, in case anybody's interested.

I was working with a 4h chart and noticed a bar as previously described (open below the 50% level of the previous bar, lower low than previous bar, lower high than previous bar, but still higher than the 50% level of the previous bar) that was not identified by the script. At a first glance, it appeared that this bar should have met all the conditions to be identified as a failed 3-up, which in the script are as follows:

fail3up := open < ss50_level and low < low[1] and lowfirst and high > ss50_level and high <= high[1]

I isolated the conditions and checked that, except for lowfirst, all the others were set to true according to the script. The value of lowfirst comes from the f_hilo() function call, which inspects lower timeframes - with the f_req() function - to determine which came first, low or high. For the 4h timeframe, the f_hilo() function calls the f_req() function passing the 5m timeframe as the lower timeframe to inspect. The actual function that implements the lower timeframe inspection is f_intrabar().

When looking at the 5m bars that correspond to the 4h bar, I observed that they first open below the 50% level, then go lower than the previous 4h bar low, then go higher than the 50% level, fail to reach the previous 4h bar high and go down again, until the end of the 4h bar. Still, f_intrabar() returned lofirst = false and hifirst = true in this scenario.

What happens is that the 5m bars first make a new lowest low (lo) on bar 2, then they make a new highest high (hi) on bar 9. Until now, hifirst = false and lowfirst = true, since lobar (2) < hibar (9). However, a new lowest low (lo) happens on bar 22; this results in hifirst = true and lowfirst = false, as hibar (9) < lobar (22). The next bars do not make any highest highs (hi), only lowest lows (lo). In the end, the last 5m bar before the next 4h bar has hibar (9) < lobar (45) and, therefore, hifirst = true and lowfirst = false, even though it first went down (lower).

Was this the intended behavior? Shouldn't that be considered a failed 3-up by the script?

Thanks once again for sharing!
shaneaus
Disregard! Figured it out! Thanks for this indicator!
bmistiaen
Nice video review by @Sandrusi of Sara Strat Sniper's - 50% Rule, which includes this SSS 50% Rule Evaluator indicator (click on image below):
drummerhc
This is amazing! Thank you so much!
עוד