tradingwithmiggy
New member
Is there a way of keeping track of local highs and local lows on a chart? Ideally what I want to do is keep track of % runs and % draw downs between local highs and local lows on charts. So I was wondering if there was any way to make this?
I also only want to denote the runs that matter so only new highs or lows created by passing through the 38.2 and 61.8 fib retracements. This way we don't have to keep track of every reversal.
It should look something like this Running and Drawdown % - Imgur
I also only want to denote the runs that matter so only new highs or lows created by passing through the 38.2 and 61.8 fib retracements. This way we don't have to keep track of every reversal.
It should look something like this Running and Drawdown % - Imgur
Code:
# Draw Highs and Lows of Thing
# created by tradingwithmiggy
# 2022/10/22
# GAME PLAN
# 1. Variables Needed:
# - A (Lagging)
# - B (Leading)
# - hh (keeps track of current local high)
# - ll (keeps track of current local low)
# 2. You need to calculate the retracement using the distance of the hh and ll
# and using A and B to know where we on the retracement.
# 3. CONDITIONAL: if the length of (A -> B) passes the retracement threshhold
# then hh and ll need to be updated. (I feel like I still need to get clear on this statement)
# a. A is lower than B (means trending upwards)
# - Update hh
# - ll remains the same
# - Check if (A->B) is more than 38.2 retracement
# - Update A = hh && ll = B
# b. A is higher than B (means trending downwards)
# - Update ll
# - hh remains the same
# - Check if (A->B) is less than 61.8 retracement
# - Update A = ll && hh = B
def rth = getTime() >= RegularTradingStart(getYYYYMMDD()) and
getTime() <= RegularTradingEnd(getYYYYMMDD());
def B = close;
def hh = if rth and !rth[1]
then open
else if rth and A < B and (B-A)/(hh-ll) > 38.2
then max(max(open[0],close[0]), hh)
else if rth and A > B and (B-A)/(hh-ll) < 61.8
then hh[1]
else hh[1];
def ll = if rth and !rth[1]
then open
else if rth and A < B and (B-A)/(hh-ll) > 38.2
then ll[1]
else if rth and A > B and (B-A)/(hh-ll) < 61.8
then min(min(open[0],close[0]), ll)
else ll[1];
def A = if rth and !rth[1]
then open
else if rth and A < B and (B-A)/(hh-ll) > 38.2
then hh
else if rth and A > B and (B-A)/(hh-ll) < 61.8
then ll
else A[1];
addChartBubble(yes, high[0], "A: " + round(A) +"\nB: " + round(B) +"\nhh: " + round(hh)+"\nll: " + round(ll), COLOR.CYAN);
def retracement = absValue(A-B)/(hh-ll);
Last edited: