snappyfrog 728 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;
AddCloud(NewCMF,Zeroline,Color.Green,Color.Red);
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!
|