#Complete_Leledc
#Leledc Exhaustion Port
#https://usethinkscript.com/threads/leledc-exhaustion-indicator-for-thinkorswim.3369/page-3
#Original by @diazlaz
#hint maj_qual: Original setting is 6
#hint maj_len: Original setting is 30
#hint showMajorArrowsWeight: Min 1 Max 5
#hint showMajorLineWeight: Min 1 Max 5
input showMajor = yes;
input maj_qual = 6;
input maj_len = 30; #hint: Original setting is 30
input showMajorBuyers = yes;
input showMajorSellers = yes;
input showMajorArrows = yes;
input showMajorLines = yes;
input ShowMajorClouds = yes;
input MajorArrowsWeight = 2; #hint: Max is 5
input MajorLineWeight = 2; #hint: Max is 5
script lele {
input qual = 100; #note: does use input variable
input len = 100; #note: does use input variable
def bIndex = CompoundValue(1,
if (bIndex[1] > qual) and (close < open) and high >= Highest(high, len) then 0 else
if (close > close[4]) then bIndex[1] + 1 else bIndex[1]
, 0);
def sIndex = CompoundValue(1,
if ((sIndex[1] > qual) and (close > open) and (low <= Lowest(low, len))) then 0 else
if (close < close[4]) then sIndex[1] + 1 else sIndex[1]
, 0);
def ret =
if (bIndex[1] > qual) and (close < open) and high >= Highest(high, len) then -1 else
if ((sIndex[1] > qual) and (close > open) and (low <= Lowest(low, len))) then 1
else 0;
plot sData = ret;
}
###############
# Major section
###############
def major = lele(maj_qual,maj_len);
def MajorBuyers = major == 1;
def MajorSellers = major == -1;
###############
# Major Arrows
###############
plot MajorBuyersArrow = if showMajor and showMajorBuyers and showMajorArrows and MajorBuyers then low else double.nan ;
MajorBuyersArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
MajorBuyersArrow.SetDefaultColor(color.light_green);
MajorBuyersArrow.SetLineWeight(MajorArrowsWeight);
plot MajorSellersArrow = if showMajor and showMajorBuyers and showMajorArrows and MajorSellers then high else double.nan;
MajorSellersArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
MajorSellersArrow.SetDefaultColor(color.light_red);
MajorSellersArrow.SetLineWeight(MajorArrowsWeight);
###############
# Major Lines
###############
input showMajorBuyersLowLine = yes;
input showMajorBuyersMidLine = yes;
input showMajorBuyersHighLine = yes;
input showMajorSellersLowLine = yes;
input showMajorSellersMidLine = yes;
input showMajorSellersHighLine = yes;
def MajorBuyersLow = if MajorBuyers then (low) else MajorBuyersLow[1];
def MajorBuyersMid = if MajorBuyers then (high + low)/2 else MajorBuyersMid[1];
def MajorBuyersHigh = if MajorBuyers then (high) else MajorBuyersHigh[1];
def MajorSellersLow = if MajorSellers then (low) else MajorSellersLow[1];
def MajorSellersMid = if MajorSellers then (high + low)/2 else MajorSellersMid[1];
def MajorSellersHigh = if MajorSellers then (high) else MajorSellersHigh[1];
plot MajorBuyersLowLine = if showMajor and showMajorBuyers and showMajorLines and showMajorBuyersLowLine then MajorBuyersLow else double.nan;
MajorBuyersLowLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
MajorBuyersLowLine.SetDefaultColor(color.light_green);
MajorBuyersLowLine.SetLineWeight(MajorLineWeight);
plot MajorBuyersMidLine = if showMajor and showMajorBuyers and showMajorLines and showMajorBuyersMidLine and MajorBuyersMid then MajorBuyersMid else double.nan;
MajorBuyersMidLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
MajorBuyersMidLine.SetDefaultColor(color.light_green);
MajorBuyersMidLine.SetLineWeight(MajorLineWeight);
plot MajorBuyersHighLine = if showMajor and showMajorBuyers and showMajorLines and showMajorBuyersHighLine and MajorBuyersHigh then MajorBuyersHigh else double.nan;
MajorBuyersHighLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
MajorBuyersHighLine.SetDefaultColor(color.light_green);
MajorBuyersHighLine.SetLineWeight(MajorLineWeight);
plot MajorSellersLowLine = if showMajor and showMajorSellers and showMajorLines and showMajorSellersLowLine and MajorSellersLow then MajorSellersLow else double.nan;
MajorSellersLowLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
MajorSellersLowLine.SetDefaultColor(color.light_red);
MajorSellersLowLine.SetLineWeight(MajorLineWeight);
plot MajorSellersMidLine = if showMajor and showMajorSellers and showMajorLines and showMajorSellersMidLine and MajorSellersMid then MajorSellersMid else double.nan;
MajorSellersMidLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
MajorSellersMidLine.SetDefaultColor(color.light_red);
MajorSellersMidLine.SetLineWeight(MajorLineWeight);
plot MajorSellersHighLine = if showMajor and showMajorSellers and showMajorLines and showMajorSellersHighLine and MajorSellersHigh then MajorSellersHigh else double.nan;
MajorSellersHighLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
MajorSellersHighLine.SetDefaultColor(color.light_red);
MajorSellersHighLine.SetLineWeight(MajorLineWeight);
###############
# Major Clouds
###############
input showMajorBuyersLowToMidCloud = yes;
input showMajorBuyersMidToHighCloud = yes;
input showMajorSellersLowToMidCloud = yes;
input showMajorSellersMidToHighCloud = yes;
def MajorBuyersLowForCloud = if MajorBuyers then (low) else MajorBuyersLow[1];
def MajorBuyersMidForCloud = if MajorBuyers then (high + low)/2 else MajorBuyersmid[1];
def MajorBuyersHighforCloud = if MajorBuyers then (high) else MajorBuyersHigh[1];
def MajorSellersLowForCloud = if MajorSellers then (low) else MajorSellersLow[1];
def MajorSellersMidForCloud = if MajorSellers then (high + low)/2 else MajorSellersMid[1];
def MajorSellersHighForCloud = if MajorSellers then (high) else MajorSellersHigh[1];
addcloud(if showMajor and showMajorBuyers and showMajorClouds and showMajorBuyersLowToMidCloud then MajorBuyersLowForCloud else Double.nan, MajorBuyersMidForCloud,color.light_green,color.light_green);
addcloud(if showMajor and showMajorBuyers and showMajorClouds and showMajorBuyersMidToHighCloud then MajorBuyersMidForCloud else Double.nan, MajorBuyersHighforCloud,color.light_green,color.light_green);
addcloud(if showMajor and showMajorSellers and showMajorClouds and showMajorSellersLowToMidCloud then MajorSellersLowForCloud else Double.nan, MajorSellersMidForCloud,color.light_red,color.light_red);
addcloud(if showMajor and showMajorSellers and showMajorClouds and showMajorSellersMidToHighCloud then MajorSellersMidForCloud else Double.nan, MajorSellersHighForCloud,color.light_red,color.light_red);
###############
# Minor section
###############
#hint min_qual: Original setting is 5
#hint min_len: Original setting is 5
input showMinor = yes;
input min_qual = 5; #hint: Original setting is 5
input min_len = 5; #hint: Original setting is 5
def minor = lele(min_qual,min_len);
def MinorBuyers = Minor == 1;
def MinorSellers = Minor == -1;
input ShowMinorBuyers = yes;
input ShowMinorSellers = yes;
input showMinorArrows = yes;
input showMinorLines = yes;
input ShowMinorClouds = yes;
input MinorArrowsWeight = 1;
input MinorLineWeight = 1;
###############
# Minor Arrows
###############
plot MinorBuyersArrow = if showMinor and !MajorBuyers and showMinorBuyers and ShowMinorArrows and MinorBuyers then low else double.nan ;
MinorBuyersArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
MinorBuyersArrow.SetDefaultColor(color.cyan);
MinorBuyersArrow.SetLineWeight(MinorArrowsWeight);
plot MinorSellersArrow = if showMinor and !MajorSellers and showMinorSellers and ShowMinorArrows and MinorSellers then high else double.nan ;
MinorSellersArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
MinorSellersArrow.SetDefaultColor(color.yellow);
MinorSellersArrow.SetLineWeight(MinorArrowsWeight);
###############
# Minor Lines
###############
input showMinorBuyersLowLine = yes;
input showMinorBuyersMidLine = yes;
input showMinorBuyersHighLine = yes;
input showMinorSellersLowLine = yes;
input showMinorSellersMidLine = yes;
input showMinorSellersHighLine = yes;
def MinorBuyersLow = if MinorBuyers and !MajorBuyers then (low) else MinorBuyersLow[1];
def MinorBuyersMid = if MinorBuyers and !MajorBuyers then (high + low)/2 else MinorBuyersMid[1];
def MinorBuyersHigh = if MinorBuyers and !MajorBuyers then (high) else MinorBuyersHigh[1];
def MinorSellersLow = if MinorSellers and !MajorSellers then (low) else MinorSellersLow[1];
def MinorSellersMid = if MinorSellers and !MajorSellers then (high + low)/2 else MinorSellersMid[1];
def MinorSellersHigh = if MinorSellers and !MajorSellers then (high) else MinorSellersHigh[1];
plot MinorBuyersLowLine = if showMinor and !MajorBuyers and showMinorBuyers and showMinorLines and showMinorBuyersLowLine and MinorBuyersLow then MinorBuyersLow else double.nan;
MinorBuyersLowLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
MinorBuyersLowLine.SetDefaultColor(color.cyan);
MinorBuyersLowLine.SetLineWeight(MinorLineWeight);
plot MinorBuyersMidLine = if showMinor and !MajorBuyers and showMinorBuyers and showMinorLines and showMinorBuyersMidLine and MinorBuyersMid then MinorBuyersMid else double.nan;
MinorBuyersMidLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
MinorBuyersMidLine.SetDefaultColor(color.cyan);
MinorBuyersMidLine.SetLineWeight(MinorLineWeight);
plot MinorBuyersHighLine = if showMinor and !MajorBuyers and showMinorBuyers and showMinorLines and showMinorBuyersHighLine and MinorBuyersHigh then MinorBuyersHigh else double.nan;
MinorBuyersHighLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
MinorBuyersHighLine.SetDefaultColor(color.cyan);
MinorBuyersHighLine.SetLineWeight(MinorLineWeight);
plot MinorSellersLowLine = if showMinor and !MajorSellers and showMinorSellers and showMinorLines and showMinorSellersLowLine and MinorSellersLow then MinorSellersLow else double.nan;
MinorSellersLowLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
MinorSellersLowLine.SetDefaultColor(color.yellow);
MinorSellersLowLine.SetLineWeight(MinorLineWeight);
plot MinorSellersMidLine = if showMinor and !MajorSellers and showMinorSellers and showMinorLines and showMinorSellersMidLine and MinorSellersMid then MinorSellersMid else double.nan;
MinorSellersMidLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
MinorSellersMidLine.SetDefaultColor(color.yellow);
MinorSellersMidLine.SetLineWeight(MinorLineWeight);
plot MinorSellersHighLine = if showMinor and !MajorSellers and showMinorSellers and showMinorLines and showMinorSellersHighLine and MinorSellersHigh then MinorSellersHigh else double.nan;
MinorSellersHighLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
MinorSellersHighLine.SetDefaultColor(color.yellow);
MinorSellersHighLine.SetLineWeight(MinorLineWeight);
###############
# Minor Clouds
###############
input showMinorBuyersMidToHighCloud = yes;
input showMinorBuyersLowToMidCloud = yes;
input showMinorSellersMidToHighCloud = yes;
input showMinorSellersLowToMidCloud = yes;
def MinorBuyersLowForCloud = if MinorBuyers and !MajorBuyers then (low) else MinorBuyersLow[1];
def MinorBuyersMidForCloud = if MinorBuyers and !MajorBuyers then (high + low)/2 else MinorBuyersMid[1];
def MinorBuyersHighForCloud = if MinorBuyers and !MajorBuyers then (high) else MinorBuyersHigh[1];
def MinorSellersLowForCloud = if MinorSellers and !MajorSellers then (low) else MinorSellersLow[1];
def MinorSellersMidForCloud = if MinorSellers and !MajorSellers then (high + low)/2 else MinorSellersMid[1];
def MinorSellersHighForCloud = if MinorSellers and !MajorSellers then (high) else MinorSellersHigh[1];
addcloud(if ShowMinor and ShowMinorBuyers and !MajorBuyers and showMinorClouds and showMinorBuyersLowToMidCloud then MinorBuyersLowForCloud else Double.nan, MinorBuyersMidForCloud,color.cyan,color.cyan);
addcloud(if ShowMinor and ShowMinorBuyers and !MajorBuyers and showMinorClouds and showMinorBuyersMidToHighCloud then MinorBuyersMidForCloud else Double.nan, MinorBuyersHighForCloud,color.cyan,color.cyan);
addcloud(if ShowMinor and ShowMinorSellers and !MajorSellers and showMinorClouds and showMinorSellersLowToMidCloud then MinorSellersLowForCloud else Double.nan, MinorSellersMidForCloud,color.yellow,color.yellow);
addcloud(if ShowMinor and ShowMinorSellers and !MajorSellers and showMinorClouds and showMinorSellersMidToHighCloud then MinorSellersMidForCloud else Double.nan, MinorSellersHighForCloud,color.yellow,color.yellow);
###############
# ALERTS
###############
input UseAlerts = yes;
input AlertMajorSellers = yes;
input AlertMajorBuyers = yes;
input AlertMinorSellers = yes;
input AlertMinorBuyers = yes;
Alert(showMajor and UseAlerts and AlertMajorBuyers and MajorBuyers, "Leledc Major Buyers", Alert.Bar, Sound.Chimes);
Alert(showMajor and UseAlerts and AlertMajorSellers and MajorSellers, "Leledc Major Sellers", Alert.Bar, Sound.Chimes);
Alert(showMinor and UseAlerts and AlertMinorBuyers and MinorSellers and !MajorBuyers, "Leledc Minor Buyers", Alert.Bar, Sound.Chimes);
Alert(showMinor and UseAlerts and AlertMinorSellers and MinorSellers and !MajorBuyers, "Leledc Minor Sellers", Alert.Bar, Sound.Chimes);
###############
# Bubbles
###############
Input showBubbles = yes;
input showMajorBubbles = yes;
input showMinorBubbles = yes;
addchartbubble(showBubbles and showMajorBubbles and MajorSellers,high ,"Major SELLERS",color.light_red,yes);
addchartbubble(showBubbles and showMajorBubbles and MajorBuyers,low ,"Major BUYERS",color.light_green,no);
addchartbubble(showBubbles and showMinorBubbles and MinorSellers and !MajorSellers,high ,"Minor SELLERS",color.cyan,yes);
addchartbubble(showBubbles and showMinorBubbles and MinorBuyers and !MajorBuyers,low ,"Minor BUYERS",color.yellow,no);