need help aligning stoplight bubbles!

floydddd

Active member
So, in the pic below you can see how the stoplight bubbles on the right aren't lining up properly. everything is shifted up just a bit, throwing everything off. is there a way to fix this, maybe with a simpler bubble? Thanks!

p.s. please to excuse the messiness of my coding. it's all a work in progress.

wGojFZh.png



Code:
declare lower;

input name = "   turning,  dmi,  sto,  kelt,  rsi,  ppo,  X+  ";

#  move bubbles

def symbol1Signal = 1;
def symbol2Signal = 1.5;
def symbol3Signal = 2;
def symbol4Signal = 2.5;
def symbol5Signal = 3;
def symbol6Signal = 3.5;
def symbol7Signal = 4;


def x = -2;
def y = -2;


#  bubbles


# X+
def highestBarSymbol1 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol1 = highestBarSymbol1 - x;
AddChartBubble( barNumber() == referenceBarSymbol1,symbol1Signal,"x+"
,Color.GREEN);

# PPO

def highestBarSymbol2 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol2 = highestBarSymbol2 - y;
AddChartBubble( barNumber() == referenceBarSymbol2,symbol2Signal,"ppo",Color.GREEN);

#RSI
def highestBarSymbol3 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol3 = highestBarSymbol2 - x;
AddChartBubble( barNumber() == referenceBarSymbol3,symbol3Signal,"rsi",Color.GREEN);

#kelt
def highestBarSymbol4 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol4 = highestBarSymbol3 - y;
AddChartBubble( barNumber() == referenceBarSymbol4,symbol4Signal,"kelt",Color.GREEN);

#sto
def highestBarSymbol5 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol5 = highestBarSymbol4- x;
AddChartBubble( barNumber() == referenceBarSymbol5,symbol5Signal,"sto",Color.GREEN);

#dmi
def highestBarSymbol6 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol6 = highestBarSymbol4 - y;
AddChartBubble( barNumber() == referenceBarSymbol6,symbol6Signal,"dmi",Color.GREEN);

#turn
def highestBarSymbol7 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol7 = highestBarSymbol7 - x;
AddChartBubble( barNumber() == referenceBarSymbol7,symbol7Signal,"turn",Color.GREEN);

   # signals

#ppo

def price = close;

def PPO_Period_Fast = 12;
def PPO_Period_Slow = 26;
def PPO_Period_Signal = 9;


def PPO_EMA_Fast = ExpAverage(price, PPO_Period_Fast);
def PPO_EMA_Slow = ExpAverage(price, PPO_Period_Slow);
def PPO_Line = ((PPO_EMA_Fast - PPO_EMA_Slow) / PPO_EMA_Slow) * 100;


def PPO_EMA   = ExpAverage(PPO_Line, PPO_Period_Signal);


# Indicator Plots
    # Indicator Statuses (1 = Up or Positive, 0 = Down or Negative)

def PPO_Status = if PPO_EMA >= 0 and PPO_Line >= 0 then 1 else 0;

def ppo_up = PPO_EMA >= 0 and PPO_Line >= 0;
def ppo_dn = PPO_EMA <= 0 and PPO_Line <= 0;
def x_up = PPO_Line crosses above PPO_EMA;
def x_dn = PPO_Line crosses below PPO_EMA;
def ox_up = PPO_EMA crosses above 0;
def ox_dn = PPO_EMA crosses below PPO_Line;

def xup2 = PPO_Line >= PPO_EMA;
def xdn2 = PPO_Line <= PPO_EMA;

plot ppoline = if IsNaN(close) then Double.NaN else 1;
ppoline.SetPaintingStrategy(PaintingStrategy.POINTS);
ppoline.SetLineWeight(5);
ppoline.AssignValueColor(if xup2 then Color.GREEN else if xdn2 then Color.RED else Color.black);
ppoline.HideBubble();

