Repaints MTF Anticipated Price Level Indicator For ThinkOrSwim

Repaints

TraderZen

Member
Updated 5:00 8/21/2022 - V3.0 --> D+ level MTF & Anticipated_Level VWAP and Price of Interest (POI) Profiles.
Updated 10:55 8/17/2022 PST - % change in Label.
Updated 12:45 8/6/2022 PST - A calculation correction.


Current Anticipated Level Indicator version is V3.
Current Anticipate Level VWAP and POI Profiler code version is V1.
Both of the studies should be added at the chart level, the plots overlap with right levels of translusence.

turpvOi.jpg


Multi Time Frame Anticipated Price Level Indicator.
Color Coded Twenty Four Steps of trend Cycles from Bearish to Bullish and vice-versa.
Color coded six phases of a trade cycle.
Entry and Exit Points.
Trend Reversal Indications.


5uLCbSL.png

Code:
#
# Anticipated Level Indicator
# Current Version: V3.0
# Created by TraderZen
# Last update 8/21/2022
#


input applyPersonsLevelsFilter = yes;
input marketThreshold = 0.0025;
input timeFrame = AggregationPeriod.Fifteen_MIN;
input showLabel = {default "Yes", "No"};
input Show_Level_Lines = {default "All", "Mid", "High-Low", "None"};
input Show_Profiles = yes;



def CurrentTP = GetAggregationPeriod();
def thisTP;
thisTP = CurrentTP;

Def HigherTP = TimeFrame;

def PP2TP = high(period = thisTP)[1] + low(period = thisTP)[1] + close(period = thisTP)[1];
def marketTypeTP = { DISABLED,  NEUTRAL, BEARISH, default BULLISH};

marketTypeTP = if !applyPersonsLevelsFilter then marketTypeTP.DISABLED
                else if PP2TP[-1] > (PP2TP[-1] + PP2TP + PP2TP[1]) / 3 + marketThreshold then marketTypeTP.BULLISH
                else if PP2TP[-1] < (PP2TP[-1] + PP2TP + PP2TP[1]) / 3 - marketThreshold then marketTypeTP.BEARISH
                else marketTypeTP.NEUTRAL;

def AlgoExec = if HigherTP <= thisTP then no else yes;
AddLabel(yes, if AlgoExec == no then "No Execution: The Current Time Period Should be Less then the Selected Time Period! " + HigherTP else "Trend:" ,
        Color.WHITE) ;

def P = HigherTP / CurrentTP;

def Higher =  fold nH = 1 to P + 1 with Top_high     do  Max(high(Period = thisTP)[P], high(Period = thisTP)[P + 1]) ;
def Lower  =  fold nL = 1 to P + 1 with Bottom_Low   do  Min(low(Period = thisTP)[P], low(Period = thisTP)[P + 1]);
def closer  = close[1];

#def higher  = high(period = HigherTP)[1];
#def Lower   = low(period = HigherTP)[1];
#def Closer  =  close(period = HigherTP)[1];

#AddLabel(Yes, higher + " " + lower + " " + closer);

def PP2HP = Higher + Lower + closer;
def MarketTypeHP = { DISABLED,  NEUTRAL,  BEARISH, default BULLISH};

MarketTypeHP = if !applyPersonsLevelsFilter then MarketTypeHP.DISABLED
        else if PP2HP[-1] > (PP2HP[-1] + PP2HP + PP2HP[1]) / 3 + marketThreshold then MarketTypeHP.BULLISH
        else if PP2HP[-1] < (PP2HP[-1] + PP2HP + PP2HP[1]) / 3 - marketThreshold then MarketTypeHP.BEARISH
        else MarketTypeHP.NEUTRAL;

#def paintingStrategy1 = if getAggregationPeriod() == AggregationPeriod.Min then PaintingStrategy.LINE_VS_TRIANGLES
#                       else if getAggregationPeriod() == AggregationPeriod.FIVE_MIN
#                            or getAggregationPeriod() == AggregationPeriod.FIFTEEN_MIN then
#                            PaintingStrategy.LINE_VS_SQUARES
#                       else PaintingStrategy.LINE;
def paintingStrategy1 = PaintingStrategy.LINE;

#def paintingStrategy2 = if HigherTP == AggregationPeriod.Min then PaintingStrategy.LINE_VS_TRIANGLES
#                       else if HigherTP == AggregationPeriod.Five_Min or HigherTP == AggregationPeriod.Fifteen_Min then PaintingStrategy.LINE_VS_SQUARES
#                       else PaintingStrategy.LINE;
def paintingStrategy2 = PaintingStrategy.LINE;

## -- Pivote points + Trigger points + phase to calculate Trend.

## -- Initiate Variables

def HigherTP_PP;
def HigherTP_R1;
def HigherTP_R2;
def HigherTP_R3;
def HigherTP_S1;
def HigherTP_S2;
def HigherTP_S3;
def HigherTP_RR;
def HigherTP_SS;

def HigherTP_PP_I;
def HigherTP_R1_I;
def HigherTP_R2_I;
def HigherTP_R3_I;
def HigherTP_S1_I;
def HigherTP_S2_I;
def HigherTP_S3_I;
def HigherTP_RR_I;
def HigherTP_SS_I;

## -- Conditionally Assign Values

