Candle Standard Deviations

Cribbage

Member
I'm trying to make a script that will show standard deviations of the candle's range. I'm using it to measure the range of M5 candles on the M1 chart, so if it worked, it would show the high/low of the M5, then show 6 standard deviations above and below. I copied the script from TOS's DailyHighLow script, then added some script that I believed would work. The result is that nothing shows up at all. (Code Below)

I used the quadrant tool to show a single demonstration on the 445 candle as an example of what I'm looking for. Any help is appreciated!

TOS Delete Soon.png
.


Code:
input aggregationPeriod = AggregationPeriod.FIVE_MIN;
input length = 1;
input displace = 0;
input showOnlyLastPeriod = no;

plot DailyHigh;
plot DailyLow;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    DailyHigh = Double.NaN;
    DailyLow = Double.NaN;
} else {
    DailyHigh = Highest(high(period = aggregationPeriod)[-displace], length);
    DailyLow = Lowest(low(period = aggregationPeriod)[-displace], length);
}

DailyHigh.SetDefaultColor(GetColor(4));
DailyHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
DailyLow.SetDefaultColor(GetColor(4));
DailyLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);


### 8/24/24 CRIBBAGE STANDARD DEVIATIONS ###

# ---------------------------------------------

def na = Double.NaN;
def HILINE = DailyHigh;
def LOLINE = DailyLow;

def PRangeL = HILINE - LOLINE;

# Cribbage End
# ---------------------------------------------

##CRIBBAGE MIDLINE AND STANDARD DEVIATIONS START##

#Midline#

###  Have not used this code on this script
#Input Show_Mid = yes;
#Def MidLine = (PRangeL/2) + LoLine;
#Plot middle = if show_mid then MidLine else na;
#Middle.SetDefaultColor(GlobalColor("V"));
#Middle.SetStyle(Curve.SHORT_DASH);

#Standard Deviations#

input Show_SDs = Yes;

#Highs#
def SD1 = PRangeL + HILINE;
def SD2 = (PRangeL * 2) + HILINE;
def SD3 = (PRangeL * 3) + HILINE;
def SD10 = (PRangeL * 4) + HILINE;
def SD11 = (PRangeL * 5) + HILINE;
def SD12 = (PRangeL * 6) + HILINE;

plot SDLine1 = if Show_SDs then SD1 else na;
SDLine1.SetDefaultColor(GlobalColor("V"));
SDLine1.SetStyle(Curve.SHORT_DASH);

plot SDLine2 = if Show_SDs then SD2 else na;
SDLine2.SetDefaultColor(GlobalColor("V"));
SDLine2.SetStyle(Curve.SHORT_DASH);

plot SDLine3 = if Show_SDs then SD3 else na;
SDLine3.SetDefaultColor(GlobalColor("V"));
SDLine3.SetStyle(Curve.SHORT_DASH);

plot SDLine10 = if Show_SDs then SD10 else na;
SDLine10.SetDefaultColor(GlobalColor("V"));
SDLine10.SetStyle(Curve.SHORT_DASH);

plot SDLine11 = if Show_SDs then SD11 else na;
SDLine11.SetDefaultColor(GlobalColor("V"));
SDLine11.SetStyle(Curve.SHORT_DASH);

plot SDLine12 = if Show_SDs then SD12 else na;
SDLine12.SetDefaultColor(GlobalColor("V"));
SDLine12.SetStyle(Curve.SHORT_DASH);

#Lows#
def SD4 = LOLINE - PRangeL;
def SD5 = LOLINE - (PRangeL * 2);
def SD6 = LOLINE - (PRangeL * 3);
def SD7 = LOLINE - (PRangeL * 4);
def SD8 = LOLINE - (PRangeL * 5);
def SD9 = LOLINE - (PRangeL * 6);

plot SDLine4 = if Show_SDs then SD4 else na;
SDLine4.SetDefaultColor(GlobalColor("V"));
SDLine4.SetStyle(Curve.SHORT_DASH);

plot SDLine5 = if Show_SDs then SD5 else na;
SDLine5.SetDefaultColor(GlobalColor("V"));
SDLine5.SetStyle(Curve.SHORT_DASH);

