StockFetcher Forums · General Discussion · ToS Code Conversion << >>Post Follow-up
snappyfrog
423 posts
msg #157891
Ignore snappyfrog
10/17/2021 12:03:47 PM

Wondering if any of you can convert these 2 oscillators into SF code.

First Oscillator:

declare lower;
input periods = 21;
Input LengthA = 5;
input over_Bought = .20;
input over_Sold = -.20;

def C = close;

def H = high;

def L = low;

def V = volume;

def TRH = Max(H,C[1]);

def TRL = Min(L, C[1]);

def TR = TRH - TRL;

def ADV =((C-TRL)-(TRH-C))/ (If TR == 0 then 999999 else TR) * V;

plot NewCMF = if WildersAverage(V,periods) == 0

then 0

else WildersAverage(ADV, periods) / WildersAverage(V, periods);
Plot NewCMFA = ExpAverage(NewCMF,LengthA);
NewCMFA.SetDefaultColor(Color.Yellow);
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(color.gray);

plot OverSold = over_Sold;
OverSold.SetDefaultColor(Color.Orange);
OverSold.SetPaintingStrategy(PaintingStrategy.Dashes);
plot OverBought = over_Bought;
OverBought.SetDefaultColor(Color.Orange);
OverBought.SetPaintingStrategy(PaintingStrategy.Dashes);

NewCMF.DefineColor("OverBought", GetColor(5));
NewCMF.DefineColor("Normal", GetColor(7));
NewCMF.DefineColor("OverSold", GetColor(1));
NewCMF.AssignValueColor(if NewCMF > over_Bought then NewCMF.color("OverBought") else if NewCMF < over_Sold then NewCMF.color("OverSold") else NewCMF.color("Normal"));
NewCMF.SetLineweight(3);

Second Oscillator:

declare lower;
input Channel_Length = 10;
input Average_Length = 21;
input wt_Length = 4;
def esa = MovingAverage(AverageType.EXPONENTIAL, hlc3, Channel_Length);
def d = MovingAverage(AverageType.EXPONENTIAL, AbsValue(hlc3 - esa), Channel_Length);
def ci = (hlc3 - esa) / (0.01 * d);
def tci = MovingAverage(AverageType.EXPONENTIAL, ci, Average_Length);
plot wt1 = tci;
wt1.SetDefaultColor(Color.GREEN);
plot wt2 = MovingAverage(AverageType.Simple, Wt1, wt_Length);
wt2.SetDefaultColor(Color.RED);

input overBought = 60;
input overSold = -60;
plot zero = 0;
zero.setDefaultColor(color.white);
plot ob = overBought;
plot os = oversold;
ob.setDefaultColor(color.red);
os.setDefaultColor(color.Green);
plot top = 100;
plot bottom = -100;
top.setDefaultColor(color.Gray);
bottom.setDefaultColor(color.Gray);
plot line=0;

Obviously, the colors are not important, but I included everything so as not to miss something.

Thanks for all of your help. I really like the Weekly and Daily MACD help you all gave me before!

Cheese
1,289 posts
msg #157901
Ignore Cheese
10/18/2021 3:37:47 PM

https://www.stockfetcher.com/forums/General-Discussion/ToS-Code-Conversion/157891
================================================================

snappy, I think your first oscillator is the Twiggs Money Flow.
A few people have coded it in sF.

 Cheese1,289 postsmsg #157905- Ignore Cheese 10/18/2021 9:56:05 PMhttps://www.stockfetcher.com/forums/General-Discussion/ToS-Code-Conversion/157891 ================================================================ snappy, I think your second oscillator might be the WaveTrend. The WaveTrend code by LazyBear on TradingView might be easier to follow than the one you posted above. The calculations seem to be nested several times so an advanced sF sub may be needed.
snappyfrog
423 posts
msg #157906
Ignore snappyfrog
10/18/2021 11:41:35 PM

Thank you cheese!

 StockFetcher Forums · General Discussion · ToS Code Conversion << >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.