plot ppoline2 = if IsNaN(close) then Double.NaN else 1.5;
ppoline2.SetPaintingStrategy(PaintingStrategy.POINTS);
ppoline2.SetLineWeight(5);
ppoline2.AssignValueColor(if ppo_up then Color.GREEN else if ppo_dn then Color.RED else Color.black);
ppoline2.HideBubble();

#RSI

def rsilength = 5;
def rsitrigger = 30;
#input averageType = AverageType.WILDERS;

def NetChgAvg = MovingAverage(AverageType.WILDERS, price - price[1], rsilength);
def TotChgAvg = MovingAverage(AverageType.WILDERS, AbsValue(price - price[1]), rsilength);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);

plot rsi_Line = if IsNaN(close) then Double.NaN else 2;
rsi_Line.SetPaintingStrategy(PaintingStrategy.POINTS);
rsi_Line.SetLineWeight(5);
rsi_Line.AssignValueColor(if RSI <= rsitrigger then Color.GREEN else Color.black);

# Keltner

def displace = 0;
def h = high;
def l = low;
def c = close;

# Keltner Channel set similar to BollingerBands PercentB by Lar (Longer Term Trend)
def factorKCLT = 1.800;
def lengthKCLT = 20.000;
def atr_length = 10;

def shiftKCLT = factorKCLT * MovingAverage(AverageType.WILDERS, TrueRange(high, close, low), atr_length);

def averageKCLT = MovingAverage(AverageType.EXPONENTIAL, close, lengthKCLT);

def AvgKCLT = averageKCLT[-displace];

def Upper_BandKCLT = averageKCLT[-displace] + shiftKCLT[-displace];
def Lower_BandKCLT = averageKCLT[-displace] - shiftKCLT[-displace];

def PercentkLT = (l - Lower_BandKCLT) / (Upper_BandKCLT - Lower_BandKCLT) * 100;

#PercentkLT.Hide();

def LTcross = PercentkLT crosses below 0;

def LT2 = PercentkLT < 0;

# keltner 2


# Keltner Channel set similar to BollingerBands PercentB by Lar (Shorter Term Trend)
def factorKCST = 3;
def lengthKCST = 20.000;

def shiftKCST = factorKCST * MovingAverage(AverageType.WILDERS, TrueRange(high, close, low), atr_length);

def averageKCST = MovingAverage(AverageType.EXPONENTIAL, close, lengthKCST);

def AvgKCST = averageKCST[-displace];
def Upper_BandKCST = averageKCST[-displace] + shiftKCST[-displace];
def Lower_BandKCST = averageKCST[-displace] - shiftKCST[-displace];

def PercentkST = (low - Lower_BandKCST) / (Upper_BandKCST - Lower_BandKCST) * 100;

def STcross = PercentkST crosses below 0;

plot pkst = if IsNaN(close) then Double.NaN else 2.5;
pkst.SetPaintingStrategy(PaintingStrategy.POINTS);
pkst.SetLineWeight(5);
pkst.AssignValueColor(if STcross then Color.GREEN else if LT2 then Color.MAGENTA else Color.black);
pkst.HideBubble();

# stochastic

def over_bought = 50;
def over_sold = 20;
def KPeriod = 5;
def DPeriod = 3;
def priceH = high;
def priceL = low;
def priceC = close;
def averageType = AverageType.SIMPLE;