plot SDLine6 = if Show_SDs then SD6 else na;
SDLine6.SetDefaultColor(GlobalColor("V"));
SDLine6.SetStyle(Curve.SHORT_DASH);

plot SDLine7 = if Show_SDs then SD7 else na;
SDLine7.SetDefaultColor(GlobalColor("V"));
SDLine7.SetStyle(Curve.SHORT_DASH);

plot SDLine8 = if Show_SDs then SD8 else na;
SDLine8.SetDefaultColor(GlobalColor("V"));
SDLine8.SetStyle(Curve.SHORT_DASH);

plot SDLine9 = if Show_SDs then SD9 else na;
SDLine9.SetDefaultColor(GlobalColor("V"));
SDLine9.SetStyle(Curve.SHORT_DASH);

##CRIBBAGE MIDLINE AND STANDARD DEVIATIONS END##
 
Solution
I'm trying to make a script that will show standard deviations of the candle's range. I'm using it to measure the range of M5 candles on the M1 chart, so if it worked, it would show the high/low of the M5, then show 6 standard deviations above and below. I copied the script from TOS's DailyHighLow script, then added some script that I believed would work. The result is that nothing shows up at all. (Code Below)

I used the quadrant tool to show a single demonstration on the 445 candle as an example of what I'm looking for. Any help is appreciated!

View attachment 22748.


Code:
input aggregationPeriod = AggregationPeriod.FIVE_MIN;
input length = 1;
input displace = 0;
input showOnlyLastPeriod = no;

plot DailyHigh;
plot DailyLow;
if...
I'm trying to make a script that will show standard deviations of the candle's range. I'm using it to measure the range of M5 candles on the M1 chart, so if it worked, it would show the high/low of the M5, then show 6 standard deviations above and below. I copied the script from TOS's DailyHighLow script, then added some script that I believed would work. The result is that nothing shows up at all. (Code Below)

I used the quadrant tool to show a single demonstration on the 445 candle as an example of what I'm looking for. Any help is appreciated!

View attachment 22748.


Code:
input aggregationPeriod = AggregationPeriod.FIVE_MIN;
input length = 1;
input displace = 0;
input showOnlyLastPeriod = no;

plot DailyHigh;
plot DailyLow;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    DailyHigh = Double.NaN;
    DailyLow = Double.NaN;
} else {
    DailyHigh = Highest(high(period = aggregationPeriod)[-displace], length);
    DailyLow = Lowest(low(period = aggregationPeriod)[-displace], length);
}

DailyHigh.SetDefaultColor(GetColor(4));
DailyHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
DailyLow.SetDefaultColor(GetColor(4));
DailyLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);


### 8/24/24 CRIBBAGE STANDARD DEVIATIONS ###

# ---------------------------------------------

def na = Double.NaN;
def HILINE = DailyHigh;
def LOLINE = DailyLow;

def PRangeL = HILINE - LOLINE;

# Cribbage End
# ---------------------------------------------

##CRIBBAGE MIDLINE AND STANDARD DEVIATIONS START##

#Midline#

###  Have not used this code on this script
#Input Show_Mid = yes;
#Def MidLine = (PRangeL/2) + LoLine;
#Plot middle = if show_mid then MidLine else na;
#Middle.SetDefaultColor(GlobalColor("V"));
#Middle.SetStyle(Curve.SHORT_DASH);

#Standard Deviations#

input Show_SDs = Yes;

#Highs#
def SD1 = PRangeL + HILINE;
def SD2 = (PRangeL * 2) + HILINE;
def SD3 = (PRangeL * 3) + HILINE;
def SD10 = (PRangeL * 4) + HILINE;
def SD11 = (PRangeL * 5) + HILINE;
def SD12 = (PRangeL * 6) + HILINE;

plot SDLine1 = if Show_SDs then SD1 else na;
SDLine1.SetDefaultColor(GlobalColor("V"));
SDLine1.SetStyle(Curve.SHORT_DASH);

plot SDLine2 = if Show_SDs then SD2 else na;
SDLine2.SetDefaultColor(GlobalColor("V"));
SDLine2.SetStyle(Curve.SHORT_DASH);

plot SDLine3 = if Show_SDs then SD3 else na;
SDLine3.SetDefaultColor(GlobalColor("V"));
SDLine3.SetStyle(Curve.SHORT_DASH);

plot SDLine10 = if Show_SDs then SD10 else na;
SDLine10.SetDefaultColor(GlobalColor("V"));
SDLine10.SetStyle(Curve.SHORT_DASH);

plot SDLine11 = if Show_SDs then SD11 else na;
SDLine11.SetDefaultColor(GlobalColor("V"));
SDLine11.SetStyle(Curve.SHORT_DASH);

plot SDLine12 = if Show_SDs then SD12 else na;
SDLine12.SetDefaultColor(GlobalColor("V"));
SDLine12.SetStyle(Curve.SHORT_DASH);

#Lows#
def SD4 = LOLINE - PRangeL;
def SD5 = LOLINE - (PRangeL * 2);
def SD6 = LOLINE - (PRangeL * 3);
def SD7 = LOLINE - (PRangeL * 4);
def SD8 = LOLINE - (PRangeL * 5);
def SD9 = LOLINE - (PRangeL * 6);

plot SDLine4 = if Show_SDs then SD4 else na;
SDLine4.SetDefaultColor(GlobalColor("V"));
SDLine4.SetStyle(Curve.SHORT_DASH);

plot SDLine5 = if Show_SDs then SD5 else na;
SDLine5.SetDefaultColor(GlobalColor("V"));
SDLine5.SetStyle(Curve.SHORT_DASH);

plot SDLine6 = if Show_SDs then SD6 else na;
SDLine6.SetDefaultColor(GlobalColor("V"));
SDLine6.SetStyle(Curve.SHORT_DASH);

plot SDLine7 = if Show_SDs then SD7 else na;
SDLine7.SetDefaultColor(GlobalColor("V"));
SDLine7.SetStyle(Curve.SHORT_DASH);

plot SDLine8 = if Show_SDs then SD8 else na;
SDLine8.SetDefaultColor(GlobalColor("V"));
SDLine8.SetStyle(Curve.SHORT_DASH);

plot SDLine9 = if Show_SDs then SD9 else na;
SDLine9.SetDefaultColor(GlobalColor("V"));
SDLine9.SetStyle(Curve.SHORT_DASH);

##CRIBBAGE MIDLINE AND STANDARD DEVIATIONS END##

sometimes, when there are errors, there is a white circle with a !, in the top left of chart.
click on it and it will list errors

color v is not defined
add this,
DefineGlobalColor("v", Color.yellow);

click on white circle again,
agg time issue. change chart to 1 minute
it draws lines, but connected

add this to all the plots, to create short horizontal lines
x.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);


Code:
#mtf_rng_dev

#https://usethinkscript.com/threads/candle-standard-deviations.19509/
#Candle Standard Deviations
#Cribbage  9/7

#1
#I'm trying to make a script that will show standard deviations of the candle's range. I'm using it to measure the range of M5 candles on the M1 chart, so if it worked, it would show the high/low of the M5, then show 6 standard deviations above and below. I copied the script from TOS's DailyHighLow script, then added some script that I believed would work. The result is that nothing shows up at all. (Code Below)

#I used the quadrant tool to show a single demonstration on the 445 candle as an example of what I'm looking for. Any help is appreciated!

DefineGlobalColor("v", Color.yellow);

input aggregationPeriod = AggregationPeriod.FIVE_MIN;
input length = 1;
input displace = 0;
input showOnlyLastPeriod = no;

plot DailyHigh;
plot DailyLow;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    DailyHigh = Double.NaN;
    DailyLow = Double.NaN;
} else {
    DailyHigh = Highest(high(period = aggregationPeriod)[-displace], length);
    DailyLow = Lowest(low(period = aggregationPeriod)[-displace], length);
}

DailyHigh.SetDefaultColor(GetColor(4));
DailyHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
DailyLow.SetDefaultColor(GetColor(4));
DailyLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);


### 8/24/24 CRIBBAGE STANDARD DEVIATIONS ###

# ---------------------------------------------

def na = Double.NaN;
def HILINE = DailyHigh;
def LOLINE = DailyLow;

def PRangeL = HILINE - LOLINE;

# Cribbage End
# ---------------------------------------------

##CRIBBAGE MIDLINE AND STANDARD DEVIATIONS START##

#Midline#

###  Have not used this code on this script
#Input Show_Mid = yes;
#Def MidLine = (PRangeL/2) + LoLine;
#Plot middle = if show_mid then MidLine else na;
#Middle.SetDefaultColor(GlobalColor("V"));
#Middle.SetStyle(Curve.SHORT_DASH);

#Standard Deviations#

input Show_SDs = Yes;

#Highs#
def SD1 = PRangeL + HILINE;
def SD2 = (PRangeL * 2) + HILINE;
def SD3 = (PRangeL * 3) + HILINE;
def SD10 = (PRangeL * 4) + HILINE;
def SD11 = (PRangeL * 5) + HILINE;
def SD12 = (PRangeL * 6) + HILINE;

plot SDLine1 = if Show_SDs then SD1 else na;
sdline1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SDLine1.SetDefaultColor(GlobalColor("V"));
SDLine1.SetStyle(Curve.SHORT_DASH);

plot SDLine2 = if Show_SDs then SD2 else na;
sdline2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SDLine2.SetDefaultColor(GlobalColor("V"));
SDLine2.SetStyle(Curve.SHORT_DASH);

plot SDLine3 = if Show_SDs then SD3 else na;
sdline3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SDLine3.SetDefaultColor(GlobalColor("V"));
SDLine3.SetStyle(Curve.SHORT_DASH);

plot SDLine10 = if Show_SDs then SD10 else na;
sdline10.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SDLine10.SetDefaultColor(GlobalColor("V"));
SDLine10.SetStyle(Curve.SHORT_DASH);

plot SDLine11 = if Show_SDs then SD11 else na;
sdline11.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SDLine11.SetDefaultColor(GlobalColor("V"));
SDLine11.SetStyle(Curve.SHORT_DASH);

plot SDLine12 = if Show_SDs then SD12 else na;
sdline12.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SDLine12.SetDefaultColor(GlobalColor("V"));
SDLine12.SetStyle(Curve.SHORT_DASH);

#Lows#
def SD4 = LOLINE - PRangeL;
def SD5 = LOLINE - (PRangeL * 2);
def SD6 = LOLINE - (PRangeL * 3);
def SD7 = LOLINE - (PRangeL * 4);
def SD8 = LOLINE - (PRangeL * 5);
def SD9 = LOLINE - (PRangeL * 6);

plot SDLine4 = if Show_SDs then SD4 else na;
sdline4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SDLine4.SetDefaultColor(GlobalColor("V"));
SDLine4.SetStyle(Curve.SHORT_DASH);

plot SDLine5 = if Show_SDs then SD5 else na;
sdline5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SDLine5.SetDefaultColor(GlobalColor("V"));
SDLine5.SetStyle(Curve.SHORT_DASH);

plot SDLine6 = if Show_SDs then SD6 else na;
sdline6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SDLine6.SetDefaultColor(GlobalColor("V"));
SDLine6.SetStyle(Curve.SHORT_DASH);

plot SDLine7 = if Show_SDs then SD7 else na;
sdline7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SDLine7.SetDefaultColor(GlobalColor("V"));
SDLine7.SetStyle(Curve.SHORT_DASH);

plot SDLine8 = if Show_SDs then SD8 else na;
sdline8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SDLine8.SetDefaultColor(GlobalColor("V"));
SDLine8.SetStyle(Curve.SHORT_DASH);

plot SDLine9 = if Show_SDs then SD9 else na;
sdline9.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SDLine9.SetDefaultColor(GlobalColor("V"));
SDLine9.SetStyle(Curve.SHORT_DASH);

##CRIBBAGE MIDLINE AND STANDARD DEVIATIONS END##
 
Solution

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
492 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