Moving Divergence lines onto a lower study


Category:
0
0

The following code will plot Stochastic Full Diff divergence lines on the price bars. However, I would like to be able to see the divergence lines on the Stochastic Full Diff indicator in the sub graph. Yes, I understand that some of the Stochastic Full Diff code needs to have the # removed in order for it to plot sub graph, and the FullK and FullD def statements need to be changed to plot statements. However, the real issue is someplace in the divergence portion of the code, for when the above changes are made the divergence lines will plot at where the price level would be instead of on the FullK line.

def zeroline1 =45;
def zeroline2 =55;
def over_bought = 80;
def over_sold = 20;
input KPeriod = 5;
input DPeriod = 3;
def priceH = high;
def priceL = low;
def priceC = close;
input slowing_period = 2;
def smoothingType = 1;
def KLength = 50;
def displace = 0;
def Trnd = Average(close[-displace], KLength);
def c1 = priceC – Lowest(priceL, KPeriod);
def c2 = Highest(priceH, KPeriod) – Lowest(priceL, KPeriod);
def FastK = c1 / c2 * 100;
def FullK;
def FullD;
if smoothingType == 1 then { FullK = Average(FastK, slowing_period);
FullD = Average(FullK, DPeriod);
} else { FullK = ExpAverage(FastK, slowing_period);
FullD = ExpAverage(FullK, DPeriod);
}
#plot OverBought = over_bought;
#plot OverSold = over_sold;
def “Zero_Line1” =45;
def “Zero_Line2” =55;
#plot OverBought = over_bought;
#OverBought.SetDefaultColor (Color.Black);
#OverBought.SetLineWeight(2);
#OverBOught.HideTitle();
#plot OverSold = over_sold;
#OverSold.SetDefaultColor (Color.Black);
#OverSold.SetLineWeight(2);
#OverSold.HideTitle();
#”Zero_Line1″.HideTitle();
#”Zero_Line1″.SetDefaultColor(Color.Gray);
#”Zero_Line1″.SetStyle(Curve.LONG_DASH);
#”Zero_Line2″.SetDefaultColor(Color.Gray);
#”Zero_Line2″.SetStyle(Curve.LONG_DASH);
#”Zero_Line2″.HideTitle();
#FullD.AssignValueColor(if FullD > FullD[1] then Color.Blue else (if FullD == FullD[1] then Color.blue else Color.dark_orange));
#FullD.DefineColor(“Up”, Color.Blue);
#FullD.DefineColor(“Down”, Color.Dark_Orange);
#FullD.AssignValueColor(if FullD > FullD[1] then FullD.color(“Up”) else FullD.color(“Down”));
#FullD.SetStyle(Curve.SHORT_DASH);
#FullD.SetLineWeight(1);
#FullK.DefineColor(“Up”, Color.Blue);
#FullK.DefineColor(“Down”, Color.Dark_Orange);
#FullK.AssignValueColor(if FullK > FullK[1] then FullK.color(“Up”) else FullK.color(“Down”));
#FullK.AssignValueColor(if FullK > FullK[1] then color.blue else color.dark_orange);
#FullK.SetLineWeight(3);
#AddCloud(FullK, FullD);
input TrendLine = {EMA, SMA, default LRL, WMA, Hull};
input AlertOn = yes;
def price = close + low + high /4;
def Midline = 50;
def o = open;
def h = high;
def l = low;
def c = close;
def lowestLow = if FullK > “Zero_Line1” then 5 else if FullK < “Zero_Line1” and 5 < lowestLow[1] then 5 else lowestLow[1]; def lowestFullK = if FullK > MidLine then FullK else if FullK < MidLine and FullK < lowestFullK[1] then FullK else lowestFullK[1];
def divergentLow = if FullK < “Zero_Line1” and 5 <= lowestLow[1] and FullK > lowestFullK[1] then “Zero_Line1” else Double.NaN;
def highestHigh = if FullK < “Zero_Line2” then h else if FullK > “Zero_Line2” and h > highestHigh[1] then h else highestHigh[1];
def highestFullK = if FullK < MidLine then FullK else if FullK > MidLine and FullK > highestFullK[1] then FullK else highestFullK[1];
def divergentHigh = if FullK > “Zero_Line2” and h >= highestHigh and FullK < highestFullK then “Zero_Line2” else if FullK < “Zero_Line2” and c < o then Double.NaN else divergentHigh[1]; def swingHigh = if divergentHigh and price > price[12] then 1 else 0;;
def swingLow = if DivergentLow and price < Price[12] then -1 else 0;
Plot sh = if swinghigh then high else double.nan;
sh.setlineweight(2);
sh.setdefaultcolor(color.Blue);
Plot sl = if swinglow then low else double.nan;
sl.setlineweight(2);
sl.setdefaultcolor(color.Blue);

RESOLVED
Marked as spam
Posted by (Questions: 15, Answers: 23)
Asked on October 14, 2018 2:32 am
234 views
0

I have removed the code from your post. I need to make sure the code is free of copyright and that you have permission from the author to post it in this forum. Please provide a link showing where you acquired the code so I can research this further.

( at October 14, 2018 7:56 am)
0

I actually found a CCI code on a forum at the following website (https://researchtrade.com/forum/read.php?7,2258,6273), and then personally modified it to fit Stochastics Full Diff.

( at October 14, 2018 12:21 pm)
0

You can also find a version of the CCI code that I found at https://www.quesearch.com/msgsdisp.php?parm=tosthinkscript-fwd-cci-divergence

( at October 14, 2018 12:36 pm)
0
Private answer

Thanks for providing those details. We always want to make sure we have code that free to publish and we always want to give credit where credit is due. So always provide links to source code if you are posting something you found somewhere else.

As to your solution. My first guess is going to be the last two plot lines:

Plot sh = if swinghigh then high else double.nan;
sh.setlineweight(2);
sh.setdefaultcolor(color.Blue);
Plot sl = if swinglow then low else double.nan;
sl.setlineweight(2);
sl.setdefaultcolor(color.Blue);

You that the sh plot is using the value of “high” and the sl plot is using the value of “low”. Those are the values you need to change to your Stochastic plots.

In closing, I will note that the divergence lines study I sell on this website is much more sophisticated than what you have here. I know many viewers will arrive at this post from a Google search. And I want to make sure everyone knows we have a full featured and sophisticated divergence study for sale.

Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on October 14, 2018 4:47 pm
0

I am assuming that you are saying the following for those two lines?
Plot sh = if swingHigh then FullK else double.nan;
Plot sl = if swinglow then FullK else double.nan;
However, that does not work.

Yes, I am familiar with the divergence indicators that you sell and have purchased your Stochastics and MACD divergence indicators, and the hidden versions of them as well, plus your Volume Profile indicator. I greatly appreciate the ability to be able to scan for your divergence indicator setups. Unfortunately, I have yet to get the right setting for what I am looking for on them. Specifically on the Stochastics, I would like to be able to plot a mini-divergence that occurs within the same cycle instead of across multiple cycles. Occasionally, with a look back of 3, it will pick up the mini-divergence, but most times not. Additionally, I would prefer to see the divergence on the indicator itself rather than in the chart.

Regardless, I do greatly appreciate your work! You have been a great blessing in helping me to start to understand thinkscript!!!

P.S. I love your Volume Profile indicator! It is a very handy indicator to have!

( at October 14, 2018 8:17 pm)
0

Upon further review, it does work, the divergence line was just hidden behind the FullK line. Thank you for your help.

( at October 15, 2018 2:29 am)