if AlgoExec == no # or !IsNaN(close(period = HigherTP)[-1])
Then
{

    HigherTP_PP = Double.NaN;
    HigherTP_R1 = Double.NaN;
    HigherTP_R2 = Double.NaN;
    HigherTP_R3 = Double.NaN;
    HigherTP_S1 = Double.NaN;
    HigherTP_S2 = Double.NaN;
    HigherTP_S3 = Double.NaN;
    HigherTP_RR = Double.NaN;
    HigherTP_SS = Double.NaN;

    HigherTP_PP_I = Double.NaN;
    ;
    HigherTP_R1_I = Double.NaN;
    HigherTP_R2_I = Double.NaN;
    ;
    HigherTP_R3_I = Double.NaN;
    ;
    HigherTP_S1_I = Double.NaN;
    ;
    HigherTP_S2_I = Double.NaN;
    ;
    HigherTP_S3_I = Double.NaN;
    ;
    HigherTP_RR_I = Double.NaN;
    ;
    HigherTP_SS_I = Double.NaN;
    ;


}
else
{

    HigherTP_PP = (high(period = HigherTP)[1] + low(period = HigherTP)[1] + close(period = HigherTP)[1]) / 3;
    ;
    HigherTP_R1 = 2 * HigherTP_PP - low(period = HigherTP)[1];
    ;
    HigherTP_R2 = HigherTP_PP + high(period = HigherTP)[1] - low(period = HigherTP)[1];
    HigherTP_R3 = HigherTP_R2 + high(period = HigherTP)[1] - low(period = HigherTP)[1];
    HigherTP_S1 = 2 * HigherTP_PP - high(period = HigherTP)[1];
    HigherTP_S2 = HigherTP_PP - high(period = HigherTP)[1] + low(period = HigherTP)[1];
    HigherTP_S3 = HigherTP_S2 - high(period = HigherTP)[1] + low(period = HigherTP)[1];
    HigherTP_RR = if (MarketTypeHP == MarketTypeHP.BEARISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_R1 else HigherTP_R2;
    HigherTP_SS = if (MarketTypeHP == MarketTypeHP.BULLISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_S1 else HigherTP_S2;

    HigherTP_PP_I = (Higher[1] + Lower[1] + closer[1]) / 3;
    ;
    HigherTP_R1_I = 2 * HigherTP_PP - Lower[1];
    ;
    HigherTP_R2_I = HigherTP_PP + Higher[1] - Lower[1];
    HigherTP_R3_I = HigherTP_R2 + Higher[1] - Lower[1];
    HigherTP_S1_I = 2 * HigherTP_PP - Higher[1];
    HigherTP_S2_I = HigherTP_PP - Higher[1] + Lower[1];
    HigherTP_S3_I = HigherTP_S2 - Higher[1] + Lower[1];
    HigherTP_RR_I = if (MarketTypeHP == MarketTypeHP.BEARISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_R1 else HigherTP_R2;
    HigherTP_SS_I = if (MarketTypeHP == MarketTypeHP.BULLISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_S1 else HigherTP_S2;

}


plot P_HigherTP_PP = if (Show_Level_Lines == Show_Level_Lines."All" or Show_Level_Lines  == Show_Level_Lines."Mid" ) then HigherTP_PP else Double.nan;
plot P_HigherTP_R1 = HigherTP_R1;
plot P_HigherTP_R2 = HigherTP_R2;
plot P_HigherTP_R3 = HigherTP_R3;
plot P_HigherTP_S1 = HigherTP_S1;
plot P_HigherTP_S2 = HigherTP_S2;
plot P_HigherTP_S3 = HigherTP_S3;
plot P_HigherTP_RR = if (Show_Level_Lines == Show_Level_Lines."All" or Show_Level_Lines  == Show_Level_Lines."High-Low") then HigherTP_RR else double.nan;
plot P_HigherTP_SS = if (Show_Level_Lines == Show_Level_Lines."All" or Show_Level_Lines  == Show_Level_Lines."High-Low") then HigherTP_SS else double.nan;

plot P_HigherTP_PP_I = HigherTP_PP_I;
plot P_HigherTP_R1_I = HigherTP_R1_I;
plot P_HigherTP_R2_I = HigherTP_R2_I;
plot P_HigherTP_R3_I = HigherTP_R3_I;
plot P_HigherTP_S1_I = HigherTP_S1_I;
plot P_HigherTP_S2_I = HigherTP_S2_I;
plot P_HigherTP_S3_I = HigherTP_S3_I;
plot P_HigherTP_RR_I = HigherTP_RR_I;
plot P_HigherTP_SS_I = HigherTP_SS_I;


P_HigherTP_RR.SetHiding(!applyPersonsLevelsFilter);
P_HigherTP_R1.SetHiding(applyPersonsLevelsFilter);
P_HigherTP_R2.SetHiding(applyPersonsLevelsFilter);
P_HigherTP_SS.SetHiding(!applyPersonsLevelsFilter);
P_HigherTP_S1.SetHiding(applyPersonsLevelsFilter);
P_HigherTP_S2.SetHiding(applyPersonsLevelsFilter);


P_HigherTP_PP.SetDefaultColor(GetColor(3));
P_HigherTP_R1.SetDefaultColor(GetColor(5));
P_HigherTP_R2.SetDefaultColor(GetColor(5));
P_HigherTP_R3.SetDefaultColor(GetColor(6));
P_HigherTP_S1.SetDefaultColor(GetColor(5));
P_HigherTP_S2.SetDefaultColor(GetColor(5));
P_HigherTP_S3.SetDefaultColor(GetColor(5));

P_HigherTP_SS.DefineColor("P_HigherTP_S1", GetColor(5));
P_HigherTP_SS.DefineColor("P_HigherTP_S2", GetColor(5));
P_HigherTP_SS.AssignValueColor(if P_HigherTP_SS == P_HigherTP_S1 then P_HigherTP_SS.Color("P_HigherTP_S1") else P_HigherTP_SS.Color("P_HigherTP_S2"));

P_HigherTP_RR.DefineColor("P_HigherTP_R1", GetColor(6));
P_HigherTP_RR.DefineColor("P_HigherTP_R2", GetColor(6));
P_HigherTP_RR.AssignValueColor(if P_HigherTP_RR == P_HigherTP_R1 then P_HigherTP_RR.Color("P_HigherTP_R1") else P_HigherTP_RR.Color("P_HigherTP_R2"));

P_HigherTP_PP.SetStyle(Curve.LONG_DASH);
P_HigherTP_RR.SetStyle(Curve.SHORT_DASH);
P_HigherTP_R1.SetStyle(Curve.SHORT_DASH);
P_HigherTP_R2.SetStyle(Curve.SHORT_DASH);
P_HigherTP_R3.SetStyle(Curve.SHORT_DASH);
P_HigherTP_SS.SetStyle(Curve.SHORT_DASH);
P_HigherTP_S1.SetStyle(Curve.SHORT_DASH);
P_HigherTP_S2.SetStyle(Curve.SHORT_DASH);
P_HigherTP_S3.SetStyle(Curve.SHORT_DASH);


P_HigherTP_PP.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_RR.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_R1.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_R2.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_R3.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_SS.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_S1.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_S2.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_S3.SetPaintingStrategy(paintingStrategy2);


P_HigherTP_S1.Hide();
P_HigherTP_S2.Hide();
P_HigherTP_S3.Hide();
P_HigherTP_R1.Hide();
P_HigherTP_R2.Hide();
P_HigherTP_R3.Hide();
#P_HigherTP_rr.hide();
#P_HigherTP_ss.hide();
#P_HigherTP_pp.hide();


P_HigherTP_S1_I.Hide();
P_HigherTP_S2_I.Hide();
P_HigherTP_S3_I.Hide();
P_HigherTP_R1_I.Hide();
P_HigherTP_R2_I.Hide();
P_HigherTP_R3_I.Hide();
P_HigherTP_RR_I.Hide();
P_HigherTP_SS_I.Hide();
P_HigherTP_PP_I.Hide();

## -- Arrangement to reference the higher timeframe data (AP = AggergationPeriod).

def BullCalc = MovingAverage(3, PP2TP[-1] / 3, 3);
def BearCalc = MovingAverage(3, ( (PP2TP[-1] + PP2TP + PP2TP[1]) / 3) / 3 , 3);

rec BullCalcHP = MovingAverage(3, PP2HP[-1] / 3, 3);
rec BearCalcHP = MovingAverage(3, ( (PP2HP[-1] + PP2HP + PP2HP[1]) / 3) / 3 , 3);

plot p_bullC = BullCalc;
p_bullC.AssignValueColor(Color.WHITE);

plot p_BearC = BearCalc;
p_BearC.AssignValueColor(Color.GRAY);


plot P_BullCHP = BullCalcHP;
P_BullCHP.AssignValueColor(Color.WHITE);

plot p_BearCHP = BearCalcHP;
p_BearCHP.AssignValueColor(Color.YELLOW);


plot P_Close = close(priceType = PriceType.LAST);


rec bull = if (BullCalc[-1] crosses above BearCalc[-1] - marketThreshold) then yes else Double.NaN;
rec bear = if (BearCalc[-1] crosses above BullCalc[-1] - marketThreshold) then yes else Double.NaN;

rec BullHP = if  (BullCalcHP[-1] crosses above (BearCalcHP[-1] - marketThreshold))  then yes
             else Double.NaN;
def BearHP = if (BearCalcHP[-1] crosses above (BullCalcHP[-1] - marketThreshold))  then yes else Double.NaN;


plot P_bull = bull;
plot p_bear =  bear ;

plot P_BullHP = BullHP ;
plot p_BearHP = BearHP ;

P_bull.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
P_bull.SetDefaultColor(Color.GREEN);
p_bear.SetDefaultColor(Color.DARK_ORANGE);
p_bear.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

P_BullHP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
P_BullHP.SetDefaultColor(Color.CYAN);
p_BearHP.SetDefaultColor(Color.MAGENTA);
p_BearHP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

p_bullC.Hide();
p_BearC.Hide();

P_bull.Hide();
p_bear.Hide();

P_BullHP.Hide();
p_BearHP.Hide();

P_BullCHP.Hide();
p_BearCHP.Hide();

######################################### ------ Color coding

def C = P_Close;

def v50  = Round(SimpleMovingAvg(close, 50)); # MovAvgExponential(close, 50);
def v100 = Round(SimpleMovingAvg(close, 100));
def v200 = Round(SimpleMovingAvg(close, 200)); # MovAvgExponential(close, 200);
def F = v50;  # Duplicate variable for v50 to code the SeqNum Logic.
def H = v100; # Duplicate variable for v100 to code the SeqNum Logic.
def T = v200; # Duplicate variable for v200 to code the seqNum Logic.
def BB = Round(BollingerBands()."MidLine");

def ROCFlag = if RateOfChange() > RateOfChange()[1] then 1
              else if RateOfChange() < RateOfChange()[1] then -1
              else 0;

def ROCFlag2 = if RateOfChange() > 0 then 1
               else if RateOfChange() < 0 then -1
               else 0;

def MACDOpen = if MACD()."value" >= MACD()."value"[1] and MACD()."value" > MACD()."avg" then 1
               else if MACD()."value" <  MACD()."value"[1] and MACD()."value" < MACD()."avg" then -1
               else 0;

def PlayzoneFlag = if  ROCFlag == 1 and MACDOpen == 1  then 2
                   else if ROCFlag2 == 1 and MACDOpen == 1 then 2
                   else if ROCFlag == -1 and MACDOpen == -1 then -2
                   else if ROCFlag2 == -1 and MACDOpen == -1 then -2
                   else 0;

def Phase = if (close >= v50  and close >= v200 and v50   >= v200) then 1 #Bullish
       else if (close >= v50  and close >= v200 and v50   <= v200) then 2 #Accumulation
       else if (  v50 <= v200 and close <= v200 and close >= v50)  then 3 # Recovery
       else if (close <= v50  and close >= v200 and v50   >= v200) then 4 # Warning
       else if (close <= v50  and close <= v200 and v50   >= v200) then 5 #Distribution
       else if (  v50 <= v200 and close <= v200 and close <= v50 ) then 6 #Bearish
       else 7;

def ScalpCode = if ( (C >= BB) and (BB > BB[1])  and (BB >= F) ) then 101 # Bullish Superseed condition
         else if ( (F >= BB) and (BB[1] >= BB) and (BB >= C) ) then -101 # Bearish Superseed condition
         else if ( (C >= BB) and (BB >= F) ) then 100 #Still Bullish Strong
         else if ( (F >= BB) and (BB >= C) ) then -100 #Still Bearish Strong
         else if ( close >= Highest(close[1], 50)) then 75 #C50 Up
         else if ( close <= Lowest(close[1], 50)) then -75  #c50 Down
         else if ( BB >= BB[1]) then 50 #Uptrend
         else if ( BB[1] >= BB) then -50 #DownTrend
         else 0;

def SeqNum =  if ((C >= F) and (F >= H) and (H >= T)) then 1 #Step-3 Bullish phase Confirmed [1] (C-F-H-T)
         else if ((C >= F) and (F >= T) and (T >= H)) then 2 #Step-2 Bullish Confirmation AKA Accumuation [2] (C-F-T-H)
         else if ((C >= H) and (H >= F) and (F >= T)) or
                 (close >= Highest(close[1], 50))     then 3 #Ambiguous Bullish. Check the C, Phase, Playzone and Higher Time-Frame. (C-H-F-T)
         else if ((C >= H) and (H >= T) and (T >= F)) then 4 #Ambiguous Bullish. Check the Phase, Playzone and Higher Time-Frame. (C-H-T-F)
         else if ((C >= T) and (T >= F) and (F >= H)) then 5 #Step-3 Bullish Breakout and re-test AKA Bullish [1] (C-T-F-H)
         else if ((C >= T) and (T >= H) and (H >= F)) then 6 #Step-1 Bullish Initiation AKA Recovery [3] (C-T-H-F)

         else if ((F >= C) and (C >= H) and (H >= T)) then 7 #Step-4.5 Bullish Maturation AKA Bullish (F-C-H-T)
         else if ((F >= C) and (C >= T) and (T >= H)) or
                 (close <= Lowest(close[1], 50))      then 8 #step-9 Bearish Maturation AKA Bearish. Check the C.[6] (F-C-T-H)
         else if ((F >= H) and (H >= C) and (C >= T)) then 9 #Step-4.5 Bullish Maturation [PullBack, Not Real Distribution] [4] (F-H-C-T)
         else if ((F >= H) and (H >= T) and (T >= C)) then 10 #Step-6 Bearish Initiation AKA Warning [4] (F-H-T-C)
         else if ((F >= T) and (T >= C) and (C >= H)) then 11 #Ambiguous-11 Check the Phase, Playzone and Higher Time-Frame(F-T-C-H)
         else if ((F >= T) and (T >= H) and (H >= C)) then 12 #Step-7 Bearish Breakout and Re-test AKA Bearish [6]

         else if ((H >= C) and (C >= F) and (F >= T)) then 13 #Step-4 Bullish Maturation AKA Bullish [1] (H-C-F-T)
         else if ((H >= C) and (C >= T) and (T >= F)) then 14 #Ambiguous-14 Check the Phase, Playzone and Higher Time-Frame(H-C-T-F)
         else if ((H >= F) and (F >= C) and (C >= T)) then 15 #Step-5 Bullish Exhaustion (H-F-C-T) Review!
         else if ((H >= F) and (F >= T) and (T >= C)) then 16 #Step-6.5 Bearish Comfirmation AKA Distribution (H-F-T-C)
         else if ((H >= T) and (T >= C) and (C >= F)) then 17 #Step-9.5 Bearish Exhaustion Confirmed (H-T-C-F)
         else if ((H >= T) and (T >= F) and (F >= C)) then 18 #Ambiguous-18 Check the Phase, Playzone and Higher Time-Frame(H-T-F-C)

         else if ((T >= C) and (C >= F) and (F >= H)) then 19 #Step-0.5 - Attempting to be Bullish. Watch ROC/MACD  [1] (T-C-F-H)
         else if ((T >= C) and (C >= H) and (H >= F)) then 20 #Step-10 - Attempting to be Bullish. Watch ROC/MACD [1] (T-C-H-F)
         else if ((T >= F) and (F >= C) and (C >= H)) then 21 #Step-4.5 Bullish Maturation [PullBack, Not Real Distribution] [4] (T-F-C-H)
         else if ((T >= F) and (F >= H) and (H >= C)) then 22 #Ambiguous Bearish. Check the Phase, Playzone and Higher Time-Frame. (T-G-H-C)
         else if ((T >= H) and (H >= C) and (C >= F)) then 23 #Ambiguoua-23 (T-H-C-F)
         else if ((T >= H) and (H >= F) and (F >= C)) then 24 #Step-9 Bearish Maturation [6] (T-H-F-c)

         else 0;



P_Close.AssignValueColor( if ScalpCode == 100 or ScalpCode == 75 then Color.GREEN
                      else if ScalpCode == 101 then Color.CYAN
                      else if ScalpCode == -100 or ScalpCode == -75 then Color.RED
                      else if ScalpCode == -101 then Color.PLUM
                      else if ScalpCode == 50 then Color.LIGHT_GREEN
                      else if ScalpCode == -50 then Color.PINK
                      else Color.LIGHT_GRAY);


P_HigherTP_PP.AssignValueColor( if SeqNum == 1 or  SeqNum == .5 then Color.CYAN
                            else if SeqNum == 2 or  SeqNum == 2.5 then Color.LIGHT_GREEN
                            else if SeqNum == 3 then Color.GREEN
                            else if SeqNum == 4 or  SeqNum == 4.5 then Color.LIGHT_GREEN
                            else if SeqNum == 5 or  SeqNum == 5.1 then Color.CYAN
                            else if SeqNum == 6 then Color.GREEN
                            else if SeqNum == 7 then Color.LIME
                            else if SeqNum == 8 then Color.RED
                            else if SeqNum == 9 or  SeqNum == 9.5 then Color.LIGHT_RED
                            else if SeqNum == 10 then Color.RED
                            else if SeqNum == 11 then Color.GRAY
                            else if SeqNum == 12 then Color.MAGENTA
                            else if SeqNum == 13 then Color.GREEN
                            else if SeqNum == 14 then Color.GRAY
                            else if SeqNum == 15 then Color.YELLOW
                            else if SeqNum == 16 then Color.MAGENTA
                            else if SeqNum == 17 then Color.YELLOW
                            else if SeqNum == 18 then Color.GRAY
                            else if SeqNum == 19 then Color.LIGHT_GREEN
                            else if SeqNum == 20 then Color.LIGHT_GREEN
                            else if SeqNum == 21 then Color.RED
                            else if SeqNum == 22 then Color.LIGHT_RED
                            else if SeqNum == 23 then Color.GRAY
                            else if SeqNum == 24 then Color.MAGENTA
                            else if SeqNum == 0 then Color.GRAY
                           else Color.LIGHT_GRAY
 
);

AddLabel(if showLabel == showLabel."Yes" then yes else no, SeqNum + " " +
    if SeqNum == 1 then "Bullish Confirmed"
         else if SeqNum == 2 then "Accumuation"
         else if SeqNum == 3 then "Ambiguous+Bullish"
         else if SeqNum == 4 then "Ambiguous+Bullish"
         else if SeqNum == 5 then "Bullish Breakout & Re-test"
         else if SeqNum == 6 then "Bullish Initiation"

         else if SeqNum == 7 then "Bullish Maturation"
         else if SeqNum == 8 then "Bearish Maturation"
         else if SeqNum == 9 then "PullBack,Not Real Distribution"
         else if SeqNum == 10 then "Bearish Initiation"
         else if SeqNum == 11 then "Ambiguous! May be in a channel"
         else if SeqNum == 12 then "Bearish Breakout & Re-test"

         else if SeqNum == 13 then "Bullish Maturation"
         else if SeqNum == 14 then "Ambiguous! May be in a channel"
         else if SeqNum == 15 then "Potential Reversal! Bullish Exhaustion"
         else if SeqNum == 16 then "Bearish Comfirmation/Distribution"
         else if SeqNum == 17 then "Bearish Exhaustion Confirmed"
         else if SeqNum == 18 then "Ambiguous-Bearish/Bearish Channel"

         else if SeqNum == 19 and PlayzoneFlag == 2 then "About to be Bullish"
         else if SeqNum == 19 and PlayzoneFlag == -2 then "About to be Bearish"
         else if SeqNum == 19 and PlayzoneFlag == 0 then "Ambiguous. Check Higher TF"
         else if SeqNum == 19 then "Ambiguous.Check Higher TF"
         else if SeqNum == 20 and PlayzoneFlag == 2 then "Bullish Attempt may fail"
         else if SeqNum == 20 and PlayzoneFlag == -2 then "Bearish attempt may fail"
         else if SeqNum == 20 and PlayzoneFlag == 0 then "Ambiguous. *Check Higher TF"
         else if SeqNum == 20 then "Ambiguous. Check Higher TF"
 
         else if SeqNum == 21 then "Bullish Maturation/PullBack, Not Real Distribution"
         else if SeqNum == 22 then "Ambiguous-Bearish. *Check Higher TF"
         else if SeqNum == 23 then "Ambiguous. Check Higher TF"
         else if SeqNum == 24 then "Bearish Trend. Check Higher TF"
         else "*" ,

         if SeqNum == 1 or  SeqNum == .5 then Color.CYAN
                            else if SeqNum == 2 or  SeqNum == 2.5 then Color.LIGHT_GREEN
                            else if SeqNum == 3 then Color.GREEN
                            else if SeqNum == 4 or  SeqNum == 4.5 then Color.LIGHT_GREEN
                            else if SeqNum == 5 or  SeqNum == 5.1 then Color.CYAN
                            else if SeqNum == 6 then Color.GREEN
                            else if SeqNum == 7 then Color.LIME
                            else if SeqNum == 8 then Color.RED
                            else if SeqNum == 9 or  SeqNum == 9.5 then Color.LIGHT_RED
                            else if SeqNum == 10 then Color.RED
                            else if SeqNum == 11 then Color.GRAY
                            else if SeqNum == 12 then Color.MAGENTA
                            else if SeqNum == 13 then Color.GREEN
                            else if SeqNum == 14 then Color.GRAY
                            else if SeqNum == 15 then Color.YELLOW
                            else if SeqNum == 16 then Color.MAGENTA
                            else if SeqNum == 17 then Color.YELLOW
                            else if SeqNum == 18 then Color.GRAY
                            else if SeqNum == 19 then Color.LIGHT_GREEN
                            else if SeqNum == 20 then Color.LIGHT_GREEN
                            else if SeqNum == 21 then Color.RED
                            else if SeqNum == 22 then Color.LIGHT_RED
                            else if SeqNum == 23 then Color.GRAY
                            else if SeqNum == 24 then Color.MAGENTA
                            else if SeqNum == 0 then Color.GRAY
                           else Color.LIGHT_GRAY );

input MACDBB_FastLength = 12;
input MACDBB_SlowLength = 26;
input MACDBB_BandLength = 9;
input MACDBB_NumDev = 1.0;

Def HigherTP_PP_BB_High = reference BollingerBands(price = P_HigherTP_RR, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).UpperBand;

def HigherTP_PP_BB_LOW = reference BollingerBands(price = P_HigherTP_SS, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).Lowerband;

AddLabel(if showLabel == showLabel."Yes" then yes else no,
      
         if P_Close >= HigherTP_PP and P_Close <= HigherTP_RR then "Anticipated Level: " + HigherTP_RR  + " (" + roundup( ((HigherTP_RR - P_Close)/P_Close)*100,2) + " %)" + " in next " + p + " Bars"
         else if P_Close <= HigherTP_PP and P_Close >= HigherTP_SS then "Anticipated Level: " + HigherTP_SS + " (" + roundup( ((HigherTP_SS - P_Close)/P_Close)*100,2) + " %)" + " in next " + p + " Bars"
         else if P_Close >= P_HigherTP_PP and P_Close >= HigherTP_RR then "Anticipated Level: " + HigherTP_PP_Bb_HIgh + " (" + roundup( ((HigherTP_PP_BB_High - P_Close)/P_Close)*100, 2) + " %)" + "* in next " + p + " Bars"
         else if P_Close <= P_HigherTP_PP and P_Close <= HigherTP_SS then "Anticipated Level: " +
                            HigherTP_PP_BB_Low  + " (" + roundup( ((HigherTP_PP_BB_Low - P_Close)/P_Close)*100,2) + " %)" + "* in next " + p + " Bars" 
         else "Anticipated Level:",
         if P_Close >= HigherTP_PP then GetColor(6) else GetColor(5) );

P_Close.SetPaintingStrategy(paintingStrategy2);
P_Close.SetLineWeight(1);
P_BullCHP.SetLineWeight(1);
P_BullCHP.AssignValueColor(Color.WHITE);
P_Close.Hide();


# --- Cross over logic --
rec _Cross_Up = if P_Close crosses above P_HigherTP_PP_I then yes else no;
def Cross_Up = if _Cross_Up != _Cross_Up[1] then _Cross_Up else Double.NaN;

def  Cross_Dn = if P_Close crosses below P_HigherTP_PP_I then yes else no;
#Cross_Up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Cross_Dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

def upArrow = if Cross_up then low else double.NaN;
def dnArrow = if Cross_Dn then high else double.NaN;

plot PPSup = upArrow;
Plot PPSdown = dnArrow;
PPSup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
PPSdown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
PPSup.SetLineWeight(3);
PPSDown.SetLineWeight(3);
PPSUp.AssignValueColor(Color.White);
PPSDown.AssignValueColor(Color.White);



#-- Paint Bars logic --
input PaintBars = { default "Yes", "No" } ;

AssignPriceColor(
        if PaintBars == PaintBars."Yes" then

         if ScalpCode == 100 or ScalpCode == 75 then Color.GREEN
                      else if ScalpCode == 101 then Color.CYAN
                      else if ScalpCode == -100 or ScalpCode == -75 then Color.RED
                      else if ScalpCode == -101 then Color.MAGENTA
                      else if ScalpCode == 50 then Color.LIGHT_GREEN
                      else if ScalpCode == -50 then Color.PINK
                      else Color.LIGHT_GRAY     
 
        else Color.CURRENT# RB
    );

#End 8/21/20222

The Anticipated Level POI and WVAP Profiler code is available below -

Mj6QV6D.jpg

Code:
# AL_Profiler
# Current Version: V1.0
# Goes with Anticipated Level Indicator
# Created by: TraderZen
# Last Update: 8/21/2022
# -- Show Profile ----

#------Start Function List---------------

input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input aggregationPeriod = {default "1 min", "2 min", "3 min", "4 min", "5 min", "10 min", "15 min", "20 min",  "30 min", "1 hour", "2 hours", "4 hours", "Day", "2 Days", "3 Days", "4 Days", "Week", "Month"};
input timePerProfile = {CHART, MINUTE, HOUR, DAY, WEEK, MONTH, "OPT EXP", default BAR, YEAR};
input multiplier = 6;
input onExpansion = no;
input profiles = 500;
input showMonkeyBar = yes;
input showThePlayground = yes;
input thePlaygroundPercent = 70;
input opacity = 25;
input emphasizeFirstDigit = no;
input markOpenPrice = no;
input markClosePrice = no;
input volumeShowStyle = MonkeyVolumeShowStyle.NONE;
input showVolumeVA = yes;
input showVolumePoc = yes;
input theVolumePercent = 70;
input showInitialBalance = no;
input initialBalanceRange = 1;

def period;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def dom = GetDayOfMonth(yyyymmdd);
def dow = GetDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
def periodMin = Floor(seconds / 60 + day_number * 24 * 60);
def periodHour = Floor(seconds / 3600 + day_number * 24);
def periodDay = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
def periodWeek = Floor(day_number / 7);
def periodMonth = month - First(month);

switch (timePerProfile) {
case CHART:
    period = 0;
case MINUTE:
    period = periodMin;
case HOUR:
    period = periodHour;
case DAY:
    period = periodDay;
case WEEK:
    period = periodWeek;
case MONTH:
    period = periodMonth;
case "OPT EXP":
    period = exp_opt - First(exp_opt);
case BAR:
    period = BarNumber() - 1;
case YEAR:
    period = GetYear() - First(GetYear());
}

input RthBegin  = 0930;
input RthEnd    = 1600;
#input Minutes = 6;
#input showBubbles = no;
def OpenRange = SecondsFromTime(0930) >= 0 and
                SecondsFromTime(1000) >= 0;
def bar = BarNumber();
def RTHBar1 = if SecondsFromTime(RthBegin) == 0 and
                 SecondsTillTime(RthBegin) == 0
              then bar
              else RTHBar1[1];
def RTHBarEnd = if SecondsFromTime(RthEnd) == 0 and
                   SecondsTillTime(RthEnd) == 0
                then 1
                else Double.NaN;
def RTH = SecondsFromTime(RthBegin) > 0 and
          SecondsTillTime(RthEnd) > 0;
def start_t = if RTH and !RTH[1]
              then GetTime()
              else start_t[1];
def t = if start_t == GetTime()
        then 1
        else GetTime() % (Multiplier * 60 * 1000) == 0;
def cond = t;

def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
case CUSTOM:
    height = customRowHeight;
}

def timeInterval;
def aggMultiplier;
switch (aggregationPeriod) {
case "1 min":
    timeInterval = periodMin;
    aggMultiplier = 1;
case "2 min":
    timeInterval = periodMin;
    aggMultiplier = 2;
case "3 min":
    timeInterval = periodMin;
    aggMultiplier = 3;
case "4 min":
    timeInterval = periodMin;
    aggMultiplier = 4;
case "5 min":
    timeInterval = periodMin;
    aggMultiplier = 5;
case "10 min":
    timeInterval = periodMin;
    aggMultiplier = 10;
case "15 min":
    timeInterval = periodMin;
    aggMultiplier = 15;
case "20 min":
    timeInterval = periodMin;
    aggMultiplier = 20;
case "30 min":
    timeInterval = periodMin;
    aggMultiplier = 30;
case "1 hour":
    timeInterval = periodHour;
    aggMultiplier = 1;
case "2 hours":
    timeInterval = periodHour;
    aggMultiplier = 2;
case "4 hours":
    timeInterval = periodHour;
    aggMultiplier = 4;
case "Day":
    timeInterval = periodDay;
    aggMultiplier = 1;
case "2 Days":
    timeInterval = periodDay;
    aggMultiplier = 2;
case "3 Days":
    timeInterval = periodDay;
    aggMultiplier = 3;
case "4 Days":
    timeInterval = periodDay;
    aggMultiplier = 4;
case "Week":
    timeInterval = periodWeek;
    aggMultiplier = 1;
case "Month":
    timeInterval = periodMonth;
    aggMultiplier = 1;
}
def agg_count = CompoundValue(1, if timeInterval != timeInterval[1]
                                 then (GetValue(agg_count, 1) + timeInterval -
                                                  timeInterval[1]) % aggMultiplier
                                 else GetValue(agg_count, 1), 0);
def agg_cond = CompoundValue(1,  agg_count < agg_count[1] + timeInterval -
                                                            timeInterval[1], yes);
def digit = CompoundValue(1, if cond
                             then 1
                             else agg_cond + GetValue(digit, 1), 1);
profile monkey = MonkeyBars(digit,
                "startNewProfile" = cond,
                "onExpansion" = onExpansion,
                "numberOfProfiles" = profiles,
                "pricePerRow" = height,
                "the playground percent" = thePlaygroundPercent,
                "emphasize first digit" = emphasizeFirstDigit,
                "volumeProfileShowStyle" = volumeShowStyle,
                "volumePercentVA" = theVolumePercent,
                "show initial balance" = showInitialBalance,
                "initial balance range" = initialBalanceRange);
def con = CompoundValue(1, onExpansion, no);
def mbar = CompoundValue(1, if IsNaN(monkey.GetPointOfControl()) and con then GetValue(mbar, 1) else monkey.GetPointOfControl(), monkey.GetPointOfControl());
def hPG = CompoundValue(1, if IsNaN(monkey.GetHighestValueArea()) and con then GetValue(hPG, 1) else monkey.GetHighestValueArea(), monkey.GetHighestValueArea());
def lPG = CompoundValue(1, if IsNaN(monkey.GetLowestValueArea()) and con then GetValue(lPG, 1) else monkey.GetLowestValueArea(), monkey.GetLowestValueArea());
def hProfile = CompoundValue(1, if IsNaN(monkey.GetHighest()) and con then GetValue(hProfile, 1) else monkey.GetHighest(), monkey.GetHighest());
def lProfile = CompoundValue(1, if IsNaN(monkey.GetLowest()) and con then GetValue(lProfile, 1) else monkey.GetLowest(), monkey.GetLowest());
def plotsDomain = IsNaN(close) == onExpansion;

def VWAP_Data = vwap(period = getAggregationPeriod());
profile vwap_Profile = DataProfile(data = vwap_data,
                "startNewProfile" = t,
                "onExpansion" = onExpansion,
                "numberOfProfiles" = profiles
                 );
plot vwap_poc = VWAP_Profile.getPointofControl();
vwap_poc.setpaintingStrategy(paintingStrategy.LINE_Vs_Triangles);
vwap_poc.assignValueColor(color.white);
plot vWap_p = vwap_data;
vwap_p.setpaintingStrategy(paintingStrategy.LINE_Vs_points);
vwap_p.setlineWeight(2);
VWAP_p.assignValueColor(if vwap_p >= vwap_p[1] then color.cyan else color.magenta);
vWAP_P.hide();

def VWAPbar = CompoundValue(1, if IsNaN(vwap_profile.GetPointOfControl()) and con then GetValue(VWAPBAR, 1) else vwap_profile.GetPointOfControl(), vwap_profile.GetPointOfControl());


profile tpo = TimeProfile("startNewProfile" = t,
                          "onExpansion" = 0,
                          "numberOfProfiles" = profiles,
                          "pricePerRow" =  tickSize(),
                          "value area percent" = 70);
def showPointOfControl = yes;
def showValueArea = no;

plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
plot PGHigh = if plotsDomain then hPG else Double.NaN;
plot PGLow = if plotsDomain then lPG else Double.NaN;

DefineGlobalColor("Monkey Bar", GetColor(4));
DefineGlobalColor("The Playground", GetColor(3));
DefineGlobalColor("Open Price", GetColor(1));
DefineGlobalColor("Close Price", GetColor(1));
DefineGlobalColor("Volume", GetColor(8));
DefineGlobalColor("Volume Value Area", GetColor(2));
DefineGlobalColor("Volume Point of Control", GetColor(3));
DefineGlobalColor("Initial Balance", GetColor(7));
DefineGlobalColor("Profiles", GetColor(1));

tpo.Show(GlobalColor("Profiles"), if showPointOfControl
                                 then GlobalColor("Volume Point Of Control")
                                 else Color.CURRENT,
                                 if showValueArea
                                 then GlobalColor("Volume Value Area")
                                 else Color.CURRENT, opacity);

plot MB = if plotsDomain then mbar else Double.NaN;


MB.SetDefaultColor(GlobalColor("Monkey Bar"));
MB.SetPaintingStrategy(PaintingStrategy.Line_vs_Points);
PGHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PGLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PGHigh.SetDefaultColor(GlobalColor("The Playground"));
PGLow.SetDefaultColor(GlobalColor("The Playground"));
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.Hide();
ProfileLow.Hide();
PGHigh.hide();
PGLow.hide();


#-----end function list ---------------

#--- end 8/21/2022

Scanner code --
Select a timeframe
Select a multiplier >=2 (default is 5) Scan will use anticipated price value Support and Resistances based on the multiplier (multiplier means the number of bars for the timeframe).




P8gdxPW.jpg


BLCSmVo.jpg



Code:
#
# Created by TraderZen
# Last update 8/23/2022
# Scanner for Anticipated Price Levels
#
#

input applyPersonsLevelsFilter = yes;
input marketThreshold = 0.0025;
input tf_Multiplier = 5;
input showLabel = {default "Yes", "No"};
input Show_Level_Lines = {default "All", "Mid", "High-Low", "None"};

def CurrentTP = GetAggregationPeriod();

def thisTP;
thisTP = GetAggregationPeriod();


Def HigherTP = ThisTp * tf_Multiplier;

def PP2TP = high(period = thisTP)[1] + low(period = thisTP)[1] + close(period = thisTP)[1];
def marketTypeTP = { DISABLED,  NEUTRAL, BEARISH, default BULLISH};

marketTypeTP = if !applyPersonsLevelsFilter then marketTypeTP.DISABLED
                else if PP2TP[-1] > (PP2TP[-1] + PP2TP + PP2TP[1]) / 3 + marketThreshold then marketTypeTP.BULLISH
                else if PP2TP[-1] < (PP2TP[-1] + PP2TP + PP2TP[1]) / 3 - marketThreshold then marketTypeTP.BEARISH
                else marketTypeTP.NEUTRAL;

def AlgoExec = if HigherTP <= thisTP then no else yes;
#AddLabel(yes, if AlgoExec == no then "No Execution: The Current Time Period Should be Less then the Selected Time Period! " + HigherTP else "Trend:" ,
#        Color.WHITE) ;

def P = HigherTP / CurrentTP;

def Higher =  fold nH = 1 to P + 1 with Top_high     do  Max(high(Period = thisTP)[P], high(Period = thisTP)[P + 1]) ;
def Lower  =  fold nL = 1 to P + 1 with Bottom_Low   do  Min(low(Period = thisTP)[P], low(Period = thisTP)[P + 1]);
def closer  = close[1];


#AddLabel(Yes, higher + " " + lower + " " + closer);

def PP2HP = Higher + Lower + closer;
def MarketTypeHP = { DISABLED,  NEUTRAL,  BEARISH, default BULLISH};

MarketTypeHP = if !applyPersonsLevelsFilter then MarketTypeHP.DISABLED
        else if PP2HP[-1] > (PP2HP[-1] + PP2HP + PP2HP[1]) / 3 + marketThreshold then MarketTypeHP.BULLISH
        else if PP2HP[-1] < (PP2HP[-1] + PP2HP + PP2HP[1]) / 3 - marketThreshold then MarketTypeHP.BEARISH
        else MarketTypeHP.NEUTRAL;

def paintingStrategy1 = PaintingStrategy.LINE;

#def paintingStrategy2 = if HigherTP == AggregationPeriod.Min then PaintingStrategy.LINE_VS_TRIANGLES
#                       else if HigherTP == AggregationPeriod.Five_Min or HigherTP == AggregationPeriod.Fifteen_Min then PaintingStrategy.LINE_VS_SQUARES
#                       else PaintingStrategy.LINE;
def paintingStrategy2 = PaintingStrategy.LINE;

## -- Pivote points + Trigger points + phase to calculate Trend.

## -- Initiate Variables

def HigherTP_PP_I;
def HigherTP_R1_I;
def HigherTP_R2_I;
def HigherTP_R3_I;
def HigherTP_S1_I;
def HigherTP_S2_I;
def HigherTP_S3_I;
def HigherTP_RR_I;
def HigherTP_SS_I;

## -- Conditionally Assign Values

if AlgoExec == no # or !IsNaN(close(period = HigherTP)[-1])
Then
{


    HigherTP_PP_I = Double.NaN;
    HigherTP_R1_I = Double.NaN;
    HigherTP_R2_I = Double.NaN;
 
    HigherTP_R3_I = Double.NaN;
 
    HigherTP_S1_I = Double.NaN;
 
    HigherTP_S2_I = Double.NaN;
    HigherTP_S3_I = Double.NaN;
    
    HigherTP_RR_I = Double.NaN;
  
    HigherTP_SS_I = Double.NaN;
    


}
else
{

    HigherTP_PP_I = (Higher[1] + Lower[1] + close[1]) / 3;
    HigherTP_R1_I = 2 * HigherTP_PP_I - Lower[1];
    HigherTP_R2_I = HigherTP_PP_I + Higher[1] - Lower[1];
    HigherTP_R3_I = HigherTP_R2_I + Higher[1] - Lower[1];
    HigherTP_S1_I = 2 * HigherTP_PP_I - Higher[1];
    HigherTP_S2_I = HigherTP_PP_I - Higher[1] + Lower[1];
    HigherTP_S3_I = HigherTP_S2_I - Higher[1] + Lower[1];
    HigherTP_RR_I = if (MarketTypeHP == MarketTypeHP.BEARISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_R1_I else HigherTP_R2_I;
    HigherTP_SS_I = if (MarketTypeHP == MarketTypeHP.BULLISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_S1_I else HigherTP_S2_I;

}


plot P_HigherTP_PP_I = HigherTP_PP_I;
plot P_HigherTP_R1_I = HigherTP_R1_I;
plot P_HigherTP_R2_I = HigherTP_R2_I;
plot P_HigherTP_R3_I = HigherTP_R3_I;
plot P_HigherTP_S1_I = HigherTP_S1_I;
plot P_HigherTP_S2_I = HigherTP_S2_I;
plot P_HigherTP_S3_I = HigherTP_S3_I;
plot P_HigherTP_RR_I = HigherTP_RR_I;
plot P_HigherTP_SS_I = HigherTP_SS_I;


#P_HigherTP_S1_I.Hide();
#P_HigherTP_S2_I.Hide();
#P_HigherTP_S3_I.Hide();
#P_HigherTP_R1_I.Hide();
#P_HigherTP_R2_I.Hide();
#P_HigherTP_R3_I.Hide();
#P_HigherTP_RR_I.Hide();
#P_HigherTP_SS_I.Hide();
#P_HigherTP_PP_I.Hide();

## -- Arrangement to reference the higher timeframe data (AP = AggergationPeriod).

plot P_Close = close(priceType = PriceType.LAST);


######################################### ------ Color coding 

P_Close.AssignValueColor( Color.LIGHT_GRAY);
P_HigherTP_PP_I.AssignValueColor(Color.LIGHT_GRAY);
 
input MACDBB_FastLength = 12;
input MACDBB_SlowLength = 26;
input MACDBB_BandLength = 9;
input MACDBB_NumDev = 1.0;

Def HigherTP_PP_BB_High = reference BollingerBands(price = P_HigherTP_RR_I, length = MACDBB_BandLength,
                                            Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).UpperBand;
def HigherTP_PP_BB_LOW = reference BollingerBands(price = P_HigherTP_SS_I, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).Lowerband;

P_Close.SetPaintingStrategy(paintingStrategy2);
P_Close.SetLineWeight(1);

#End 8/23/20222
 
Last edited:
Multi Time Frame Anticipated Price Level Indicator.
Color Coded Twenty Four Steps of trend Cycles from Bearish to Bullish and vice-versa.
Color coded six phases of a trade cycle.
Entry and Exit Points.
Trend Reversal Indications.
5uLCbSL.png

Code:
##-------------------------------------------------------------------------------------------
# MTF Anticipated Price Level with 24 Steps of 6 phases in a trade Cycle.
# TraderZen
#
##------------------------------------------------------------------------------------------

input applyPersonsLevelsFilter = yes;
input marketThreshold = 0.0025;
input timeFrame = {Min,   Five_Min, Ten_Min, Fifteen_Min, Thirty_Min,  default  hour };
input showLabel = {default "Yes", "No"};

def CurrentTP = GetAggregationPeriod();

def thisTP;
thisTP = CurrentTP;


def HigherTP = if timeFrame == timeFrame."Five_Min" then AggregationPeriod.FIVE_MIN
              else if timeFrame == timeFrame."Fifteen_Min" then AggregationPeriod.FIFTEEN_MIN
              else if timeFrame == timeFrame."Ten_Min" then AggregationPeriod.TEN_MIN
              else if timeFrame == timeFrame."hour" then AggregationPeriod.HOUR
              else if timeFrame == timeFrame."Thirty_Min" then AggregationPeriod.THIRTY_MIN
              else if timeFrame == timeFrame."Min" then AggregationPeriod.MIN
              else thisTP * 4;

def PP2TP = high(period = thisTP)[1] + low(period = thisTP)[1] + close(period = thisTP)[1];
def marketTypeTP = { DISABLED,  NEUTRAL, BEARISH, default BULLISH};

marketTypeTP = if !applyPersonsLevelsFilter then marketTypeTP.DISABLED
                else if PP2TP[-1] > (PP2TP[-1] + PP2TP + PP2TP[1]) / 3 + marketThreshold then marketTypeTP.BULLISH
                else if PP2TP[-1] < (PP2TP[-1] + PP2TP + PP2TP[1]) / 3 - marketThreshold then marketTypeTP.BEARISH
                else marketTypeTP.NEUTRAL;

def AlgoExec = if HigherTP <= thisTP then no else yes;
AddLabel(yes, if AlgoExec == no then "No Execution: The Current Time Period Should be Less then the Selected Time Period! " + HigherTP else "Trend:" ,
        Color.WHITE) ;

def P = HigherTP / CurrentTP;

def Higher =  fold nH = 1 to P + 1 with Top_high     do  Max(high(Period = thisTP)[P], high(Period = thisTP)[P + 1]) ;
def Lower  =  fold nL = 1 to P + 1 with Bottom_Low   do  Min(low(Period = thisTP)[P], low(Period = thisTP)[P + 1]);
def closer  = close[1];

#def higher  = high(period = HigherTP)[1];
#def Lower   = low(period = HigherTP)[1];
#def Closer  =  close(period = HigherTP)[1];

#AddLabel(Yes, higher + " " + lower + " " + closer);

def PP2HP = Higher + Lower + closer;
def MarketTypeHP = { DISABLED,  NEUTRAL,  BEARISH, default BULLISH};

MarketTypeHP = if !applyPersonsLevelsFilter then MarketTypeHP.DISABLED
        else if PP2HP[-1] > (PP2HP[-1] + PP2HP + PP2HP[1]) / 3 + marketThreshold then MarketTypeHP.BULLISH
        else if PP2HP[-1] < (PP2HP[-1] + PP2HP + PP2HP[1]) / 3 - marketThreshold then MarketTypeHP.BEARISH
        else MarketTypeHP.NEUTRAL;

#def paintingStrategy1 = if getAggregationPeriod() == AggregationPeriod.Min then PaintingStrategy.LINE_VS_TRIANGLES
#                       else if getAggregationPeriod() == AggregationPeriod.FIVE_MIN
#                            or getAggregationPeriod() == AggregationPeriod.FIFTEEN_MIN then
#                            PaintingStrategy.LINE_VS_SQUARES
#                       else PaintingStrategy.LINE;
def paintingStrategy1 = PaintingStrategy.LINE;

#def paintingStrategy2 = if HigherTP == AggregationPeriod.Min then PaintingStrategy.LINE_VS_TRIANGLES
#                       else if HigherTP == AggregationPeriod.Five_Min or HigherTP == AggregationPeriod.Fifteen_Min then PaintingStrategy.LINE_VS_SQUARES
#                       else PaintingStrategy.LINE;
def paintingStrategy2 = PaintingStrategy.LINE;

## -- Pivote points + Trigger points + phase to calculate Trend.

## -- Initiate Variables

def HigherTP_PP;
def HigherTP_R1;
def HigherTP_R2;
def HigherTP_R3;
def HigherTP_S1;
def HigherTP_S2;
def HigherTP_S3;
def HigherTP_RR;
def HigherTP_SS;

def HigherTP_PP_I;
def HigherTP_R1_I;
def HigherTP_R2_I;
def HigherTP_R3_I;
def HigherTP_S1_I;
def HigherTP_S2_I;
def HigherTP_S3_I;
def HigherTP_RR_I;
def HigherTP_SS_I;

## -- Conditionally Assign Values

if AlgoExec == no # or !IsNaN(close(period = HigherTP)[-1])
Then
{

    HigherTP_PP = Double.NaN;
    HigherTP_R1 = Double.NaN;
    HigherTP_R2 = Double.NaN;
    HigherTP_R3 = Double.NaN;
    HigherTP_S1 = Double.NaN;
    HigherTP_S2 = Double.NaN;
    HigherTP_S3 = Double.NaN;
    HigherTP_RR = Double.NaN;
    HigherTP_SS = Double.NaN;

    HigherTP_PP_I = Double.NaN;
    ;
    HigherTP_R1_I = Double.NaN;
    HigherTP_R2_I = Double.NaN;
    ;
    HigherTP_R3_I = Double.NaN;
    ;
    HigherTP_S1_I = Double.NaN;
    ;
    HigherTP_S2_I = Double.NaN;
    ;
    HigherTP_S3_I = Double.NaN;
    ;
    HigherTP_RR_I = Double.NaN;
    ;
    HigherTP_SS_I = Double.NaN;
    ;


}
else
{

    HigherTP_PP = (high(period = HigherTP)[1] + low(period = HigherTP)[1] + close(period = HigherTP)[1]) / 3;
    ;
    HigherTP_R1 = 2 * HigherTP_PP - low(period = HigherTP)[1];
    ;
    HigherTP_R2 = HigherTP_PP + high(period = HigherTP)[1] - low(period = HigherTP)[1];
    HigherTP_R3 = HigherTP_R2 + high(period = HigherTP)[1] - low(period = HigherTP)[1];
    HigherTP_S1 = 2 * HigherTP_PP - high(period = HigherTP)[1];
    HigherTP_S2 = HigherTP_PP - high(period = HigherTP)[1] + low(period = HigherTP)[1];
    HigherTP_S3 = HigherTP_S2 - high(period = HigherTP)[1] + low(period = HigherTP)[1];
    HigherTP_RR = if (MarketTypeHP == MarketTypeHP.BEARISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_R1 else HigherTP_R2;
    HigherTP_SS = if (MarketTypeHP == MarketTypeHP.BULLISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_S1 else HigherTP_S2;

    HigherTP_PP_I = (Higher[1] + Lower[1] + closer[1]) / 3;
    ;
    HigherTP_R1_I = 2 * HigherTP_PP - Lower[1];
    ;
    HigherTP_R2_I = HigherTP_PP + Higher[1] - Lower[1];
    HigherTP_R3_I = HigherTP_R2 + Higher[1] - Lower[1];
    HigherTP_S1_I = 2 * HigherTP_PP - Higher[1];
    HigherTP_S2_I = HigherTP_PP - Higher[1] + Lower[1];
    HigherTP_S3_I = HigherTP_S2 - Higher[1] + Lower[1];
    HigherTP_RR_I = if (MarketTypeHP == MarketTypeHP.BEARISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_R1 else HigherTP_R2;
    HigherTP_SS_I = if (MarketTypeHP == MarketTypeHP.BULLISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_S1 else HigherTP_S2;

}


plot P_HigherTP_PP = HigherTP_PP;
plot P_HigherTP_R1 = HigherTP_R1;
plot P_HigherTP_R2 = HigherTP_R2;
plot P_HigherTP_R3 = HigherTP_R3;
plot P_HigherTP_S1 = HigherTP_S1;
plot P_HigherTP_S2 = HigherTP_S2;
plot P_HigherTP_S3 = HigherTP_S3;
plot P_HigherTP_RR = HigherTP_RR;
plot P_HigherTP_SS = HigherTP_SS;

plot P_HigherTP_PP_I = HigherTP_PP_I;
plot P_HigherTP_R1_I = HigherTP_R1_I;
plot P_HigherTP_R2_I = HigherTP_R2_I;
plot P_HigherTP_R3_I = HigherTP_R3_I;
plot P_HigherTP_S1_I = HigherTP_S1_I;
plot P_HigherTP_S2_I = HigherTP_S2_I;
plot P_HigherTP_S3_I = HigherTP_S3_I;
plot P_HigherTP_RR_I = HigherTP_RR_I;
plot P_HigherTP_SS_I = HigherTP_SS_I;


P_HigherTP_RR.SetHiding(!applyPersonsLevelsFilter);
P_HigherTP_R1.SetHiding(applyPersonsLevelsFilter);
P_HigherTP_R2.SetHiding(applyPersonsLevelsFilter);
P_HigherTP_SS.SetHiding(!applyPersonsLevelsFilter);
P_HigherTP_S1.SetHiding(applyPersonsLevelsFilter);
P_HigherTP_S2.SetHiding(applyPersonsLevelsFilter);


P_HigherTP_PP.SetDefaultColor(GetColor(3));
P_HigherTP_R1.SetDefaultColor(GetColor(5));
P_HigherTP_R2.SetDefaultColor(GetColor(5));
P_HigherTP_R3.SetDefaultColor(GetColor(6));
P_HigherTP_S1.SetDefaultColor(GetColor(5));
P_HigherTP_S2.SetDefaultColor(GetColor(5));
P_HigherTP_S3.SetDefaultColor(GetColor(5));

P_HigherTP_SS.DefineColor("P_HigherTP_S1", GetColor(5));
P_HigherTP_SS.DefineColor("P_HigherTP_S2", GetColor(5));
P_HigherTP_SS.AssignValueColor(if P_HigherTP_SS == P_HigherTP_S1 then P_HigherTP_SS.Color("P_HigherTP_S1") else P_HigherTP_SS.Color("P_HigherTP_S2"));

P_HigherTP_RR.DefineColor("P_HigherTP_R1", GetColor(6));
P_HigherTP_RR.DefineColor("P_HigherTP_R2", GetColor(6));
P_HigherTP_RR.AssignValueColor(if P_HigherTP_RR == P_HigherTP_R1 then P_HigherTP_RR.Color("P_HigherTP_R1") else P_HigherTP_RR.Color("P_HigherTP_R2"));

P_HigherTP_PP.SetStyle(Curve.LONG_DASH);
P_HigherTP_RR.SetStyle(Curve.SHORT_DASH);
P_HigherTP_R1.SetStyle(Curve.SHORT_DASH);
P_HigherTP_R2.SetStyle(Curve.SHORT_DASH);
P_HigherTP_R3.SetStyle(Curve.SHORT_DASH);
P_HigherTP_SS.SetStyle(Curve.SHORT_DASH);
P_HigherTP_S1.SetStyle(Curve.SHORT_DASH);
P_HigherTP_S2.SetStyle(Curve.SHORT_DASH);
P_HigherTP_S3.SetStyle(Curve.SHORT_DASH);


P_HigherTP_PP.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_RR.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_R1.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_R2.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_R3.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_SS.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_S1.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_S2.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_S3.SetPaintingStrategy(paintingStrategy2);


P_HigherTP_S1.Hide();
P_HigherTP_S2.Hide();
P_HigherTP_S3.Hide();
P_HigherTP_R1.Hide();
P_HigherTP_R2.Hide();
P_HigherTP_R3.Hide();
#P_HigherTP_rr.hide();
#P_HigherTP_ss.hide();
#P_HigherTP_pp.hide();


P_HigherTP_S1_I.Hide();
P_HigherTP_S2_I.Hide();
P_HigherTP_S3_I.Hide();
P_HigherTP_R1_I.Hide();
P_HigherTP_R2_I.Hide();
P_HigherTP_R3_I.Hide();
P_HigherTP_RR_I.Hide();
P_HigherTP_SS_I.Hide();
P_HigherTP_PP_I.Hide();

## -- Arrangement to reference the higher timeframe data (AP = AggergationPeriod).

def BullCalc = MovingAverage(3, PP2TP[-1] / 3, 3);
def BearCalc = MovingAverage(3, ( (PP2TP[-1] + PP2TP + PP2TP[1]) / 3) / 3 , 3);

rec BullCalcHP = MovingAverage(3, PP2HP[-1] / 3, 3);
rec BearCalcHP = MovingAverage(3, ( (PP2HP[-1] + PP2HP + PP2HP[1]) / 3) / 3 , 3);

plot p_bullC = BullCalc;
p_bullC.AssignValueColor(Color.WHITE);

plot p_BearC = BearCalc;
p_BearC.AssignValueColor(Color.GRAY);


plot P_BullCHP = BullCalcHP;
P_BullCHP.AssignValueColor(Color.WHITE);

plot p_BearCHP = BearCalcHP;
p_BearCHP.AssignValueColor(Color.YELLOW);


plot P_Close = close(priceType = PriceType.LAST);


rec bull = if (BullCalc[-1] crosses above BearCalc[-1] - marketThreshold) then yes else Double.NaN;
rec bear = if (BearCalc[-1] crosses above BullCalc[-1] - marketThreshold) then yes else Double.NaN;

rec BullHP = if  (BullCalcHP[-1] crosses above (BearCalcHP[-1] - marketThreshold))  then yes
             else Double.NaN;
def BearHP = if (BearCalcHP[-1] crosses above (BullCalcHP[-1] - marketThreshold))  then yes else Double.NaN;


plot P_bull = bull;
plot p_bear =  bear ;

plot P_BullHP = BullHP ;
plot p_BearHP = BearHP ;

P_bull.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
P_bull.SetDefaultColor(Color.GREEN);
p_bear.SetDefaultColor(Color.DARK_ORANGE);
p_bear.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

P_BullHP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
P_BullHP.SetDefaultColor(Color.CYAN);
p_BearHP.SetDefaultColor(Color.MAGENTA);
p_BearHP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

p_bullC.Hide();
p_BearC.Hide();

P_bull.Hide();
p_bear.Hide();

P_BullHP.Hide();
p_BearHP.Hide();

P_BullCHP.Hide();
p_BearCHP.Hide();

######################################### ------ Color coding

def C = P_Close;

def v50  = Round(SimpleMovingAvg(close, 50)); # MovAvgExponential(close, 50);
def v100 = Round(SimpleMovingAvg(close, 100));
def v200 = Round(SimpleMovingAvg(close, 200)); # MovAvgExponential(close, 200);
def F = v50;  # Duplicate variable for v50 to code the SeqNum Logic.
def H = v100; # Duplicate variable for v100 to code the SeqNum Logic.
def T = v200; # Duplicate variable for v200 to code the seqNum Logic.
def BB = Round(BollingerBands()."MidLine");

def ROCFlag = if RateOfChange() > RateOfChange()[1] then 1
              else if RateOfChange() < RateOfChange()[1] then -1
              else 0;

def ROCFlag2 = if RateOfChange() > 0 then 1
               else if RateOfChange() < 0 then -1
               else 0;

def MACDOpen = if MACD()."value" >= MACD()."value"[1] and MACD()."value" > MACD()."avg" then 1
               else if MACD()."value" <  MACD()."value"[1] and MACD()."value" < MACD()."avg" then -1
               else 0;

def PlayzoneFlag = if  ROCFlag == 1 and MACDOpen == 1  then 2
                   else if ROCFlag2 == 1 and MACDOpen == 1 then 2
                   else if ROCFlag == -1 and MACDOpen == -1 then -2
                   else if ROCFlag2 == -1 and MACDOpen == -1 then -2
                   else 0;

def Phase = if (close >= v50  and close >= v200 and v50   >= v200) then 1 #Bullish
       else if (close >= v50  and close >= v200 and v50   <= v200) then 2 #Accumulation
       else if (  v50 <= v200 and close <= v200 and close >= v50)  then 3 # Recovery
       else if (close <= v50  and close >= v200 and v50   >= v200) then 4 # Warning
       else if (close <= v50  and close <= v200 and v50   >= v200) then 5 #Distribution
       else if (  v50 <= v200 and close <= v200 and close <= v50 ) then 6 #Bearish
       else 7;

def ScalpCode = if ( (C >= BB) and (BB > BB[1])  and (BB >= F) ) then 101 # Bullish Superseed condition
         else if ( (F >= BB) and (BB[1] >= BB) and (BB >= C) ) then -101 # Bearish Superseed condition
         else if ( (C >= BB) and (BB >= F) ) then 100 #Still Bullish Strong
         else if ( (F >= BB) and (BB >= C) ) then -100 #Still Bearish Strong  
         else if ( close >= Highest(close[1], 50)) then 75 #C50 Up
         else if ( close <= Lowest(close[1], 50)) then -75  #c50 Down  
         else if ( BB >= BB[1]) then 50 #Uptrend
         else if ( BB[1] >= BB) then -50 #DownTrend
         else 0;

def SeqNum =  if ((C >= F) and (F >= H) and (H >= T)) then 1 #Step-3 Bullish phase Confirmed [1] (C-F-H-T)
         else if ((C >= F) and (F >= T) and (T >= H)) then 2 #Step-2 Bullish Confirmation AKA Accumuation [2] (C-F-T-H)
         else if ((C >= H) and (H >= F) and (F >= T)) or
                 (close >= Highest(close[1], 50))     then 3 #Ambiguous Bullish. Check the C, Phase, Playzone and Higher Time-Frame. (C-H-F-T)
         else if ((C >= H) and (H >= T) and (T >= F)) then 4 #Ambiguous Bullish. Check the Phase, Playzone and Higher Time-Frame. (C-H-T-F)
         else if ((C >= T) and (T >= F) and (F >= H)) then 5 #Step-3 Bullish Breakout and re-test AKA Bullish [1] (C-T-F-H)
         else if ((C >= T) and (T >= H) and (H >= F)) then 6 #Step-1 Bullish Initiation AKA Recovery [3] (C-T-H-F)

         else if ((F >= C) and (C >= H) and (H >= T)) then 7 #Step-4.5 Bullish Maturation AKA Bullish (F-C-H-T)
         else if ((F >= C) and (C >= T) and (T >= H)) or
                 (close <= Lowest(close[1], 50))      then 8 #step-9 Bearish Maturation AKA Bearish. Check the C.[6] (F-C-T-H)
         else if ((F >= H) and (H >= C) and (C >= T)) then 9 #Step-4.5 Bullish Maturation [PullBack, Not Real Distribution] [4] (F-H-C-T)
         else if ((F >= H) and (H >= T) and (T >= C)) then 10 #Step-6 Bearish Initiation AKA Warning [4] (F-H-T-C)
         else if ((F >= T) and (T >= C) and (C >= H)) then 11 #Ambiguous-11 Check the Phase, Playzone and Higher Time-Frame(F-T-C-H)
         else if ((F >= T) and (T >= H) and (H >= C)) then 12 #Step-7 Bearish Breakout and Re-test AKA Bearish [6]

         else if ((H >= C) and (C >= F) and (F >= T)) then 13 #Step-4 Bullish Maturation AKA Bullish [1] (H-C-F-T)
         else if ((H >= C) and (C >= T) and (T >= F)) then 14 #Ambiguous-14 Check the Phase, Playzone and Higher Time-Frame(H-C-T-F)
         else if ((H >= F) and (F >= C) and (C >= T)) then 15 #Step-5 Bullish Exhaustion (H-F-C-T) Review!
         else if ((H >= F) and (F >= T) and (T >= C)) then 16 #Step-6.5 Bearish Comfirmation AKA Distribution (H-F-T-C)
         else if ((H >= T) and (T >= C) and (C >= F)) then 17 #Step-9.5 Bearish Exhaustion Confirmed (H-T-C-F)
         else if ((H >= T) and (T >= F) and (F >= C)) then 18 #Ambiguous-18 Check the Phase, Playzone and Higher Time-Frame(H-T-F-C)

         else if ((T >= C) and (C >= F) and (F >= H)) then 19 #Step-0.5 - Attempting to be Bullish. Watch ROC/MACD  [1] (T-C-F-H)
         else if ((T >= C) and (C >= H) and (H >= F)) then 20 #Step-10 - Attempting to be Bullish. Watch ROC/MACD [1] (T-C-H-F)
         else if ((T >= F) and (F >= C) and (C >= H)) then 21 #Step-4.5 Bullish Maturation [PullBack, Not Real Distribution] [4] (T-F-C-H)
         else if ((T >= F) and (F >= H) and (H >= C)) then 22 #Ambiguous Bearish. Check the Phase, Playzone and Higher Time-Frame. (T-G-H-C)
         else if ((T >= H) and (H >= C) and (C >= F)) then 23 #Ambiguoua-23 (T-H-C-F)
         else if ((T >= H) and (H >= F) and (F >= C)) then 24 #Step-9 Bearish Maturation [6] (T-H-F-c)

         else 0;



P_Close.AssignValueColor( if ScalpCode == 100 or ScalpCode == 75 then Color.GREEN
                      else if ScalpCode == 101 then Color.CYAN
                      else if ScalpCode == -100 or ScalpCode == -75 then Color.RED
                      else if ScalpCode == -101 then Color.PLUM
                      else if ScalpCode == 50 then Color.LIGHT_GREEN
                      else if ScalpCode == -50 then Color.PINK
                      else Color.LIGHT_GRAY);


P_HigherTP_PP.AssignValueColor( if SeqNum == 1 or  SeqNum == .5 then Color.CYAN
                            else if SeqNum == 2 or  SeqNum == 2.5 then Color.LIGHT_GREEN
                            else if SeqNum == 3 then Color.GREEN
                            else if SeqNum == 4 or  SeqNum == 4.5 then Color.LIGHT_GREEN
                            else if SeqNum == 5 or  SeqNum == 5.1 then Color.CYAN
                            else if SeqNum == 6 then Color.GREEN
                            else if SeqNum == 7 then Color.LIME
                            else if SeqNum == 8 then Color.RED
                            else if SeqNum == 9 or  SeqNum == 9.5 then Color.LIGHT_RED
                            else if SeqNum == 10 then Color.RED
                            else if SeqNum == 11 then Color.GRAY
                            else if SeqNum == 12 then Color.MAGENTA
                            else if SeqNum == 13 then Color.GREEN
                            else if SeqNum == 14 then Color.GRAY
                            else if SeqNum == 15 then Color.YELLOW
                            else if SeqNum == 16 then Color.MAGENTA
                            else if SeqNum == 17 then Color.YELLOW
                            else if SeqNum == 18 then Color.GRAY
                            else if SeqNum == 19 then Color.LIGHT_GREEN
                            else if SeqNum == 20 then Color.LIGHT_GREEN
                            else if SeqNum == 21 then Color.RED
                            else if SeqNum == 22 then Color.LIGHT_RED
                            else if SeqNum == 23 then Color.GRAY
                            else if SeqNum == 24 then Color.MAGENTA
                            else if SeqNum == 0 then Color.GRAY
                           else Color.LIGHT_GRAY
   
);

AddLabel(if showLabel == showLabel."Yes" then yes else no, SeqNum + " " +
    if SeqNum == 1 then "Bullish Confirmed"
         else if SeqNum == 2 then "Accumuation"
         else if SeqNum == 3 then "Ambiguous+Bullish"
         else if SeqNum == 4 then "Ambiguous+Bullish"
         else if SeqNum == 5 then "Bullish Breakout & Re-test"
         else if SeqNum == 6 then "Bullish Initiation"

         else if SeqNum == 7 then "Bullish Maturation"
         else if SeqNum == 8 then "Bearish Maturation"
         else if SeqNum == 9 then "PullBack,Not Real Distribution"
         else if SeqNum == 10 then "Bearish Initiation"
         else if SeqNum == 11 then "Ambiguous! May be in a channel"
         else if SeqNum == 12 then "Bearish Breakout & Re-test"

         else if SeqNum == 13 then "Bullish Maturation"
         else if SeqNum == 14 then "Ambiguous! May be in a channel"
         else if SeqNum == 15 then "Potential Reversal! Bullish Exhaustion"
         else if SeqNum == 16 then "Bearish Comfirmation/Distribution"
         else if SeqNum == 17 then "Bearish Exhaustion Confirmed"
         else if SeqNum == 18 then "Ambiguous-Bearish/Bearish Channel"

         else if SeqNum == 19 and PlayzoneFlag == 2 then "About to be Bullish"
         else if SeqNum == 19 and PlayzoneFlag == -2 then "About to be Bearish"
         else if SeqNum == 19 and PlayzoneFlag == 0 then "Ambiguous. Check Higher TF"
         else if SeqNum == 19 then "Ambiguous.Check Higher TF"
         else if SeqNum == 20 and PlayzoneFlag == 2 then "Bullish Attempt may fail"
         else if SeqNum == 20 and PlayzoneFlag == -2 then "Bearish attempt may fail"
         else if SeqNum == 20 and PlayzoneFlag == 0 then "Ambiguous. *Check Higher TF"
         else if SeqNum == 20 then "Ambiguous. Check Higher TF"
 
         else if SeqNum == 21 then "Bullish Maturation/PullBack, Not Real Distribution"
         else if SeqNum == 22 then "Ambiguous-Bearish. *Check Higher TF"
         else if SeqNum == 23 then "Ambiguous. Check Higher TF"
         else if SeqNum == 24 then "Bearish Trend. Check Higher TF"
         else "*" ,

         if SeqNum == 1 or  SeqNum == .5 then Color.CYAN
                            else if SeqNum == 2 or  SeqNum == 2.5 then Color.LIGHT_GREEN
                            else if SeqNum == 3 then Color.GREEN
                            else if SeqNum == 4 or  SeqNum == 4.5 then Color.LIGHT_GREEN
                            else if SeqNum == 5 or  SeqNum == 5.1 then Color.CYAN
                            else if SeqNum == 6 then Color.GREEN
                            else if SeqNum == 7 then Color.LIME
                            else if SeqNum == 8 then Color.RED
                            else if SeqNum == 9 or  SeqNum == 9.5 then Color.LIGHT_RED
                            else if SeqNum == 10 then Color.RED
                            else if SeqNum == 11 then Color.GRAY
                            else if SeqNum == 12 then Color.MAGENTA
                            else if SeqNum == 13 then Color.GREEN
                            else if SeqNum == 14 then Color.GRAY
                            else if SeqNum == 15 then Color.YELLOW
                            else if SeqNum == 16 then Color.MAGENTA
                            else if SeqNum == 17 then Color.YELLOW
                            else if SeqNum == 18 then Color.GRAY
                            else if SeqNum == 19 then Color.LIGHT_GREEN
                            else if SeqNum == 20 then Color.LIGHT_GREEN
                            else if SeqNum == 21 then Color.RED
                            else if SeqNum == 22 then Color.LIGHT_RED
                            else if SeqNum == 23 then Color.GRAY
                            else if SeqNum == 24 then Color.MAGENTA
                            else if SeqNum == 0 then Color.GRAY
                           else Color.LIGHT_GRAY );

AddLabel(if showLabel == showLabel."Yes" then yes else no,
       
         if P_Close >= P_HigherTP_PP then "Anticipated Level: " + P_HigherTP_R3  + " in next " + p + " Bars"
         else if P_Close <= P_HigherTP_PP then "Anticipated Level: " + P_HigherTP_S3  + " in next " + p + " Bars"
         else "Anticipated Price:"
         ,
         if P_Close >= P_HigherTP_PP then GetColor(6) else GetColor(5) );

P_Close.SetPaintingStrategy(paintingStrategy2);
P_Close.SetLineWeight(1);
P_BullCHP.SetLineWeight(1);
P_BullCHP.AssignValueColor(Color.WHITE);
P_Close.Hide();


# --- Cross over logic --
rec _Cross_Up = if P_Close crosses above P_HigherTP_PP_I then yes else no;
plot Cross_Up = if _Cross_Up != _Cross_Up[1] then _Cross_Up else Double.NaN;

plot Cross_Dn = if P_Close crosses below P_HigherTP_PP_I then yes else no;
Cross_Up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Cross_Dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Cross_Up.SetLineWeight(3);
Cross_Dn.SetLineWeight(3);
Cross_Up.AssignValueColor(Color.UPTICK);
Cross_Dn.AssignValueColor(Color.DOWNTICK);



#-- Paint Bars logic --
input PaintBars = { default "Yes", "No" } ;

AssignPriceColor(
        if PaintBars == PaintBars."Yes" then

         if ScalpCode == 100 or ScalpCode == 75 then Color.GREEN
                      else if ScalpCode == 101 then Color.CYAN
                      else if ScalpCode == -100 or ScalpCode == -75 then Color.RED
                      else if ScalpCode == -101 then Color.MAGENTA
                      else if ScalpCode == 50 then Color.LIGHT_GREEN
                      else if ScalpCode == -50 then Color.PINK
                      else Color.LIGHT_GRAY      
   
        else Color.CURRENT# RB
    );
thank you very much for your great work!! a quick question is this system repaint? it is look great! thank you in advance
 
thank you very much for your great work!! a quick question is this system repaint? it is look great! thank you in advance
FOTM_8888 - Please allow the candle to complete - it gives early warning, but old candles are not re-printed.

(Ignorable Esoteric BS): All indicators are lagging indicator in reality. Even the predictive ones. Any real-time prediction can only be done based on past events, and the system needs to be allowed time to infer the meaning of the event. Computers are fast so we do not feel the lag in real-time.
An indicator that relies on pivot points and/or the open/close/high/low calculations needs to be allowed to complete the candle for that timeframe.
This is why a trader is suggested to use multiple timeframes and tick charts. (1M, 5M,15M are commonly used).
 
Updated 12:45 8/6/2022 PST - A calculation correction.

Multi Time Frame Anticipated Price Level Indicator.
Color Coded Twenty Four Steps of trend Cycles from Bearish to Bullish and vice-versa.
Color coded six phases of a trade cycle.
Entry and Exit Points.
Trend Reversal Indications.


5uLCbSL.png

Code:
input applyPersonsLevelsFilter = yes;
input marketThreshold = 0.0025;
input timeFrame = {Min,   Five_Min, Ten_Min, Fifteen_Min, Thirty_Min,  default  hour };
input showLabel = {default "Yes", "No"};

def CurrentTP = GetAggregationPeriod();

def thisTP;
thisTP = CurrentTP;


def HigherTP = if timeFrame == timeFrame."Five_Min" then AggregationPeriod.FIVE_MIN
              else if timeFrame == timeFrame."Fifteen_Min" then AggregationPeriod.FIFTEEN_MIN
              else if timeFrame == timeFrame."Ten_Min" then AggregationPeriod.TEN_MIN
              else if timeFrame == timeFrame."hour" then AggregationPeriod.HOUR
              else if timeFrame == timeFrame."Thirty_Min" then AggregationPeriod.THIRTY_MIN
              else if timeFrame == timeFrame."Min" then AggregationPeriod.MIN
              else thisTP * 4;

def PP2TP = high(period = thisTP)[1] + low(period = thisTP)[1] + close(period = thisTP)[1];
def marketTypeTP = { DISABLED,  NEUTRAL, BEARISH, default BULLISH};

marketTypeTP = if !applyPersonsLevelsFilter then marketTypeTP.DISABLED
                else if PP2TP[-1] > (PP2TP[-1] + PP2TP + PP2TP[1]) / 3 + marketThreshold then marketTypeTP.BULLISH
                else if PP2TP[-1] < (PP2TP[-1] + PP2TP + PP2TP[1]) / 3 - marketThreshold then marketTypeTP.BEARISH
                else marketTypeTP.NEUTRAL;

def AlgoExec = if HigherTP <= thisTP then no else yes;
AddLabel(yes, if AlgoExec == no then "No Execution: The Current Time Period Should be Less then the Selected Time Period! " + HigherTP else "Trend:" ,
        Color.WHITE) ;

def P = HigherTP / CurrentTP;

def Higher =  fold nH = 1 to P + 1 with Top_high     do  Max(high(Period = thisTP)[P], high(Period = thisTP)[P + 1]) ;
def Lower  =  fold nL = 1 to P + 1 with Bottom_Low   do  Min(low(Period = thisTP)[P], low(Period = thisTP)[P + 1]);
def closer  = close[1];

#def higher  = high(period = HigherTP)[1];
#def Lower   = low(period = HigherTP)[1];
#def Closer  =  close(period = HigherTP)[1];

#AddLabel(Yes, higher + " " + lower + " " + closer);

def PP2HP = Higher + Lower + closer;
def MarketTypeHP = { DISABLED,  NEUTRAL,  BEARISH, default BULLISH};

MarketTypeHP = if !applyPersonsLevelsFilter then MarketTypeHP.DISABLED
        else if PP2HP[-1] > (PP2HP[-1] + PP2HP + PP2HP[1]) / 3 + marketThreshold then MarketTypeHP.BULLISH
        else if PP2HP[-1] < (PP2HP[-1] + PP2HP + PP2HP[1]) / 3 - marketThreshold then MarketTypeHP.BEARISH
        else MarketTypeHP.NEUTRAL;

#def paintingStrategy1 = if getAggregationPeriod() == AggregationPeriod.Min then PaintingStrategy.LINE_VS_TRIANGLES
#                       else if getAggregationPeriod() == AggregationPeriod.FIVE_MIN
#                            or getAggregationPeriod() == AggregationPeriod.FIFTEEN_MIN then
#                            PaintingStrategy.LINE_VS_SQUARES
#                       else PaintingStrategy.LINE;
def paintingStrategy1 = PaintingStrategy.LINE;

#def paintingStrategy2 = if HigherTP == AggregationPeriod.Min then PaintingStrategy.LINE_VS_TRIANGLES
#                       else if HigherTP == AggregationPeriod.Five_Min or HigherTP == AggregationPeriod.Fifteen_Min then PaintingStrategy.LINE_VS_SQUARES
#                       else PaintingStrategy.LINE;
def paintingStrategy2 = PaintingStrategy.LINE;

## -- Pivote points + Trigger points + phase to calculate Trend.

## -- Initiate Variables

def HigherTP_PP;
def HigherTP_R1;
def HigherTP_R2;
def HigherTP_R3;
def HigherTP_S1;
def HigherTP_S2;
def HigherTP_S3;
def HigherTP_RR;
def HigherTP_SS;

def HigherTP_PP_I;
def HigherTP_R1_I;
def HigherTP_R2_I;
def HigherTP_R3_I;
def HigherTP_S1_I;
def HigherTP_S2_I;
def HigherTP_S3_I;
def HigherTP_RR_I;
def HigherTP_SS_I;

## -- Conditionally Assign Values

if AlgoExec == no # or !IsNaN(close(period = HigherTP)[-1])
Then
{

    HigherTP_PP = Double.NaN;
    HigherTP_R1 = Double.NaN;
    HigherTP_R2 = Double.NaN;
    HigherTP_R3 = Double.NaN;
    HigherTP_S1 = Double.NaN;
    HigherTP_S2 = Double.NaN;
    HigherTP_S3 = Double.NaN;
    HigherTP_RR = Double.NaN;
    HigherTP_SS = Double.NaN;

    HigherTP_PP_I = Double.NaN;
    ;
    HigherTP_R1_I = Double.NaN;
    HigherTP_R2_I = Double.NaN;
    ;
    HigherTP_R3_I = Double.NaN;
    ;
    HigherTP_S1_I = Double.NaN;
    ;
    HigherTP_S2_I = Double.NaN;
    ;
    HigherTP_S3_I = Double.NaN;
    ;
    HigherTP_RR_I = Double.NaN;
    ;
    HigherTP_SS_I = Double.NaN;
    ;


}
else
{

    HigherTP_PP = (high(period = HigherTP)[1] + low(period = HigherTP)[1] + close(period = HigherTP)[1]) / 3;
    ;
    HigherTP_R1 = 2 * HigherTP_PP - low(period = HigherTP)[1];
    ;
    HigherTP_R2 = HigherTP_PP + high(period = HigherTP)[1] - low(period = HigherTP)[1];
    HigherTP_R3 = HigherTP_R2 + high(period = HigherTP)[1] - low(period = HigherTP)[1];
    HigherTP_S1 = 2 * HigherTP_PP - high(period = HigherTP)[1];
    HigherTP_S2 = HigherTP_PP - high(period = HigherTP)[1] + low(period = HigherTP)[1];
    HigherTP_S3 = HigherTP_S2 - high(period = HigherTP)[1] + low(period = HigherTP)[1];
    HigherTP_RR = if (MarketTypeHP == MarketTypeHP.BEARISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_R1 else HigherTP_R2;
    HigherTP_SS = if (MarketTypeHP == MarketTypeHP.BULLISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_S1 else HigherTP_S2;

    HigherTP_PP_I = (Higher[1] + Lower[1] + closer[1]) / 3;
    ;
    HigherTP_R1_I = 2 * HigherTP_PP - Lower[1];
    ;
    HigherTP_R2_I = HigherTP_PP + Higher[1] - Lower[1];
    HigherTP_R3_I = HigherTP_R2 + Higher[1] - Lower[1];
    HigherTP_S1_I = 2 * HigherTP_PP - Higher[1];
    HigherTP_S2_I = HigherTP_PP - Higher[1] + Lower[1];
    HigherTP_S3_I = HigherTP_S2 - Higher[1] + Lower[1];
    HigherTP_RR_I = if (MarketTypeHP == MarketTypeHP.BEARISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_R1 else HigherTP_R2;
    HigherTP_SS_I = if (MarketTypeHP == MarketTypeHP.BULLISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_S1 else HigherTP_S2;

}


plot P_HigherTP_PP = HigherTP_PP;
plot P_HigherTP_R1 = HigherTP_R1;
plot P_HigherTP_R2 = HigherTP_R2;
plot P_HigherTP_R3 = HigherTP_R3;
plot P_HigherTP_S1 = HigherTP_S1;
plot P_HigherTP_S2 = HigherTP_S2;
plot P_HigherTP_S3 = HigherTP_S3;
plot P_HigherTP_RR = HigherTP_RR;
plot P_HigherTP_SS = HigherTP_SS;

plot P_HigherTP_PP_I = HigherTP_PP_I;
plot P_HigherTP_R1_I = HigherTP_R1_I;
plot P_HigherTP_R2_I = HigherTP_R2_I;
plot P_HigherTP_R3_I = HigherTP_R3_I;
plot P_HigherTP_S1_I = HigherTP_S1_I;
plot P_HigherTP_S2_I = HigherTP_S2_I;
plot P_HigherTP_S3_I = HigherTP_S3_I;
plot P_HigherTP_RR_I = HigherTP_RR_I;
plot P_HigherTP_SS_I = HigherTP_SS_I;


P_HigherTP_RR.SetHiding(!applyPersonsLevelsFilter);
P_HigherTP_R1.SetHiding(applyPersonsLevelsFilter);
P_HigherTP_R2.SetHiding(applyPersonsLevelsFilter);
P_HigherTP_SS.SetHiding(!applyPersonsLevelsFilter);
P_HigherTP_S1.SetHiding(applyPersonsLevelsFilter);
P_HigherTP_S2.SetHiding(applyPersonsLevelsFilter);


P_HigherTP_PP.SetDefaultColor(GetColor(3));
P_HigherTP_R1.SetDefaultColor(GetColor(5));
P_HigherTP_R2.SetDefaultColor(GetColor(5));
P_HigherTP_R3.SetDefaultColor(GetColor(6));
P_HigherTP_S1.SetDefaultColor(GetColor(5));
P_HigherTP_S2.SetDefaultColor(GetColor(5));
P_HigherTP_S3.SetDefaultColor(GetColor(5));

P_HigherTP_SS.DefineColor("P_HigherTP_S1", GetColor(5));
P_HigherTP_SS.DefineColor("P_HigherTP_S2", GetColor(5));
P_HigherTP_SS.AssignValueColor(if P_HigherTP_SS == P_HigherTP_S1 then P_HigherTP_SS.Color("P_HigherTP_S1") else P_HigherTP_SS.Color("P_HigherTP_S2"));

P_HigherTP_RR.DefineColor("P_HigherTP_R1", GetColor(6));
P_HigherTP_RR.DefineColor("P_HigherTP_R2", GetColor(6));
P_HigherTP_RR.AssignValueColor(if P_HigherTP_RR == P_HigherTP_R1 then P_HigherTP_RR.Color("P_HigherTP_R1") else P_HigherTP_RR.Color("P_HigherTP_R2"));

P_HigherTP_PP.SetStyle(Curve.LONG_DASH);
P_HigherTP_RR.SetStyle(Curve.SHORT_DASH);
P_HigherTP_R1.SetStyle(Curve.SHORT_DASH);
P_HigherTP_R2.SetStyle(Curve.SHORT_DASH);
P_HigherTP_R3.SetStyle(Curve.SHORT_DASH);
P_HigherTP_SS.SetStyle(Curve.SHORT_DASH);
P_HigherTP_S1.SetStyle(Curve.SHORT_DASH);
P_HigherTP_S2.SetStyle(Curve.SHORT_DASH);
P_HigherTP_S3.SetStyle(Curve.SHORT_DASH);


P_HigherTP_PP.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_RR.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_R1.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_R2.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_R3.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_SS.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_S1.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_S2.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_S3.SetPaintingStrategy(paintingStrategy2);


P_HigherTP_S1.Hide();
P_HigherTP_S2.Hide();
P_HigherTP_S3.Hide();
P_HigherTP_R1.Hide();
P_HigherTP_R2.Hide();
P_HigherTP_R3.Hide();
#P_HigherTP_rr.hide();
#P_HigherTP_ss.hide();
#P_HigherTP_pp.hide();


P_HigherTP_S1_I.Hide();
P_HigherTP_S2_I.Hide();
P_HigherTP_S3_I.Hide();
P_HigherTP_R1_I.Hide();
P_HigherTP_R2_I.Hide();
P_HigherTP_R3_I.Hide();
P_HigherTP_RR_I.Hide();
P_HigherTP_SS_I.Hide();
P_HigherTP_PP_I.Hide();

## -- Arrangement to reference the higher timeframe data (AP = AggergationPeriod).

def BullCalc = MovingAverage(3, PP2TP[-1] / 3, 3);
def BearCalc = MovingAverage(3, ( (PP2TP[-1] + PP2TP + PP2TP[1]) / 3) / 3 , 3);

rec BullCalcHP = MovingAverage(3, PP2HP[-1] / 3, 3);
rec BearCalcHP = MovingAverage(3, ( (PP2HP[-1] + PP2HP + PP2HP[1]) / 3) / 3 , 3);

plot p_bullC = BullCalc;
p_bullC.AssignValueColor(Color.WHITE);

plot p_BearC = BearCalc;
p_BearC.AssignValueColor(Color.GRAY);


plot P_BullCHP = BullCalcHP;
P_BullCHP.AssignValueColor(Color.WHITE);

plot p_BearCHP = BearCalcHP;
p_BearCHP.AssignValueColor(Color.YELLOW);


plot P_Close = close(priceType = PriceType.LAST);


rec bull = if (BullCalc[-1] crosses above BearCalc[-1] - marketThreshold) then yes else Double.NaN;
rec bear = if (BearCalc[-1] crosses above BullCalc[-1] - marketThreshold) then yes else Double.NaN;

rec BullHP = if  (BullCalcHP[-1] crosses above (BearCalcHP[-1] - marketThreshold))  then yes
             else Double.NaN;
def BearHP = if (BearCalcHP[-1] crosses above (BullCalcHP[-1] - marketThreshold))  then yes else Double.NaN;


plot P_bull = bull;
plot p_bear =  bear ;

plot P_BullHP = BullHP ;
plot p_BearHP = BearHP ;

P_bull.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
P_bull.SetDefaultColor(Color.GREEN);
p_bear.SetDefaultColor(Color.DARK_ORANGE);
p_bear.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

P_BullHP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
P_BullHP.SetDefaultColor(Color.CYAN);
p_BearHP.SetDefaultColor(Color.MAGENTA);
p_BearHP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

p_bullC.Hide();
p_BearC.Hide();

P_bull.Hide();
p_bear.Hide();

P_BullHP.Hide();
p_BearHP.Hide();

P_BullCHP.Hide();
p_BearCHP.Hide();

######################################### ------ Color coding

def C = P_Close;

def v50  = Round(SimpleMovingAvg(close, 50)); # MovAvgExponential(close, 50);
def v100 = Round(SimpleMovingAvg(close, 100));
def v200 = Round(SimpleMovingAvg(close, 200)); # MovAvgExponential(close, 200);
def F = v50;  # Duplicate variable for v50 to code the SeqNum Logic.
def H = v100; # Duplicate variable for v100 to code the SeqNum Logic.
def T = v200; # Duplicate variable for v200 to code the seqNum Logic.
def BB = Round(BollingerBands()."MidLine");

def ROCFlag = if RateOfChange() > RateOfChange()[1] then 1
              else if RateOfChange() < RateOfChange()[1] then -1
              else 0;

def ROCFlag2 = if RateOfChange() > 0 then 1
               else if RateOfChange() < 0 then -1
               else 0;

def MACDOpen = if MACD()."value" >= MACD()."value"[1] and MACD()."value" > MACD()."avg" then 1
               else if MACD()."value" <  MACD()."value"[1] and MACD()."value" < MACD()."avg" then -1
               else 0;

def PlayzoneFlag = if  ROCFlag == 1 and MACDOpen == 1  then 2
                   else if ROCFlag2 == 1 and MACDOpen == 1 then 2
                   else if ROCFlag == -1 and MACDOpen == -1 then -2
                   else if ROCFlag2 == -1 and MACDOpen == -1 then -2
                   else 0;

def Phase = if (close >= v50  and close >= v200 and v50   >= v200) then 1 #Bullish
       else if (close >= v50  and close >= v200 and v50   <= v200) then 2 #Accumulation
       else if (  v50 <= v200 and close <= v200 and close >= v50)  then 3 # Recovery
       else if (close <= v50  and close >= v200 and v50   >= v200) then 4 # Warning
       else if (close <= v50  and close <= v200 and v50   >= v200) then 5 #Distribution
       else if (  v50 <= v200 and close <= v200 and close <= v50 ) then 6 #Bearish
       else 7;

def ScalpCode = if ( (C >= BB) and (BB > BB[1])  and (BB >= F) ) then 101 # Bullish Superseed condition
         else if ( (F >= BB) and (BB[1] >= BB) and (BB >= C) ) then -101 # Bearish Superseed condition
         else if ( (C >= BB) and (BB >= F) ) then 100 #Still Bullish Strong
         else if ( (F >= BB) and (BB >= C) ) then -100 #Still Bearish Strong 
         else if ( close >= Highest(close[1], 50)) then 75 #C50 Up
         else if ( close <= Lowest(close[1], 50)) then -75  #c50 Down 
         else if ( BB >= BB[1]) then 50 #Uptrend
         else if ( BB[1] >= BB) then -50 #DownTrend
         else 0;

def SeqNum =  if ((C >= F) and (F >= H) and (H >= T)) then 1 #Step-3 Bullish phase Confirmed [1] (C-F-H-T)
         else if ((C >= F) and (F >= T) and (T >= H)) then 2 #Step-2 Bullish Confirmation AKA Accumuation [2] (C-F-T-H)
         else if ((C >= H) and (H >= F) and (F >= T)) or
                 (close >= Highest(close[1], 50))     then 3 #Ambiguous Bullish. Check the C, Phase, Playzone and Higher Time-Frame. (C-H-F-T)
         else if ((C >= H) and (H >= T) and (T >= F)) then 4 #Ambiguous Bullish. Check the Phase, Playzone and Higher Time-Frame. (C-H-T-F)
         else if ((C >= T) and (T >= F) and (F >= H)) then 5 #Step-3 Bullish Breakout and re-test AKA Bullish [1] (C-T-F-H)
         else if ((C >= T) and (T >= H) and (H >= F)) then 6 #Step-1 Bullish Initiation AKA Recovery [3] (C-T-H-F)

         else if ((F >= C) and (C >= H) and (H >= T)) then 7 #Step-4.5 Bullish Maturation AKA Bullish (F-C-H-T)
         else if ((F >= C) and (C >= T) and (T >= H)) or
                 (close <= Lowest(close[1], 50))      then 8 #step-9 Bearish Maturation AKA Bearish. Check the C.[6] (F-C-T-H)
         else if ((F >= H) and (H >= C) and (C >= T)) then 9 #Step-4.5 Bullish Maturation [PullBack, Not Real Distribution] [4] (F-H-C-T)
         else if ((F >= H) and (H >= T) and (T >= C)) then 10 #Step-6 Bearish Initiation AKA Warning [4] (F-H-T-C)
         else if ((F >= T) and (T >= C) and (C >= H)) then 11 #Ambiguous-11 Check the Phase, Playzone and Higher Time-Frame(F-T-C-H)
         else if ((F >= T) and (T >= H) and (H >= C)) then 12 #Step-7 Bearish Breakout and Re-test AKA Bearish [6]

         else if ((H >= C) and (C >= F) and (F >= T)) then 13 #Step-4 Bullish Maturation AKA Bullish [1] (H-C-F-T)
         else if ((H >= C) and (C >= T) and (T >= F)) then 14 #Ambiguous-14 Check the Phase, Playzone and Higher Time-Frame(H-C-T-F)
         else if ((H >= F) and (F >= C) and (C >= T)) then 15 #Step-5 Bullish Exhaustion (H-F-C-T) Review!
         else if ((H >= F) and (F >= T) and (T >= C)) then 16 #Step-6.5 Bearish Comfirmation AKA Distribution (H-F-T-C)
         else if ((H >= T) and (T >= C) and (C >= F)) then 17 #Step-9.5 Bearish Exhaustion Confirmed (H-T-C-F)
         else if ((H >= T) and (T >= F) and (F >= C)) then 18 #Ambiguous-18 Check the Phase, Playzone and Higher Time-Frame(H-T-F-C)

         else if ((T >= C) and (C >= F) and (F >= H)) then 19 #Step-0.5 - Attempting to be Bullish. Watch ROC/MACD  [1] (T-C-F-H)
         else if ((T >= C) and (C >= H) and (H >= F)) then 20 #Step-10 - Attempting to be Bullish. Watch ROC/MACD [1] (T-C-H-F)
         else if ((T >= F) and (F >= C) and (C >= H)) then 21 #Step-4.5 Bullish Maturation [PullBack, Not Real Distribution] [4] (T-F-C-H)
         else if ((T >= F) and (F >= H) and (H >= C)) then 22 #Ambiguous Bearish. Check the Phase, Playzone and Higher Time-Frame. (T-G-H-C)
         else if ((T >= H) and (H >= C) and (C >= F)) then 23 #Ambiguoua-23 (T-H-C-F)
         else if ((T >= H) and (H >= F) and (F >= C)) then 24 #Step-9 Bearish Maturation [6] (T-H-F-c)

         else 0;



P_Close.AssignValueColor( if ScalpCode == 100 or ScalpCode == 75 then Color.GREEN
                      else if ScalpCode == 101 then Color.CYAN
                      else if ScalpCode == -100 or ScalpCode == -75 then Color.RED
                      else if ScalpCode == -101 then Color.PLUM
                      else if ScalpCode == 50 then Color.LIGHT_GREEN
                      else if ScalpCode == -50 then Color.PINK
                      else Color.LIGHT_GRAY);


P_HigherTP_PP.AssignValueColor( if SeqNum == 1 or  SeqNum == .5 then Color.CYAN
                            else if SeqNum == 2 or  SeqNum == 2.5 then Color.LIGHT_GREEN
                            else if SeqNum == 3 then Color.GREEN
                            else if SeqNum == 4 or  SeqNum == 4.5 then Color.LIGHT_GREEN
                            else if SeqNum == 5 or  SeqNum == 5.1 then Color.CYAN
                            else if SeqNum == 6 then Color.GREEN
                            else if SeqNum == 7 then Color.LIME
                            else if SeqNum == 8 then Color.RED
                            else if SeqNum == 9 or  SeqNum == 9.5 then Color.LIGHT_RED
                            else if SeqNum == 10 then Color.RED
                            else if SeqNum == 11 then Color.GRAY
                            else if SeqNum == 12 then Color.MAGENTA
                            else if SeqNum == 13 then Color.GREEN
                            else if SeqNum == 14 then Color.GRAY
                            else if SeqNum == 15 then Color.YELLOW
                            else if SeqNum == 16 then Color.MAGENTA
                            else if SeqNum == 17 then Color.YELLOW
                            else if SeqNum == 18 then Color.GRAY
                            else if SeqNum == 19 then Color.LIGHT_GREEN
                            else if SeqNum == 20 then Color.LIGHT_GREEN
                            else if SeqNum == 21 then Color.RED
                            else if SeqNum == 22 then Color.LIGHT_RED
                            else if SeqNum == 23 then Color.GRAY
                            else if SeqNum == 24 then Color.MAGENTA
                            else if SeqNum == 0 then Color.GRAY
                           else Color.LIGHT_GRAY
  
);

AddLabel(if showLabel == showLabel."Yes" then yes else no, SeqNum + " " +
    if SeqNum == 1 then "Bullish Confirmed"
         else if SeqNum == 2 then "Accumuation"
         else if SeqNum == 3 then "Ambiguous+Bullish"
         else if SeqNum == 4 then "Ambiguous+Bullish"
         else if SeqNum == 5 then "Bullish Breakout & Re-test"
         else if SeqNum == 6 then "Bullish Initiation"

         else if SeqNum == 7 then "Bullish Maturation"
         else if SeqNum == 8 then "Bearish Maturation"
         else if SeqNum == 9 then "PullBack,Not Real Distribution"
         else if SeqNum == 10 then "Bearish Initiation"
         else if SeqNum == 11 then "Ambiguous! May be in a channel"
         else if SeqNum == 12 then "Bearish Breakout & Re-test"

         else if SeqNum == 13 then "Bullish Maturation"
         else if SeqNum == 14 then "Ambiguous! May be in a channel"
         else if SeqNum == 15 then "Potential Reversal! Bullish Exhaustion"
         else if SeqNum == 16 then "Bearish Comfirmation/Distribution"
         else if SeqNum == 17 then "Bearish Exhaustion Confirmed"
         else if SeqNum == 18 then "Ambiguous-Bearish/Bearish Channel"

         else if SeqNum == 19 and PlayzoneFlag == 2 then "About to be Bullish"
         else if SeqNum == 19 and PlayzoneFlag == -2 then "About to be Bearish"
         else if SeqNum == 19 and PlayzoneFlag == 0 then "Ambiguous. Check Higher TF"
         else if SeqNum == 19 then "Ambiguous.Check Higher TF"
         else if SeqNum == 20 and PlayzoneFlag == 2 then "Bullish Attempt may fail"
         else if SeqNum == 20 and PlayzoneFlag == -2 then "Bearish attempt may fail"
         else if SeqNum == 20 and PlayzoneFlag == 0 then "Ambiguous. *Check Higher TF"
         else if SeqNum == 20 then "Ambiguous. Check Higher TF"
 
         else if SeqNum == 21 then "Bullish Maturation/PullBack, Not Real Distribution"
         else if SeqNum == 22 then "Ambiguous-Bearish. *Check Higher TF"
         else if SeqNum == 23 then "Ambiguous. Check Higher TF"
         else if SeqNum == 24 then "Bearish Trend. Check Higher TF"
         else "*" ,

         if SeqNum == 1 or  SeqNum == .5 then Color.CYAN
                            else if SeqNum == 2 or  SeqNum == 2.5 then Color.LIGHT_GREEN
                            else if SeqNum == 3 then Color.GREEN
                            else if SeqNum == 4 or  SeqNum == 4.5 then Color.LIGHT_GREEN
                            else if SeqNum == 5 or  SeqNum == 5.1 then Color.CYAN
                            else if SeqNum == 6 then Color.GREEN
                            else if SeqNum == 7 then Color.LIME
                            else if SeqNum == 8 then Color.RED
                            else if SeqNum == 9 or  SeqNum == 9.5 then Color.LIGHT_RED
                            else if SeqNum == 10 then Color.RED
                            else if SeqNum == 11 then Color.GRAY
                            else if SeqNum == 12 then Color.MAGENTA
                            else if SeqNum == 13 then Color.GREEN
                            else if SeqNum == 14 then Color.GRAY
                            else if SeqNum == 15 then Color.YELLOW
                            else if SeqNum == 16 then Color.MAGENTA
                            else if SeqNum == 17 then Color.YELLOW
                            else if SeqNum == 18 then Color.GRAY
                            else if SeqNum == 19 then Color.LIGHT_GREEN
                            else if SeqNum == 20 then Color.LIGHT_GREEN
                            else if SeqNum == 21 then Color.RED
                            else if SeqNum == 22 then Color.LIGHT_RED
                            else if SeqNum == 23 then Color.GRAY
                            else if SeqNum == 24 then Color.MAGENTA
                            else if SeqNum == 0 then Color.GRAY
                           else Color.LIGHT_GRAY );

input MACDBB_FastLength = 12;
input MACDBB_SlowLength = 26;
input MACDBB_BandLength = 15;
input MACDBB_NumDev = 1.0;

Def HigherTP_PP_BB_High = reference BollingerBands(price = P_HigherTP_PP, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).UpperBand;

def HigherTP_PP_BB_LOW = reference BollingerBands(price = P_HigherTP_PP, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).Lowerband;

AddLabel(if showLabel == showLabel."Yes" then yes else no,
       
         if P_Close >= P_HigherTP_PP and P_Close <= P_HigherTP_R3 then "Anticipated Level: " + P_HigherTP_R3  + " in next " + p + " Bars"
         else if P_Close <= P_HigherTP_PP and P_Close >= P_HigherTP_S3 then "Anticipated Level: " + P_HigherTP_S3  + " in next " + p + " Bars"
         else if P_Close >= P_HigherTP_PP and P_Close <= HigherTP_PP_BB_High then "Anticipated Level: " + HigherTP_PP_Bb_HIgh  + " in next " + p + " Bars"
         else if P_Close <= P_HigherTP_PP and P_Close >= HigherTP_PP_BB_Low then "Anticipated Level: " +  HigherTP_PP_BB_Low  + " in next " + p + " Bars"  
         else "Anticipated Level:",
         if P_Close >= P_HigherTP_PP then GetColor(6) else GetColor(5) );

P_Close.SetPaintingStrategy(paintingStrategy2);
P_Close.SetLineWeight(1);
P_BullCHP.SetLineWeight(1);
P_BullCHP.AssignValueColor(Color.WHITE);
P_Close.Hide();


# --- Cross over logic --
rec _Cross_Up = if P_Close crosses above P_HigherTP_PP_I then yes else no;
def Cross_Up = if _Cross_Up != _Cross_Up[1] then _Cross_Up else Double.NaN;

def  Cross_Dn = if P_Close crosses below P_HigherTP_PP_I then yes else no;
#Cross_Up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Cross_Dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

def upArrow = if Cross_up then Low else double.NaN;
def dnArrow = if Cross_Dn then High else double.NaN;

plot PPSup = upArrow;
Plot PPSdown = dnArrow;
PPSup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
PPSdown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
PPSup.SetLineWeight(3);
PPSDown.SetLineWeight(3);
PPSUp.AssignValueColor(Color.White);
PPSDown.AssignValueColor(Color.White);



#-- Paint Bars logic --
input PaintBars = { default "Yes", "No" } ;

AssignPriceColor(
        if PaintBars == PaintBars."Yes" then

         if ScalpCode == 100 or ScalpCode == 75 then Color.GREEN
                      else if ScalpCode == 101 then Color.CYAN
                      else if ScalpCode == -100 or ScalpCode == -75 then Color.RED
                      else if ScalpCode == -101 then Color.MAGENTA
                      else if ScalpCode == 50 then Color.LIGHT_GREEN
                      else if ScalpCode == -50 then Color.PINK
                      else Color.LIGHT_GRAY      
  
        else Color.CURRENT# RB
    );
This AWESOME! I didn't want to muck with the code-not my forte--but can anticipated price in X mins be listed as a percentage of current price? Thanks!
 
Updated 10:55 8/17/2022 PST - % change in Label.
Updated 12:45 8/6/2022 PST - A calculation correction.

Multi Time Frame Anticipated Price Level Indicator.
Color Coded Twenty Four Steps of trend Cycles from Bearish to Bullish and vice-versa.
Color coded six phases of a trade cycle.
Entry and Exit Points.
Trend Reversal Indications.


5uLCbSL.png

Code:
#
# Created by TraderZen
# Last update 8/17/2022
#
#
#


input applyPersonsLevelsFilter = yes;
input marketThreshold = 0.0025;
input timeFrame = {Min,   Five_Min, Ten_Min, Fifteen_Min, Thirty_Min,  default  hour };
input showLabel = {default "Yes", "No"};
input Show_Level_Lines = {default "All", "Mid", "High-Low", "None"};

def CurrentTP = GetAggregationPeriod();

def thisTP;
thisTP = CurrentTP;


def HigherTP = if timeFrame == timeFrame."Five_Min" then AggregationPeriod.FIVE_MIN
              else if timeFrame == timeFrame."Fifteen_Min" then AggregationPeriod.FIFTEEN_MIN
              else if timeFrame == timeFrame."Ten_Min" then AggregationPeriod.TEN_MIN
              else if timeFrame == timeFrame."hour" then AggregationPeriod.HOUR
              else if timeFrame == timeFrame."Thirty_Min" then AggregationPeriod.THIRTY_MIN
              else if timeFrame == timeFrame."Min" then AggregationPeriod.MIN
              else thisTP * 4;

def PP2TP = high(period = thisTP)[1] + low(period = thisTP)[1] + close(period = thisTP)[1];
def marketTypeTP = { DISABLED,  NEUTRAL, BEARISH, default BULLISH};

marketTypeTP = if !applyPersonsLevelsFilter then marketTypeTP.DISABLED
                else if PP2TP[-1] > (PP2TP[-1] + PP2TP + PP2TP[1]) / 3 + marketThreshold then marketTypeTP.BULLISH
                else if PP2TP[-1] < (PP2TP[-1] + PP2TP + PP2TP[1]) / 3 - marketThreshold then marketTypeTP.BEARISH
                else marketTypeTP.NEUTRAL;

def AlgoExec = if HigherTP <= thisTP then no else yes;
AddLabel(yes, if AlgoExec == no then "No Execution: The Current Time Period Should be Less then the Selected Time Period! " + HigherTP else "Trend:" ,
        Color.WHITE) ;

def P = HigherTP / CurrentTP;

def Higher =  fold nH = 1 to P + 1 with Top_high     do  Max(high(Period = thisTP)[P], high(Period = thisTP)[P + 1]) ;
def Lower  =  fold nL = 1 to P + 1 with Bottom_Low   do  Min(low(Period = thisTP)[P], low(Period = thisTP)[P + 1]);
def closer  = close[1];

#def higher  = high(period = HigherTP)[1];
#def Lower   = low(period = HigherTP)[1];
#def Closer  =  close(period = HigherTP)[1];

#AddLabel(Yes, higher + " " + lower + " " + closer);

def PP2HP = Higher + Lower + closer;
def MarketTypeHP = { DISABLED,  NEUTRAL,  BEARISH, default BULLISH};

MarketTypeHP = if !applyPersonsLevelsFilter then MarketTypeHP.DISABLED
        else if PP2HP[-1] > (PP2HP[-1] + PP2HP + PP2HP[1]) / 3 + marketThreshold then MarketTypeHP.BULLISH
        else if PP2HP[-1] < (PP2HP[-1] + PP2HP + PP2HP[1]) / 3 - marketThreshold then MarketTypeHP.BEARISH
        else MarketTypeHP.NEUTRAL;

#def paintingStrategy1 = if getAggregationPeriod() == AggregationPeriod.Min then PaintingStrategy.LINE_VS_TRIANGLES
#                       else if getAggregationPeriod() == AggregationPeriod.FIVE_MIN
#                            or getAggregationPeriod() == AggregationPeriod.FIFTEEN_MIN then
#                            PaintingStrategy.LINE_VS_SQUARES
#                       else PaintingStrategy.LINE;
def paintingStrategy1 = PaintingStrategy.LINE;

#def paintingStrategy2 = if HigherTP == AggregationPeriod.Min then PaintingStrategy.LINE_VS_TRIANGLES
#                       else if HigherTP == AggregationPeriod.Five_Min or HigherTP == AggregationPeriod.Fifteen_Min then PaintingStrategy.LINE_VS_SQUARES
#                       else PaintingStrategy.LINE;
def paintingStrategy2 = PaintingStrategy.LINE;

## -- Pivote points + Trigger points + phase to calculate Trend.

## -- Initiate Variables

def HigherTP_PP;
def HigherTP_R1;
def HigherTP_R2;
def HigherTP_R3;
def HigherTP_S1;
def HigherTP_S2;
def HigherTP_S3;
def HigherTP_RR;
def HigherTP_SS;

def HigherTP_PP_I;
def HigherTP_R1_I;
def HigherTP_R2_I;
def HigherTP_R3_I;
def HigherTP_S1_I;
def HigherTP_S2_I;
def HigherTP_S3_I;
def HigherTP_RR_I;
def HigherTP_SS_I;

## -- Conditionally Assign Values

if AlgoExec == no # or !IsNaN(close(period = HigherTP)[-1])
Then
{

    HigherTP_PP = Double.NaN;
    HigherTP_R1 = Double.NaN;
    HigherTP_R2 = Double.NaN;
    HigherTP_R3 = Double.NaN;
    HigherTP_S1 = Double.NaN;
    HigherTP_S2 = Double.NaN;
    HigherTP_S3 = Double.NaN;
    HigherTP_RR = Double.NaN;
    HigherTP_SS = Double.NaN;

    HigherTP_PP_I = Double.NaN;
    ;
    HigherTP_R1_I = Double.NaN;
    HigherTP_R2_I = Double.NaN;
    ;
    HigherTP_R3_I = Double.NaN;
    ;
    HigherTP_S1_I = Double.NaN;
    ;
    HigherTP_S2_I = Double.NaN;
    ;
    HigherTP_S3_I = Double.NaN;
    ;
    HigherTP_RR_I = Double.NaN;
    ;
    HigherTP_SS_I = Double.NaN;
    ;


}
else
{

    HigherTP_PP = (high(period = HigherTP)[1] + low(period = HigherTP)[1] + close(period = HigherTP)[1]) / 3;
    ;
    HigherTP_R1 = 2 * HigherTP_PP - low(period = HigherTP)[1];
    ;
    HigherTP_R2 = HigherTP_PP + high(period = HigherTP)[1] - low(period = HigherTP)[1];
    HigherTP_R3 = HigherTP_R2 + high(period = HigherTP)[1] - low(period = HigherTP)[1];
    HigherTP_S1 = 2 * HigherTP_PP - high(period = HigherTP)[1];
    HigherTP_S2 = HigherTP_PP - high(period = HigherTP)[1] + low(period = HigherTP)[1];
    HigherTP_S3 = HigherTP_S2 - high(period = HigherTP)[1] + low(period = HigherTP)[1];
    HigherTP_RR = if (MarketTypeHP == MarketTypeHP.BEARISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_R1 else HigherTP_R2;
    HigherTP_SS = if (MarketTypeHP == MarketTypeHP.BULLISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_S1 else HigherTP_S2;

    HigherTP_PP_I = (Higher[1] + Lower[1] + closer[1]) / 3;
    ;
    HigherTP_R1_I = 2 * HigherTP_PP - Lower[1];
    ;
    HigherTP_R2_I = HigherTP_PP + Higher[1] - Lower[1];
    HigherTP_R3_I = HigherTP_R2 + Higher[1] - Lower[1];
    HigherTP_S1_I = 2 * HigherTP_PP - Higher[1];
    HigherTP_S2_I = HigherTP_PP - Higher[1] + Lower[1];
    HigherTP_S3_I = HigherTP_S2 - Higher[1] + Lower[1];
    HigherTP_RR_I = if (MarketTypeHP == MarketTypeHP.BEARISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_R1 else HigherTP_R2;
    HigherTP_SS_I = if (MarketTypeHP == MarketTypeHP.BULLISH or MarketTypeHP == MarketTypeHP.NEUTRAL) then HigherTP_S1 else HigherTP_S2;

}


plot P_HigherTP_PP = if (Show_Level_Lines == Show_Level_Lines."All" or Show_Level_Lines  == Show_Level_Lines."Mid" ) then HigherTP_PP else Double.nan;
plot P_HigherTP_R1 = HigherTP_R1;
plot P_HigherTP_R2 = HigherTP_R2;
plot P_HigherTP_R3 = HigherTP_R3;
plot P_HigherTP_S1 = HigherTP_S1;
plot P_HigherTP_S2 = HigherTP_S2;
plot P_HigherTP_S3 = HigherTP_S3;
plot P_HigherTP_RR = if (Show_Level_Lines == Show_Level_Lines."All" or Show_Level_Lines  == Show_Level_Lines."High-Low") then HigherTP_RR else double.nan;
plot P_HigherTP_SS = if (Show_Level_Lines == Show_Level_Lines."All" or Show_Level_Lines  == Show_Level_Lines."High-Low") then HigherTP_SS else double.nan;

plot P_HigherTP_PP_I = HigherTP_PP_I;
plot P_HigherTP_R1_I = HigherTP_R1_I;
plot P_HigherTP_R2_I = HigherTP_R2_I;
plot P_HigherTP_R3_I = HigherTP_R3_I;
plot P_HigherTP_S1_I = HigherTP_S1_I;
plot P_HigherTP_S2_I = HigherTP_S2_I;
plot P_HigherTP_S3_I = HigherTP_S3_I;
plot P_HigherTP_RR_I = HigherTP_RR_I;
plot P_HigherTP_SS_I = HigherTP_SS_I;


P_HigherTP_RR.SetHiding(!applyPersonsLevelsFilter);
P_HigherTP_R1.SetHiding(applyPersonsLevelsFilter);
P_HigherTP_R2.SetHiding(applyPersonsLevelsFilter);
P_HigherTP_SS.SetHiding(!applyPersonsLevelsFilter);
P_HigherTP_S1.SetHiding(applyPersonsLevelsFilter);
P_HigherTP_S2.SetHiding(applyPersonsLevelsFilter);


P_HigherTP_PP.SetDefaultColor(GetColor(3));
P_HigherTP_R1.SetDefaultColor(GetColor(5));
P_HigherTP_R2.SetDefaultColor(GetColor(5));
P_HigherTP_R3.SetDefaultColor(GetColor(6));
P_HigherTP_S1.SetDefaultColor(GetColor(5));
P_HigherTP_S2.SetDefaultColor(GetColor(5));
P_HigherTP_S3.SetDefaultColor(GetColor(5));

P_HigherTP_SS.DefineColor("P_HigherTP_S1", GetColor(5));
P_HigherTP_SS.DefineColor("P_HigherTP_S2", GetColor(5));
P_HigherTP_SS.AssignValueColor(if P_HigherTP_SS == P_HigherTP_S1 then P_HigherTP_SS.Color("P_HigherTP_S1") else P_HigherTP_SS.Color("P_HigherTP_S2"));

P_HigherTP_RR.DefineColor("P_HigherTP_R1", GetColor(6));
P_HigherTP_RR.DefineColor("P_HigherTP_R2", GetColor(6));
P_HigherTP_RR.AssignValueColor(if P_HigherTP_RR == P_HigherTP_R1 then P_HigherTP_RR.Color("P_HigherTP_R1") else P_HigherTP_RR.Color("P_HigherTP_R2"));

P_HigherTP_PP.SetStyle(Curve.LONG_DASH);
P_HigherTP_RR.SetStyle(Curve.SHORT_DASH);
P_HigherTP_R1.SetStyle(Curve.SHORT_DASH);
P_HigherTP_R2.SetStyle(Curve.SHORT_DASH);
P_HigherTP_R3.SetStyle(Curve.SHORT_DASH);
P_HigherTP_SS.SetStyle(Curve.SHORT_DASH);
P_HigherTP_S1.SetStyle(Curve.SHORT_DASH);
P_HigherTP_S2.SetStyle(Curve.SHORT_DASH);
P_HigherTP_S3.SetStyle(Curve.SHORT_DASH);


P_HigherTP_PP.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_RR.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_R1.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_R2.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_R3.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_SS.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_S1.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_S2.SetPaintingStrategy(paintingStrategy2);
P_HigherTP_S3.SetPaintingStrategy(paintingStrategy2);


P_HigherTP_S1.Hide();
P_HigherTP_S2.Hide();
P_HigherTP_S3.Hide();
P_HigherTP_R1.Hide();
P_HigherTP_R2.Hide();
P_HigherTP_R3.Hide();
#P_HigherTP_rr.hide();
#P_HigherTP_ss.hide();
#P_HigherTP_pp.hide();


P_HigherTP_S1_I.Hide();
P_HigherTP_S2_I.Hide();
P_HigherTP_S3_I.Hide();
P_HigherTP_R1_I.Hide();
P_HigherTP_R2_I.Hide();
P_HigherTP_R3_I.Hide();
P_HigherTP_RR_I.Hide();
P_HigherTP_SS_I.Hide();
P_HigherTP_PP_I.Hide();

## -- Arrangement to reference the higher timeframe data (AP = AggergationPeriod).

def BullCalc = MovingAverage(3, PP2TP[-1] / 3, 3);
def BearCalc = MovingAverage(3, ( (PP2TP[-1] + PP2TP + PP2TP[1]) / 3) / 3 , 3);

rec BullCalcHP = MovingAverage(3, PP2HP[-1] / 3, 3);
rec BearCalcHP = MovingAverage(3, ( (PP2HP[-1] + PP2HP + PP2HP[1]) / 3) / 3 , 3);

plot p_bullC = BullCalc;
p_bullC.AssignValueColor(Color.WHITE);

plot p_BearC = BearCalc;
p_BearC.AssignValueColor(Color.GRAY);


plot P_BullCHP = BullCalcHP;
P_BullCHP.AssignValueColor(Color.WHITE);

plot p_BearCHP = BearCalcHP;
p_BearCHP.AssignValueColor(Color.YELLOW);


plot P_Close = close(priceType = PriceType.LAST);


rec bull = if (BullCalc[-1] crosses above BearCalc[-1] - marketThreshold) then yes else Double.NaN;
rec bear = if (BearCalc[-1] crosses above BullCalc[-1] - marketThreshold) then yes else Double.NaN;

rec BullHP = if  (BullCalcHP[-1] crosses above (BearCalcHP[-1] - marketThreshold))  then yes
             else Double.NaN;
def BearHP = if (BearCalcHP[-1] crosses above (BullCalcHP[-1] - marketThreshold))  then yes else Double.NaN;


plot P_bull = bull;
plot p_bear =  bear ;

plot P_BullHP = BullHP ;
plot p_BearHP = BearHP ;

P_bull.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
P_bull.SetDefaultColor(Color.GREEN);
p_bear.SetDefaultColor(Color.DARK_ORANGE);
p_bear.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

P_BullHP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
P_BullHP.SetDefaultColor(Color.CYAN);
p_BearHP.SetDefaultColor(Color.MAGENTA);
p_BearHP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

p_bullC.Hide();
p_BearC.Hide();

P_bull.Hide();
p_bear.Hide();

P_BullHP.Hide();
p_BearHP.Hide();

P_BullCHP.Hide();
p_BearCHP.Hide();

######################################### ------ Color coding 

def C = P_Close;

def v50  = Round(SimpleMovingAvg(close, 50)); # MovAvgExponential(close, 50);
def v100 = Round(SimpleMovingAvg(close, 100));
def v200 = Round(SimpleMovingAvg(close, 200)); # MovAvgExponential(close, 200);
def F = v50;  # Duplicate variable for v50 to code the SeqNum Logic.
def H = v100; # Duplicate variable for v100 to code the SeqNum Logic.
def T = v200; # Duplicate variable for v200 to code the seqNum Logic.
def BB = Round(BollingerBands()."MidLine");

def ROCFlag = if RateOfChange() > RateOfChange()[1] then 1
              else if RateOfChange() < RateOfChange()[1] then -1
              else 0;

def ROCFlag2 = if RateOfChange() > 0 then 1
               else if RateOfChange() < 0 then -1
               else 0;

def MACDOpen = if MACD()."value" >= MACD()."value"[1] and MACD()."value" > MACD()."avg" then 1
               else if MACD()."value" <  MACD()."value"[1] and MACD()."value" < MACD()."avg" then -1
               else 0;

def PlayzoneFlag = if  ROCFlag == 1 and MACDOpen == 1  then 2
                   else if ROCFlag2 == 1 and MACDOpen == 1 then 2
                   else if ROCFlag == -1 and MACDOpen == -1 then -2
                   else if ROCFlag2 == -1 and MACDOpen == -1 then -2 
                   else 0;

def Phase = if (close >= v50  and close >= v200 and v50   >= v200) then 1 #Bullish
       else if (close >= v50  and close >= v200 and v50   <= v200) then 2 #Accumulation 
       else if (  v50 <= v200 and close <= v200 and close >= v50)  then 3 # Recovery
       else if (close <= v50  and close >= v200 and v50   >= v200) then 4 # Warning
       else if (close <= v50  and close <= v200 and v50   >= v200) then 5 #Distribution
       else if (  v50 <= v200 and close <= v200 and close <= v50 ) then 6 #Bearish
       else 7;

def ScalpCode = if ( (C >= BB) and (BB > BB[1])  and (BB >= F) ) then 101 # Bullish Superseed condition
         else if ( (F >= BB) and (BB[1] >= BB) and (BB >= C) ) then -101 # Bearish Superseed condition
         else if ( (C >= BB) and (BB >= F) ) then 100 #Still Bullish Strong
         else if ( (F >= BB) and (BB >= C) ) then -100 #Still Bearish Strong  
         else if ( close >= Highest(close[1], 50)) then 75 #C50 Up
         else if ( close <= Lowest(close[1], 50)) then -75  #c50 Down  
         else if ( BB >= BB[1]) then 50 #Uptrend
         else if ( BB[1] >= BB) then -50 #DownTrend
         else 0;

def SeqNum =  if ((C >= F) and (F >= H) and (H >= T)) then 1 #Step-3 Bullish phase Confirmed [1] (C-F-H-T)
         else if ((C >= F) and (F >= T) and (T >= H)) then 2 #Step-2 Bullish Confirmation AKA Accumuation [2] (C-F-T-H)
         else if ((C >= H) and (H >= F) and (F >= T)) or
                 (close >= Highest(close[1], 50))     then 3 #Ambiguous Bullish. Check the C, Phase, Playzone and Higher Time-Frame. (C-H-F-T)
         else if ((C >= H) and (H >= T) and (T >= F)) then 4 #Ambiguous Bullish. Check the Phase, Playzone and Higher Time-Frame. (C-H-T-F)
         else if ((C >= T) and (T >= F) and (F >= H)) then 5 #Step-3 Bullish Breakout and re-test AKA Bullish [1] (C-T-F-H)
         else if ((C >= T) and (T >= H) and (H >= F)) then 6 #Step-1 Bullish Initiation AKA Recovery [3] (C-T-H-F)

         else if ((F >= C) and (C >= H) and (H >= T)) then 7 #Step-4.5 Bullish Maturation AKA Bullish (F-C-H-T)
         else if ((F >= C) and (C >= T) and (T >= H)) or
                 (close <= Lowest(close[1], 50))      then 8 #step-9 Bearish Maturation AKA Bearish. Check the C.[6] (F-C-T-H)
         else if ((F >= H) and (H >= C) and (C >= T)) then 9 #Step-4.5 Bullish Maturation [PullBack, Not Real Distribution] [4] (F-H-C-T)
         else if ((F >= H) and (H >= T) and (T >= C)) then 10 #Step-6 Bearish Initiation AKA Warning [4] (F-H-T-C)
         else if ((F >= T) and (T >= C) and (C >= H)) then 11 #Ambiguous-11 Check the Phase, Playzone and Higher Time-Frame(F-T-C-H)
         else if ((F >= T) and (T >= H) and (H >= C)) then 12 #Step-7 Bearish Breakout and Re-test AKA Bearish [6]

         else if ((H >= C) and (C >= F) and (F >= T)) then 13 #Step-4 Bullish Maturation AKA Bullish [1] (H-C-F-T)
         else if ((H >= C) and (C >= T) and (T >= F)) then 14 #Ambiguous-14 Check the Phase, Playzone and Higher Time-Frame(H-C-T-F)
         else if ((H >= F) and (F >= C) and (C >= T)) then 15 #Step-5 Bullish Exhaustion (H-F-C-T) Review!
         else if ((H >= F) and (F >= T) and (T >= C)) then 16 #Step-6.5 Bearish Comfirmation AKA Distribution (H-F-T-C)
         else if ((H >= T) and (T >= C) and (C >= F)) then 17 #Step-9.5 Bearish Exhaustion Confirmed (H-T-C-F)
         else if ((H >= T) and (T >= F) and (F >= C)) then 18 #Ambiguous-18 Check the Phase, Playzone and Higher Time-Frame(H-T-F-C)

         else if ((T >= C) and (C >= F) and (F >= H)) then 19 #Step-0.5 - Attempting to be Bullish. Watch ROC/MACD  [1] (T-C-F-H)
         else if ((T >= C) and (C >= H) and (H >= F)) then 20 #Step-10 - Attempting to be Bullish. Watch ROC/MACD [1] (T-C-H-F)
         else if ((T >= F) and (F >= C) and (C >= H)) then 21 #Step-4.5 Bullish Maturation [PullBack, Not Real Distribution] [4] (T-F-C-H)
         else if ((T >= F) and (F >= H) and (H >= C)) then 22 #Ambiguous Bearish. Check the Phase, Playzone and Higher Time-Frame. (T-G-H-C)
         else if ((T >= H) and (H >= C) and (C >= F)) then 23 #Ambiguoua-23 (T-H-C-F)
         else if ((T >= H) and (H >= F) and (F >= C)) then 24 #Step-9 Bearish Maturation [6] (T-H-F-c)

         else 0;



P_Close.AssignValueColor( if ScalpCode == 100 or ScalpCode == 75 then Color.GREEN
                      else if ScalpCode == 101 then Color.CYAN
                      else if ScalpCode == -100 or ScalpCode == -75 then Color.RED
                      else if ScalpCode == -101 then Color.PLUM
                      else if ScalpCode == 50 then Color.LIGHT_GREEN
                      else if ScalpCode == -50 then Color.PINK
                      else Color.LIGHT_GRAY);


P_HigherTP_PP.AssignValueColor( if SeqNum == 1 or  SeqNum == .5 then Color.CYAN
                            else if SeqNum == 2 or  SeqNum == 2.5 then Color.LIGHT_GREEN
                            else if SeqNum == 3 then Color.GREEN
                            else if SeqNum == 4 or  SeqNum == 4.5 then Color.LIGHT_GREEN
                            else if SeqNum == 5 or  SeqNum == 5.1 then Color.CYAN
                            else if SeqNum == 6 then Color.GREEN
                            else if SeqNum == 7 then Color.LIME
                            else if SeqNum == 8 then Color.RED
                            else if SeqNum == 9 or  SeqNum == 9.5 then Color.LIGHT_RED
                            else if SeqNum == 10 then Color.RED
                            else if SeqNum == 11 then Color.GRAY
                            else if SeqNum == 12 then Color.MAGENTA
                            else if SeqNum == 13 then Color.GREEN
                            else if SeqNum == 14 then Color.GRAY
                            else if SeqNum == 15 then Color.YELLOW
                            else if SeqNum == 16 then Color.MAGENTA
                            else if SeqNum == 17 then Color.YELLOW
                            else if SeqNum == 18 then Color.GRAY
                            else if SeqNum == 19 then Color.LIGHT_GREEN
                            else if SeqNum == 20 then Color.LIGHT_GREEN
                            else if SeqNum == 21 then Color.RED
                            else if SeqNum == 22 then Color.LIGHT_RED
                            else if SeqNum == 23 then Color.GRAY
                            else if SeqNum == 24 then Color.MAGENTA
                            else if SeqNum == 0 then Color.GRAY
                           else Color.LIGHT_GRAY
   
);

AddLabel(if showLabel == showLabel."Yes" then yes else no, SeqNum + " " +
    if SeqNum == 1 then "Bullish Confirmed"
         else if SeqNum == 2 then "Accumuation"
         else if SeqNum == 3 then "Ambiguous+Bullish"
         else if SeqNum == 4 then "Ambiguous+Bullish"
         else if SeqNum == 5 then "Bullish Breakout & Re-test"
         else if SeqNum == 6 then "Bullish Initiation"

         else if SeqNum == 7 then "Bullish Maturation"
         else if SeqNum == 8 then "Bearish Maturation"
         else if SeqNum == 9 then "PullBack,Not Real Distribution"
         else if SeqNum == 10 then "Bearish Initiation"
         else if SeqNum == 11 then "Ambiguous! May be in a channel"
         else if SeqNum == 12 then "Bearish Breakout & Re-test"

         else if SeqNum == 13 then "Bullish Maturation"
         else if SeqNum == 14 then "Ambiguous! May be in a channel"
         else if SeqNum == 15 then "Potential Reversal! Bullish Exhaustion"
         else if SeqNum == 16 then "Bearish Comfirmation/Distribution"
         else if SeqNum == 17 then "Bearish Exhaustion Confirmed"
         else if SeqNum == 18 then "Ambiguous-Bearish/Bearish Channel"

         else if SeqNum == 19 and PlayzoneFlag == 2 then "About to be Bullish"
         else if SeqNum == 19 and PlayzoneFlag == -2 then "About to be Bearish"
         else if SeqNum == 19 and PlayzoneFlag == 0 then "Ambiguous. Check Higher TF"
         else if SeqNum == 19 then "Ambiguous.Check Higher TF"
         else if SeqNum == 20 and PlayzoneFlag == 2 then "Bullish Attempt may fail"
         else if SeqNum == 20 and PlayzoneFlag == -2 then "Bearish attempt may fail"
         else if SeqNum == 20 and PlayzoneFlag == 0 then "Ambiguous. *Check Higher TF"
         else if SeqNum == 20 then "Ambiguous. Check Higher TF"
  
         else if SeqNum == 21 then "Bullish Maturation/PullBack, Not Real Distribution"
         else if SeqNum == 22 then "Ambiguous-Bearish. *Check Higher TF"
         else if SeqNum == 23 then "Ambiguous. Check Higher TF"
         else if SeqNum == 24 then "Bearish Trend. Check Higher TF"
         else "*" ,

         if SeqNum == 1 or  SeqNum == .5 then Color.CYAN
                            else if SeqNum == 2 or  SeqNum == 2.5 then Color.LIGHT_GREEN
                            else if SeqNum == 3 then Color.GREEN
                            else if SeqNum == 4 or  SeqNum == 4.5 then Color.LIGHT_GREEN
                            else if SeqNum == 5 or  SeqNum == 5.1 then Color.CYAN
                            else if SeqNum == 6 then Color.GREEN
                            else if SeqNum == 7 then Color.LIME
                            else if SeqNum == 8 then Color.RED
                            else if SeqNum == 9 or  SeqNum == 9.5 then Color.LIGHT_RED
                            else if SeqNum == 10 then Color.RED
                            else if SeqNum == 11 then Color.GRAY
                            else if SeqNum == 12 then Color.MAGENTA
                            else if SeqNum == 13 then Color.GREEN
                            else if SeqNum == 14 then Color.GRAY
                            else if SeqNum == 15 then Color.YELLOW
                            else if SeqNum == 16 then Color.MAGENTA
                            else if SeqNum == 17 then Color.YELLOW
                            else if SeqNum == 18 then Color.GRAY
                            else if SeqNum == 19 then Color.LIGHT_GREEN
                            else if SeqNum == 20 then Color.LIGHT_GREEN
                            else if SeqNum == 21 then Color.RED
                            else if SeqNum == 22 then Color.LIGHT_RED
                            else if SeqNum == 23 then Color.GRAY
                            else if SeqNum == 24 then Color.MAGENTA
                            else if SeqNum == 0 then Color.GRAY
                           else Color.LIGHT_GRAY );

input MACDBB_FastLength = 12;
input MACDBB_SlowLength = 26;
input MACDBB_BandLength = 9;
input MACDBB_NumDev = 1.0;

Def HigherTP_PP_BB_High = reference BollingerBands(price = P_HigherTP_RR, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).UpperBand;

def HigherTP_PP_BB_LOW = reference BollingerBands(price = P_HigherTP_SS, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).Lowerband;

AddLabel(if showLabel == showLabel."Yes" then yes else no,
        
         if P_Close >= HigherTP_PP and P_Close <= HigherTP_RR then "Anticipated Level: " + HigherTP_RR  + " (" + roundup( ((HigherTP_RR - P_Close)/P_Close)*100,2) + " %)" + " in next " + p + " Bars"
         else if P_Close <= HigherTP_PP and P_Close >= HigherTP_SS then "Anticipated Level: " + HigherTP_SS + " (" + roundup( ((HigherTP_SS - P_Close)/P_Close)*100,2) + " %)" + " in next " + p + " Bars"
         else if P_Close >= P_HigherTP_PP and P_Close >= HigherTP_RR then "Anticipated Level: " + HigherTP_PP_Bb_HIgh + " (" + roundup( ((HigherTP_PP_BB_High - P_Close)/P_Close)*100, 2) + " %)" + "* in next " + p + " Bars"
         else if P_Close <= P_HigherTP_PP and P_Close <= HigherTP_SS then "Anticipated Level: " + 
                            HigherTP_PP_BB_Low  + " (" + roundup( ((HigherTP_PP_BB_Low - P_Close)/P_Close)*100,2) + " %)" + "* in next " + p + " Bars"   
         else "Anticipated Level:",
         if P_Close >= HigherTP_PP then GetColor(6) else GetColor(5) );

P_Close.SetPaintingStrategy(paintingStrategy2);
P_Close.SetLineWeight(1);
P_BullCHP.SetLineWeight(1);
P_BullCHP.AssignValueColor(Color.WHITE);
P_Close.Hide();


# --- Cross over logic --
rec _Cross_Up = if P_Close crosses above P_HigherTP_PP_I then yes else no;
def Cross_Up = if _Cross_Up != _Cross_Up[1] then _Cross_Up else Double.NaN;

def  Cross_Dn = if P_Close crosses below P_HigherTP_PP_I then yes else no;
#Cross_Up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Cross_Dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

def upArrow = if Cross_up then low else double.NaN;
def dnArrow = if Cross_Dn then high else double.NaN;

plot PPSup = upArrow;
Plot PPSdown = dnArrow;
PPSup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
PPSdown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
PPSup.SetLineWeight(3);
PPSDown.SetLineWeight(3);
PPSUp.AssignValueColor(Color.White);
PPSDown.AssignValueColor(Color.White);



#-- Paint Bars logic --
input PaintBars = { default "Yes", "No" } ;

AssignPriceColor(
        if PaintBars == PaintBars."Yes" then

         if ScalpCode == 100 or ScalpCode == 75 then Color.GREEN
                      else if ScalpCode == 101 then Color.CYAN
                      else if ScalpCode == -100 or ScalpCode == -75 then Color.RED
                      else if ScalpCode == -101 then Color.MAGENTA
                      else if ScalpCode == 50 then Color.LIGHT_GREEN
                      else if ScalpCode == -50 then Color.PINK
                      else Color.LIGHT_GRAY       
   
        else Color.CURRENT# RB
    );

#End 8/17/20222
Is there a way to make a short and long scan for when price is equal to or greater than { p_higherTP_R1-P_higherTP_R2 }
AND FOR LONGS if price is equal to or less than{ PhigherTP_S1-P_HigherTP_S2 } thanks i tried but it says to complicated is there a way?
 
Is there a way to make a short and long scan for when price is equal to or greater than { p_higherTP_R1-P_higherTP_R2 }
AND FOR LONGS if price is equal to or less than{ PhigherTP_S1-P_HigherTP_S2 } thanks i tried but it says to complicated is there a way?
Try
price >= (p_higherTP_R1 - p_higherTP_R2) "(" instead of "{".

Otherwise keep it simple and try
price >= p_higherTP_PP and Price <=p_HigherTP_PP
 
Try
price >= (p_higherTP_R1 - p_higherTP_R2) "(" instead of "{".

Otherwise keep it simple and try
price >= p_higherTP_PP and Price <=p_HigherTP_PP
Thanks for reply TraderZen ok so I tried a couple of different ways but i am getting no results maybe market has to be open for that type of scan .Its not working. I dont know if i am doing something wrong? Thanks for help
 
Thanks for reply TraderZen ok so I tried a couple of different ways but i am getting no results maybe market has to be open for that type of scan .Its not working. I dont know if i am doing something wrong? Thanks for help
Ahh.. I know why .. and I sincerely apologize for not realizing this earlier @DOUBLE MOVE
(I promise I'll make up for this oversight!) ..

So, The code was intended to be used for scalping and then I shared it - never actually cared to turn on the MTF feature for the Day Aggregation Period. I guess you are trying to scan at the D level.
Let's first make this arrangement and then I'll create a scan if you still don't see results.

I have noted this and I'll make the new code available over the weekend - hopefully.
 
OK THANKS much appreciated was trying to scan for 1hour levels
Please refer to the top post in this thread.

V3 code is available now. D level MTF is available. Please select aggregation levels and current timeframes carefully.
In addition custom VWAP and Point of Interest Profiler (V1) is also available to go with this code.

Both of the studies when combined at the right time frames provide great insight into price action and price levels.

Please try and see if this version help with the scanner - otherwise I'll attempt to create one!
 
Please refer to the top post in this thread.

V3 code is available now. D level MTF is available. Please select aggregation levels and current timeframes carefully.
In addition custom VWAP and Point of Interest Profiler (V1) is also available to go with this code.

Both of the studies when combined at the right time frames provide great insight into price action and price levels.

Please try and see if this version help with the scanner - otherwise I'll attempt to create one!
Thanks TraderZen so i tried to scan on new code and I am trying to scan for price open is <or= to P_HigherTP_RR Hourly but it still says to complex so maybe that its not able to scan?
 
Thanks TraderZen so i tried to scan on new code and I am trying to scan for price open is <or= to P_HigherTP_RR Hourly but it still says to complex so maybe that its not able to scan?
Confirmed. Trimming the code to create a scan. error msg is gone but I am not getting any results except for once.. testing.
 
Thanks TraderZen so i tried to scan on new code and I am trying to scan for price open is <or= to P_HigherTP_RR Hourly but it still says to complex so maybe that its not able to scan?
@DOUBLE MOVE - Scanner code is available, along with the screenshots and general info/guidelines. Please refer to the top post in this thread.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
585 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top