def SlowK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, if (averageType == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullK;

def SlowD = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, if (averageType == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullD;

plot upk_Line = if IsNaN(close) then Double.NaN else 3;
upk_Line.SetPaintingStrategy(PaintingStrategy.POINTS);
upk_Line.SetLineWeight(5);
upk_Line.AssignValueColor(if SlowK < 20 then Color.WHITE else if SlowK crosses above 20 then Color.GREEN else Color.black);
upk_Line.HideBubble();


# DMI ADX

def dmi = reference DIPlus(length = 5);
def signal = dmi <= 5;

def adx = reference ADX(length = 3);

def signal2 = adx >= 70 and dmi <= 10;

def crossing = Crosses (signal2, CrossingDirection.ABOVE);

def signal3 = adx >= 80 and dmi <= 5;

#crossing.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

#def BS2 = if Signal2 then 0 else Double.NaN

#def UpSignal = if crossing then 0 else Double.NaN;

plot dmiline = if IsNaN(close) then Double.NaN else 3.5;
dmiline.SetPaintingStrategy(PaintingStrategy.POINTS);
dmiline.SetLineWeight(5);
dmiline.AssignValueColor(if signal2 then Color.GREEN else Color.black);
dmiline.HideBubble();


# Turning Value

def length = 5;

def VarP = Round(length / 5);
def VarA = Highest(high, VarP) - Lowest(low, VarP);
def VarR1 = if VarA == 0 and VarP == 1 then AbsValue(close - close[VarP]) else VarA;
def VarB = Highest(high, VarP)[VarP + 1] - Lowest(low, VarP)[VarP];
def VarR2 = if VarB == 0 and VarP == 1 then AbsValue(close[VarP] - close[VarP * 2]) else VarB;
def VarC = Highest(high, VarP)[VarP * 2] - Lowest(low, VarP)[VarP * 2];

def VarR3 = if VarC == 0 and VarP == 1 then AbsValue(close[VarP * 2] - close[VarP * 3]) else VarC;

def VarD = Highest(high, VarP)[VarP * 3] - Lowest(low, VarP)[VarP * 3];
def VarR4 =
if VarD == 0 and VarP == 1 then AbsValue(close[VarP * 3] - close[VarP * 4]) else VarD;

def VarE = Highest(high, VarP)[VarP * 4] - Lowest(low, VarP)[VarP * 4];
def VarR5 = if VarE == 0 and VarP == 1 then AbsValue(close[VarP * 4] - close[VarP * 5]) else VarE;

def LRange = ((VarR1 + VarR2 + VarR3 + VarR4 + VarR5) / 5) * 0.2;

def Var0 = if AbsValue(close - close[1]) > (high - low) then AbsValue(close - close[1]) else (high - low);
def LRange2 = if high == low then Average(AbsValue(close - close[1]), 5) * 0.2 else Average(Var0, 5) * 0.2;

def range = high + low;
def delta = high - low;
def median = range / 2;
def floatingAxis = Average(median, length);
def dynamicVolatilityUnit = if length <= 7 then LRange2 else LRange;
def relativeHigh = (high - floatingAxis) / dynamicVolatilityUnit;
def relativeLow = (low - floatingAxis) / dynamicVolatilityUnit;
def relativeOpen = (open - floatingAxis) / dynamicVolatilityUnit;
def relativeClose = (close - floatingAxis) / dynamicVolatilityUnit;

def "High" = relativeHigh;

def "Low" = relativeLow;

def length2 = 10;
def stdLength = 60;

def rolling = (close - close[length2]) * 100 / close[length2];

def updev = StDev(rolling, stdLength);

def twoupdev = 2 * StDev(rolling, stdLength);

def downdev = -StDev(rolling, stdLength);

def twodowndev = -2 * StDev(rolling, stdLength);

def combined = rolling <= downdev and "Low" <= -8;

def sell = rolling >= updev and "High" >= 8;

#combined.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

#sell.setpaintingstrategy (paintingstrategy.histogram);

#combined.AssignValueColor (if combined then Color.GREEN else if sell then Color.RED else color.yellow);

#combined.SetLineWeight(2);

plot roll = if IsNaN(close) then Double.NaN else 4;
roll.SetPaintingStrategy(PaintingStrategy.POINTS);
roll.SetLineWeight(5);
roll.AssignValueColor(if combined then Color.GREEN else if sell then Color.RED else Color.black);
roll.HideBubble();

#========== Bubbles ==========

plot Filler = if IsNaN(close) then Double.NaN else 4.5;

#Filler.Hide();

def barNum = BarNumber();
def offset = 30;
def LastBar = !IsNaN(open) and IsNaN(open [-1]);
def BubbleLocation = LastBar[offset];
def FirstBar = barNum == 1;
def FirstBarValue = barNum == 1;
def LastBarValue = if LastBar then barNum else 0;
def MidBar = if LastBar then barNum == (BarNumber() / 2) else 0;

#AddChartBubble(FirstBar, 1, "X+", Color.PINK);
#AddChartBubble(FirstBar, 1.5, "ppo", Color.PINK);
#AddChartBubble(FirstBar, 2, "rsi", Color.BLUE);
#AddChartBubble(FirstBar, 2.5, "kelt", Color.MAGENTA);
#AddChartBubble(FirstBar, 3, "sto", Color.YELLOW);
#AddChartBubble(FirstBar, 3.5, "dmi", Color.YELLOW);
#AddChartBubble(FirstBar, 4, "turning", Color.GREEN);

#def upK = SlowK crosses above 20;
#def signal2 = slowk < 20;
 
Solution
yes, you are right -- it's the damn tag. any way to do away w/ it? barring that, i tried adding a filler bubble, trying to force things down, but i couldn't quite figure it out.

or else maybe there's another variable like the x and y i have in the code, one that moves the bubble up and down?

See if this helps. Change the input updown and zero to fine tune the bubble placement vertcally to your liking.

Capture.jpg
Code:
declare lower;

input name = "   turning,  dmi,  sto,  kelt,  rsi,  ppo,  X+  ";

#  move bubbles

def symbol1Signal = 1;
def symbol2Signal = 1.5;
def symbol3Signal = 2;
def symbol4Signal = 2.5;
def symbol5Signal = 3;
def symbol6Signal = 3.5;
def symbol7Signal = 4;


def x = -2;
def y = -2;


#  bubbles

input...
It's not really shifted... the little tag off the bottom of the bubble sits just above the thing it is describing. They're not exactly in-line labels as such.

HTH,
Happy Trading,
Mashume
 

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

yes, you are right -- it's the damn tag. any way to do away w/ it? barring that, i tried adding a filler bubble, trying to force things down, but i couldn't quite figure it out.

or else maybe there's another variable like the x and y i have in the code, one that moves the bubble up and down?
 
yes, you are right -- it's the damn tag. any way to do away w/ it? barring that, i tried adding a filler bubble, trying to force things down, but i couldn't quite figure it out.

or else maybe there's another variable like the x and y i have in the code, one that moves the bubble up and down?

See if this helps. Change the input updown and zero to fine tune the bubble placement vertcally to your liking.

Capture.jpg
Code:
declare lower;

input name = "   turning,  dmi,  sto,  kelt,  rsi,  ppo,  X+  ";

#  move bubbles

def symbol1Signal = 1;
def symbol2Signal = 1.5;
def symbol3Signal = 2;
def symbol4Signal = 2.5;
def symbol5Signal = 3;
def symbol6Signal = 3.5;
def symbol7Signal = 4;


def x = -2;
def y = -2;


#  bubbles

input updown = .5;
plot zerobase = .75;
# X+
def highestBarSymbol1 = HighestAll( if IsNaN(close) then Double.NaN else BarNumber() );
def referenceBarSymbol1 = highestBarSymbol1 - x;
AddChartBubble( BarNumber() == referenceBarSymbol1, symbol1Signal + updown, "x+"
, Color.GREEN, up = no);

# PPO

def highestBarSymbol2 = HighestAll( if IsNaN(close) then Double.NaN else BarNumber() );
def referenceBarSymbol2 = highestBarSymbol2 - y;
AddChartBubble( BarNumber() == referenceBarSymbol2, symbol2Signal + updown, "ppo", Color.GREEN, up = no);

#RSI
def highestBarSymbol3 = HighestAll( if IsNaN(close) then Double.NaN else BarNumber() );
def referenceBarSymbol3 = highestBarSymbol2 - x;
AddChartBubble( BarNumber() == referenceBarSymbol3, symbol3Signal + updown, "rsi", Color.GREEN, up = no);

#kelt
def highestBarSymbol4 = HighestAll( if IsNaN(close) then Double.NaN else BarNumber() );
def referenceBarSymbol4 = highestBarSymbol3 - y;
AddChartBubble( BarNumber() == referenceBarSymbol4, symbol4Signal + updown, "kelt", Color.GREEN, up = no);

#sto
def highestBarSymbol5 = HighestAll( if IsNaN(close) then Double.NaN else BarNumber() );
def referenceBarSymbol5 = highestBarSymbol4 - x;
AddChartBubble( BarNumber() == referenceBarSymbol5, symbol5Signal + updown, "sto", Color.GREEN, up = no);

#dmi
def highestBarSymbol6 = HighestAll( if IsNaN(close) then Double.NaN else BarNumber() );
def referenceBarSymbol6 = highestBarSymbol4 - y;
AddChartBubble( BarNumber() == referenceBarSymbol6, symbol6Signal + updown, "dmi", Color.GREEN, up = no);

#turn
def highestBarSymbol7 = HighestAll( if IsNaN(close) then Double.NaN else BarNumber() );
def referenceBarSymbol7 = highestBarSymbol7 - x;
AddChartBubble( BarNumber() == referenceBarSymbol7, symbol7Signal + updown, "turn", Color.GREEN, up = no);

   # signals

#ppo

def price = close;

def PPO_Period_Fast = 12;
def PPO_Period_Slow = 26;
def PPO_Period_Signal = 9;


def PPO_EMA_Fast = ExpAverage(price, PPO_Period_Fast);
def PPO_EMA_Slow = ExpAverage(price, PPO_Period_Slow);
def PPO_Line = ((PPO_EMA_Fast - PPO_EMA_Slow) / PPO_EMA_Slow) * 100;


def PPO_EMA   = ExpAverage(PPO_Line, PPO_Period_Signal);


# Indicator Plots
    # Indicator Statuses (1 = Up or Positive, 0 = Down or Negative)

def PPO_Status = if PPO_EMA >= 0 and PPO_Line >= 0 then 1 else 0;

def ppo_up = PPO_EMA >= 0 and PPO_Line >= 0;
def ppo_dn = PPO_EMA <= 0 and PPO_Line <= 0;
def x_up = PPO_Line crosses above PPO_EMA;
def x_dn = PPO_Line crosses below PPO_EMA;
def ox_up = PPO_EMA crosses above 0;
def ox_dn = PPO_EMA crosses below PPO_Line;

def xup2 = PPO_Line >= PPO_EMA;
def xdn2 = PPO_Line <= PPO_EMA;

plot ppoline = if IsNaN(close) then Double.NaN else 1;
ppoline.SetPaintingStrategy(PaintingStrategy.POINTS);
ppoline.SetLineWeight(5);
ppoline.AssignValueColor(if xup2 then Color.GREEN else if xdn2 then Color.RED else Color.BLACK);
ppoline.HideBubble();

plot ppoline2 = if IsNaN(close) then Double.NaN else 1.5;
ppoline2.SetPaintingStrategy(PaintingStrategy.POINTS);
ppoline2.SetLineWeight(5);
ppoline2.AssignValueColor(if ppo_up then Color.GREEN else if ppo_dn then Color.RED else Color.BLACK);
ppoline2.HideBubble();

#RSI

def rsilength = 5;
def rsitrigger = 30;
#input averageType = AverageType.WILDERS;

def NetChgAvg = MovingAverage(AverageType.WILDERS, price - price[1], rsilength);
def TotChgAvg = MovingAverage(AverageType.WILDERS, AbsValue(price - price[1]), rsilength);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);

plot rsi_Line = if IsNaN(close) then Double.NaN else 2;
rsi_Line.SetPaintingStrategy(PaintingStrategy.POINTS);
rsi_Line.SetLineWeight(5);
rsi_Line.AssignValueColor(if RSI <= rsitrigger then Color.GREEN else Color.BLACK);

# Keltner

def displace = 0;
def h = high;
def l = low;
def c = close;

# Keltner Channel set similar to BollingerBands PercentB by Lar (Longer Term Trend)
def factorKCLT = 1.800;
def lengthKCLT = 20.000;
def atr_length = 10;

def shiftKCLT = factorKCLT * MovingAverage(AverageType.WILDERS, TrueRange(high, close, low), atr_length);

def averageKCLT = MovingAverage(AverageType.EXPONENTIAL, close, lengthKCLT);

def AvgKCLT = averageKCLT[-displace];

def Upper_BandKCLT = averageKCLT[-displace] + shiftKCLT[-displace];
def Lower_BandKCLT = averageKCLT[-displace] - shiftKCLT[-displace];

def PercentkLT = (l - Lower_BandKCLT) / (Upper_BandKCLT - Lower_BandKCLT) * 100;

#PercentkLT.Hide();

def LTcross = PercentkLT crosses below 0;

def LT2 = PercentkLT < 0;

# keltner 2


# Keltner Channel set similar to BollingerBands PercentB by Lar (Shorter Term Trend)
def factorKCST = 3;
def lengthKCST = 20.000;

def shiftKCST = factorKCST * MovingAverage(AverageType.WILDERS, TrueRange(high, close, low), atr_length);

def averageKCST = MovingAverage(AverageType.EXPONENTIAL, close, lengthKCST);

def AvgKCST = averageKCST[-displace];
def Upper_BandKCST = averageKCST[-displace] + shiftKCST[-displace];
def Lower_BandKCST = averageKCST[-displace] - shiftKCST[-displace];

def PercentkST = (low - Lower_BandKCST) / (Upper_BandKCST - Lower_BandKCST) * 100;

def STcross = PercentkST crosses below 0;

plot pkst = if IsNaN(close) then Double.NaN else 2.5;
pkst.SetPaintingStrategy(PaintingStrategy.POINTS);
pkst.SetLineWeight(5);
pkst.AssignValueColor(if STcross then Color.GREEN else if LT2 then Color.MAGENTA else Color.BLACK);
pkst.HideBubble();

# stochastic

def over_bought = 50;
def over_sold = 20;
def KPeriod = 5;
def DPeriod = 3;
def priceH = high;
def priceL = low;
def priceC = close;
def averageType = AverageType.SIMPLE;

def SlowK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, if (averageType == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullK;

def SlowD = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, if (averageType == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullD;

plot upk_Line = if IsNaN(close) then Double.NaN else 3;
upk_Line.SetPaintingStrategy(PaintingStrategy.POINTS);
upk_Line.SetLineWeight(5);
upk_Line.AssignValueColor(if SlowK < 20 then Color.WHITE else if SlowK crosses above 20 then Color.GREEN else Color.BLACK);
upk_Line.HideBubble();


# DMI ADX

def dmi = reference DIPlus(length = 5);
def signal = dmi <= 5;

def adx = reference ADX(length = 3);

def signal2 = adx >= 70 and dmi <= 10;

def crossing = Crosses (signal2, CrossingDirection.ABOVE);

def signal3 = adx >= 80 and dmi <= 5;

#crossing.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

#def BS2 = if Signal2 then 0 else Double.NaN

#def UpSignal = if crossing then 0 else Double.NaN;

plot dmiline = if IsNaN(close) then Double.NaN else 3.5;
dmiline.SetPaintingStrategy(PaintingStrategy.POINTS);
dmiline.SetLineWeight(5);
dmiline.AssignValueColor(if signal2 then Color.GREEN else Color.BLACK);
dmiline.HideBubble();


# Turning Value

def length = 5;

def VarP = Round(length / 5);
def VarA = Highest(high, VarP) - Lowest(low, VarP);
def VarR1 = if VarA == 0 and VarP == 1 then AbsValue(close - close[VarP]) else VarA;
def VarB = Highest(high, VarP)[VarP + 1] - Lowest(low, VarP)[VarP];
def VarR2 = if VarB == 0 and VarP == 1 then AbsValue(close[VarP] - close[VarP * 2]) else VarB;
def VarC = Highest(high, VarP)[VarP * 2] - Lowest(low, VarP)[VarP * 2];

def VarR3 = if VarC == 0 and VarP == 1 then AbsValue(close[VarP * 2] - close[VarP * 3]) else VarC;

def VarD = Highest(high, VarP)[VarP * 3] - Lowest(low, VarP)[VarP * 3];
def VarR4 =
if VarD == 0 and VarP == 1 then AbsValue(close[VarP * 3] - close[VarP * 4]) else VarD;

def VarE = Highest(high, VarP)[VarP * 4] - Lowest(low, VarP)[VarP * 4];
def VarR5 = if VarE == 0 and VarP == 1 then AbsValue(close[VarP * 4] - close[VarP * 5]) else VarE;

def LRange = ((VarR1 + VarR2 + VarR3 + VarR4 + VarR5) / 5) * 0.2;

def Var0 = if AbsValue(close - close[1]) > (high - low) then AbsValue(close - close[1]) else (high - low);
def LRange2 = if high == low then Average(AbsValue(close - close[1]), 5) * 0.2 else Average(Var0, 5) * 0.2;

def range = high + low;
def delta = high - low;
def median = range / 2;
def floatingAxis = Average(median, length);
def dynamicVolatilityUnit = if length <= 7 then LRange2 else LRange;
def relativeHigh = (high - floatingAxis) / dynamicVolatilityUnit;
def relativeLow = (low - floatingAxis) / dynamicVolatilityUnit;
def relativeOpen = (open - floatingAxis) / dynamicVolatilityUnit;
def relativeClose = (close - floatingAxis) / dynamicVolatilityUnit;

def "High" = relativeHigh;

def "Low" = relativeLow;

def length2 = 10;
def stdLength = 60;

def rolling = (close - close[length2]) * 100 / close[length2];

def updev = StDev(rolling, stdLength);

def twoupdev = 2 * StDev(rolling, stdLength);

def downdev = -StDev(rolling, stdLength);

def twodowndev = -2 * StDev(rolling, stdLength);

def combined = rolling <= downdev and "Low" <= -8;

def sell = rolling >= updev and "High" >= 8;

#combined.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

#sell.setpaintingstrategy (paintingstrategy.histogram);

#combined.AssignValueColor (if combined then Color.GREEN else if sell then Color.RED else color.yellow);

#combined.SetLineWeight(2);

plot roll = if IsNaN(close) then Double.NaN else 4;
roll.SetPaintingStrategy(PaintingStrategy.POINTS);
roll.SetLineWeight(5);
roll.AssignValueColor(if combined then Color.GREEN else if sell then Color.RED else Color.BLACK);
roll.HideBubble();

#========== Bubbles ==========

plot Filler = if IsNaN(close) then Double.NaN else 4.5;

#Filler.Hide();

def barNum = BarNumber();
def offset = 30;
def LastBar = !IsNaN(open) and IsNaN(open [-1]);
def BubbleLocation = LastBar[offset];
def FirstBar = barNum == 1;
def FirstBarValue = barNum == 1;
def LastBarValue = if LastBar then barNum else 0;
def MidBar = if LastBar then barNum == (BarNumber() / 2) else 0;

#AddChartBubble(FirstBar, 1, "X+", Color.PINK);
#AddChartBubble(FirstBar, 1.5, "ppo", Color.PINK);
#AddChartBubble(FirstBar, 2, "rsi", Color.BLUE);
#AddChartBubble(FirstBar, 2.5, "kelt", Color.MAGENTA);
#AddChartBubble(FirstBar, 3, "sto", Color.YELLOW);
#AddChartBubble(FirstBar, 3.5, "dmi", Color.YELLOW);
#AddChartBubble(FirstBar, 4, "turning", Color.GREEN);

#def upK = SlowK crosses above 20;
#def signal2 = slowk < 20;
 
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
260 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