Plot gap down levels automatically


Category:
0
0

Hi Pete, is it possible to create a study that plot the gap down levels automatically, with an input for percent gap down and an input for volume for the day of the gap down, if possible to show only the last gap down, can you help me please? Thanks!

Attachments:
Marked as spam
Posted by (Questions: 8, Answers: 23)
Asked on December 1, 2019 10:54 pm
131 views
0
It is not possible to create or modify drawing tools from code in Thinkorswim. So the lines would not be drawn as you have pictured. They would be plots. Plots which would begin at the candle that created the gap and continue on until the next gap is formed. There is no way to show only the most recent gap. And if those limitations are acceptable, you will need to explain the following: "... input for percent gap down and an input for volume for the day..." The only way I can interpret this is that you want to set the minimum gap percent and the minimum daily volume during the gap candle. Any gap that does not satisfy the minimum values of percent gap and daily volume would not change the plots to the new gap?
( at December 2, 2019 10:23 am)
0
yes I understand the limitations, and the input for percent gap and input for volume yes that exactly what I need, Thanks for your help Pete
( at December 2, 2019 11:13 am)
0
I guess I should've specified 20% minimum gap and 100000 in volume thanks.
( at December 2, 2019 2:02 pm)
0
Private answer

After getting some clarifications in the comment section of the question I can provide a solution.

input percentThreshold = -20.0;
input volumeThreshold = 100000;
def gapDownPercent = 100 * (open / close[1] - 1);
def qualifiedGap = gapDownPercent < percentThreshold and volume > volumeThreshold;
rec trackGapHigh = if qualifiedGap[-1] then close else trackGapHigh[1];
rec trackGapLow = if qualifiedGap then open else trackGapLow[1];
plot gapHigh = trackGapHigh;
gapHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
gapHigh.SetDefaultColor(Color.DARK_GREEN);
plot gapLow = trackGapLow;
gapLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
gapLow.SetDefaultColor(Color.DARK_RED);

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on December 2, 2019 5:00 pm
0
Thanks Pete Works great!
( at December 2, 2019 9:08 pm)