StockFetcher Forums · General Discussion · ToS Code Conversion<< >>Post Follow-up
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);
plot ZeroLine = 0;

plot OverSold = over_Sold;
plot OverBought = over_Bought;

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"));

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;
plot wt2 = MovingAverage(AverageType.Simple, Wt1, wt_Length);

input overBought = 60;
input overSold = -60;
plot zero = 0;
plot ob = overBought;
plot os = oversold;
plot top = 100;
plot bottom = -100;
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!

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

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

1,289 posts
msg #157905
Ignore Cheese
10/18/2021 9:56:05 PM

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.

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 *** 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. does not recommend particular securities., 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.

Copyright 2021 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.