Good afternoon, I'm trying to get a script that creates a green line at close when the buying volume is above average and a red line at close when the selling volume is above average. Also once the that line is broken through with above average volume from the other side, it should disappear. For example...if a green line is created because there was above average buying and then later on, an above average red goes through that green bar, then the green bar should disappear.
I went through the forum and found this code create by
@Department but I'm not sure how to edit it to have the color lines be created based on the close and how to have it disappear once its broken through.
Can you help.
input history = 10;
input multiplier = 1.5;
def highLow = high - low;
def body = BodyHeight();
def greenCandle = open < close;
def redCandle = close < open;
def volatility = ATR(history);
def significantBar = volatility * multiplier;
def imBody = (body > highLow * 0.5) and (highLow >= significantBar);
AssignPriceColor(if imBody and greenCandle then Color.DARK_GREEN else Color.CURRENT);
AssignPriceColor(if imBody and redCandle then Color.DARK_RED else Color.CURRENT);
#These would be the price levels drawn on the chart.
#They start at the previous candle's high/low and end once price returns to that price.
#Green Candles
plot supportLevel = if imBody and greenCandle then high[1] else Double.NaN;
supportLevel.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
#######################################################################################
#Code edit by Svanoy
#Continuation of Support Level Line.
def SLine = If !IsNaN(supportLevel) then supportLevel else SLine[1];
#Check for touch.
def STouched = fold s = 0 to 1 with ssum = 0 do if low<=Sline then ssum + 1 else ssum;
#Define end of Support Line.
def SLineEnd = If Sline!=high[1] and STouched then Double.NaN else If SLine==high[1] and !IsNaN(SupportLevel) then SLine else SlineEnd[1];
#Plot Support Line.
plot SLineP = SLineEnd;
SLineP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL );
SLineP.SetDefaultColor(Color.GREEN);
SLineP.SetLineWeight(1);
#----------------------------------------------------------------------------------
#Continuation of Support Level Line 1.
def SLine2 = If SLine!=SLine[1] then SLine[1] else SLine2[1];
#Check for touch.
def STouched2 = fold s2 = 0 to 1 with ssum2 = 0 do if low<=Sline2 then ssum2 + 1 else ssum2;
#Define end of Support Line.
def SLineEnd2 = If STouched2 then Double.NaN else If SLine!=SLine[1] and !IsNaN(SLineP[1]) then SLineP[1] else SlineEnd2[1];
#Plot Support Line.
plot SLineP2 = SLineEnd2;
SLineP2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL );
SLineP2.SetDefaultColor(Color.GREEN);
SLineP2.SetLineWeight(1);
#----------------------------------------------------------------------------------
#Continuation of Support Level Line 2.
#Copy and Paste this section to add more Support lines.
def SLine3 = If SLine2!=SLine2[1] then SLine2[1] else SLine3[1];
#Check for touch.
def STouched3 = fold s3 = 0 to 1 with ssum3 = 0 do if low<=Sline3 then ssum3 + 1 else ssum3;
#Define end of Support Line.
def SLineEnd3 = If STouched3 then Double.NaN else If SLine2!=SLine2[1] and !IsNaN(SLineP2[1]) then SLineP2[1] else SlineEnd3[1];
#Plot Support Line.
plot SLineP3 = SLineEnd3;
SLineP3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL );
SLineP3.SetDefaultColor(Color.GREEN);
SLineP3.SetLineWeight(1);
#######################################################################################
#Red Candles
plot resistenceLevel = if imBody and redCandle then low[1] else Double.NaN;
resistenceLevel.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
#######################################################################################
#Code edit by Svanoy
#Continuation of Resistence Level Line.
def RLine = If !IsNaN(resistenceLevel) then resistenceLevel else RLine[1];
#Check for touch.
def RTouched = fold r = 0 to 1 with rsum = 0 do if high>=Rline then rsum + 1 else rsum;
#Define end of Resistence Line.
def RLineEnd = If Rline!=low[1] and RTouched then Double.NaN else If RLine==low[1] and !IsNaN(ResistenceLevel) then RLine else RlineEnd[1];
#Plot Resistence Line.
plot RLineP = RLineEnd;
RLineP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL );
RLineP.SetDefaultColor(Color.RED);
RLineP.SetLineWeight(1);
#----------------------------------------------------------------------------------
#Continuation of Resistence Level Line 1.
def RLine2 = If RLine!=RLine[1] then RLine[1] else RLine2[1];
#Check for touch.
def RTouched2 = fold r2 = 0 to 1 with rsum2 = 0 do if high>=Rline2 then rsum2 + 1 else rsum2;
#Define end of Resistence Line.
def RLineEnd2 = If RTouched2 then Double.NaN else If RLine!=RLine[1] and !IsNaN(RLineP[1]) then RLineP[1] else RlineEnd2[1];
#Plot Resistence Line.
plot RLineP2 = RLineEnd2;
RLineP2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL );
RLineP2.SetDefaultColor(Color.RED);
RLineP2.SetLineWeight(1);
#----------------------------------------------------------------------------------
#Continuation of Resistence Level Line 2.
#Copy and Paste this section to add more Resistence lines.
def RLine3 = If RLine2!=RLine2[1] then RLine2[1] else RLine3[1];
#Check for touch.
def RTouched3 = fold r3 = 0 to 1 with rsum3 = 0 do if high>=Rline3 then rsum3 + 1 else rsum3;
#Define end of Resistence Line.
def RLineEnd3 = If RTouched3 then Double.NaN else If RLine2!=RLine2[1] and !IsNaN(RLineP2[1]) then RLineP2[1] else RlineEnd3[1];
#Plot Resistence Line.
plot RLineP3 = RLineEnd3;
RLineP3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL );
RLineP3.SetDefaultColor(Color.RED);
RLineP3.SetLineWeight(1);
#######################################################################################