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!
.
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!
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##