StefanReich

Pullback Analyzer

StefanReich מעודכן   
Pullback Analyzer - a trailing stop helper.

This indicator measures the biggest pullback encountered during an up or down move.
You can use the reported percentages to fine-tune your trailing stop.

The reporting is very precise: On higher timeframes, the pullback size can sometimes not be determined exactly from the candles.
In this case, the script displays a lower and upper bound for this number.
I suggest that you use the upper bound as your trailing stop callback rate (plus some safety margin if you like).

The size of the move itself is always reported as a lower bound.

The biggest pullback within each move is marked with a gray dotted line.

There is only one parameter, "lookback"' (or lookback limit), which determines how many bars a single move can comprise. A value of 50 was found to be a nice default. If you lower the lookback, long moves will be split up into multiple moves, each being at or below the lookback limit. Conversely, you can capture longer moves in one piece by raising the lookback limit.

The algorithm automatically ignores small moves and trading ranges near a bigger move. (We may add a parameter to control this behavior more precisely in the future.)

How the algorithm works

There is a central class called MoveFinder which scans the candle feed for the biggest possible move in a certain direction (up or down).

Two instances of this class are used, one for each direction, to find the biggest next up and down move simultaneously (upFinder and downFinder).

Additionally, each of these main MoveFinders contains two more MoveFinders. These are used to find pullbacks within the move. (This comes from the observation that finding a pullback is fundamentally the exact same operation as finding a move, just with opposing direction and limited to the time between the move's beginning and end.)

Why two nested MoveFinders per parent (for a total of 6 in the program)? Well, one of them runs in "lower bound" and one runs in "upper bound" mode, so we can print the detected pullback size as an exact interval (lower bound <= real pullback <= upper bound). I am a mathematician. I like precision.

Moves as well as pullbacks that have been found are stored as instances of class Move which simply stores start and end bar index as well as start and end price.
הערות שחרור:
Fixed a bug in the script that sometimes showed a wrong pullback value. Changed increment for lookback value to 10 which I think is more practical.
הערות שחרור:
Added a "forex mode", i.e. an option to show percentages as pips. :) Selecting this mode also improves the label placement for low volatility assets such as forex pairs.
הערות שחרור:
Added an option to show move sizes in points. Added an option to not show pullbacks. Added an option to show beginning and end price of each move.

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יכולים להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בסקריפ זה בגרף?