I had this code from @korygill that it will give me the last 2 points on the daily the High Pivot and the Low Pivot. I modified I added a percentage of retracement from the Previous High to the New Low or at least the current Low..
What I would like to do is find stocks that has retracement certain percentage from High Point For Example that retrace 20% percentage from that High Pivot. Its working but how can I implement into a scanner? that find stocks that has retrace from Pivit High to either (last) or that current low.? Does anyone can help me
def Retrace= 100*((mostRecentLow-mostRecentHigh)/mostRecentHigh);
AddLAbel(yes,
"PullBack from mostRecentHigh:" + Round(retrace, 2)+ " %",color.GRAY);
The Entire code is :
# HighLowLookback
#
# Study to show the highest high and lowest low after a given number of bars back.
#
# Author: Kory Gill, @korygill
#
# VERSION HISTORY (sortable date and time (your local time is fine), and your initials
# 20190710-2200-KG - created
#
input length = 13;
#
# Common Variables that may also reduce calls to server
#
def vClose = close;
def vLow = low;
def vHigh = high;
def nan = double.NaN;
#
# Logic
#
def currentBarNumber = if !IsNaN(vClose) then BarNumber() else nan;
def lastBarNumber = HighestAll(currentBarNumber);
def lookbackBar = lastBarNumber - length + 1;
def doPlot = if currentBarNumber >= lookbackBar then 1 else 0;
def mostRecentHigh = CompoundValue(1, if doPlot && vHigh > mostRecentHigh[1] then vHigh else mostRecentHigh[1],double.NEGATIVE_INFINITY);
def highBarNumber = CompoundValue(1, if doPlot && vHIgh > mostRecentHigh[1] then currentBarNumber else highBarNumber[1],0);
#plot mrh = if currentBarNumber >= HighestAll(highBarNumber) then mostRecentHigh else nan;
#mrh.SetDefaultColor(Color.GREEN);
def mostRecentLow = CompoundValue(1, if doPlot && vLow < mostRecentLow[1] then vLow else mostRecentLow[1],double.POSITIVE_INFINITY);
def lowBarNumber = CompoundValue(1, if doPlot && vLow < mostRecentLow[1] then currentBarNumber else lowBarNumber[1],0);
#plot mrl = if currentBarNumber >= HighestAll(lowBarNumber) then mostRecentLow else nan;
#mrl.SetDefaultColor(Color.RED);
#
# Visualizations
#
#AddChartBubble(
# currentBarNumber == HighestAll(highBarNumber),
# vHigh,
# "HIGH",
# Color.WHITE,
# yes);
#AddChartBubble(
# currentBarNumber == HighestAll(lowBarNumber),
# vLow,
# "LOW",
# Color.WHITE,
# no);
#AddChartBubble(
# currentBarNumber == lookbackBar,
# (vHigh+vLow)/2,
# length+"\nBar",
# Color.GRAY,
# yes);
#plot bbH = if currentBarNumber == lookbackBar then vHigh + TickSize()*1 else #nan;
#bbH.SetPaintingStrategy(PaintingStrategy.SQUARES);
#bbH.SetDefaultColor(Color.MAGENTA);
#bbH.SetLineWeight(5);
#bbH.HideBubble();
#plot bbL = if currentBarNumber == lookbackBar then vLow - TickSize()*1 else #nan;
#bbL.SetPaintingStrategy(PaintingStrategy.SQUARES);
#bbL.SetDefaultColor(Color.MAGENTA);
#bbL.SetLineWeight(5);
#bbL.HideBubble();
#
# Labels
#
AddLabel(yes,
"mostRecentHigh: " + mostRecentHigh,
Color.Gray);
AddLabel(yes,
"mostRecentLow: " + mostRecentLow,
Color.Gray);
def Retrace= 100*((mostRecentLow-mostRecentHigh)/mostRecentHigh);
AddLAbel(yes,
"PullBack from mostRecentHigh:" + Round(retrace, 2)+ " %",color.GRAY);
What I would like to do is find stocks that has retracement certain percentage from High Point For Example that retrace 20% percentage from that High Pivot. Its working but how can I implement into a scanner? that find stocks that has retrace from Pivit High to either (last) or that current low.? Does anyone can help me
def Retrace= 100*((mostRecentLow-mostRecentHigh)/mostRecentHigh);
AddLAbel(yes,
"PullBack from mostRecentHigh:" + Round(retrace, 2)+ " %",color.GRAY);
The Entire code is :
# HighLowLookback
#
# Study to show the highest high and lowest low after a given number of bars back.
#
# Author: Kory Gill, @korygill
#
# VERSION HISTORY (sortable date and time (your local time is fine), and your initials
# 20190710-2200-KG - created
#
input length = 13;
#
# Common Variables that may also reduce calls to server
#
def vClose = close;
def vLow = low;
def vHigh = high;
def nan = double.NaN;
#
# Logic
#
def currentBarNumber = if !IsNaN(vClose) then BarNumber() else nan;
def lastBarNumber = HighestAll(currentBarNumber);
def lookbackBar = lastBarNumber - length + 1;
def doPlot = if currentBarNumber >= lookbackBar then 1 else 0;
def mostRecentHigh = CompoundValue(1, if doPlot && vHigh > mostRecentHigh[1] then vHigh else mostRecentHigh[1],double.NEGATIVE_INFINITY);
def highBarNumber = CompoundValue(1, if doPlot && vHIgh > mostRecentHigh[1] then currentBarNumber else highBarNumber[1],0);
#plot mrh = if currentBarNumber >= HighestAll(highBarNumber) then mostRecentHigh else nan;
#mrh.SetDefaultColor(Color.GREEN);
def mostRecentLow = CompoundValue(1, if doPlot && vLow < mostRecentLow[1] then vLow else mostRecentLow[1],double.POSITIVE_INFINITY);
def lowBarNumber = CompoundValue(1, if doPlot && vLow < mostRecentLow[1] then currentBarNumber else lowBarNumber[1],0);
#plot mrl = if currentBarNumber >= HighestAll(lowBarNumber) then mostRecentLow else nan;
#mrl.SetDefaultColor(Color.RED);
#
# Visualizations
#
#AddChartBubble(
# currentBarNumber == HighestAll(highBarNumber),
# vHigh,
# "HIGH",
# Color.WHITE,
# yes);
#AddChartBubble(
# currentBarNumber == HighestAll(lowBarNumber),
# vLow,
# "LOW",
# Color.WHITE,
# no);
#AddChartBubble(
# currentBarNumber == lookbackBar,
# (vHigh+vLow)/2,
# length+"\nBar",
# Color.GRAY,
# yes);
#plot bbH = if currentBarNumber == lookbackBar then vHigh + TickSize()*1 else #nan;
#bbH.SetPaintingStrategy(PaintingStrategy.SQUARES);
#bbH.SetDefaultColor(Color.MAGENTA);
#bbH.SetLineWeight(5);
#bbH.HideBubble();
#plot bbL = if currentBarNumber == lookbackBar then vLow - TickSize()*1 else #nan;
#bbL.SetPaintingStrategy(PaintingStrategy.SQUARES);
#bbL.SetDefaultColor(Color.MAGENTA);
#bbL.SetLineWeight(5);
#bbL.HideBubble();
#
# Labels
#
AddLabel(yes,
"mostRecentHigh: " + mostRecentHigh,
Color.Gray);
AddLabel(yes,
"mostRecentLow: " + mostRecentLow,
Color.Gray);
def Retrace= 100*((mostRecentLow-mostRecentHigh)/mostRecentHigh);
AddLAbel(yes,
"PullBack from mostRecentHigh:" + Round(retrace, 2)+ " %",color.GRAY);