Below is the code for the study that I have. I would like to use it as two different scans/watchlists but do not know how to adjust the code myself in order to make that conversion. I am hoping that one of the experts in here could adjust the code and send it back to me in a way that would work for the scanner in ThinkorSwim.
I know this is asking a lot from a stranger, but after countless attempts I am at a loss and don't know where else to go to figure this out.
Thank you for your time and consideration.
.....................................................
From what I can tell, there are four alerts included in this study, however I'd prefer the two different scans to each work off of one of the alert conditions shown below, (other alerts are not needed for the scan, unless you feel they are important to its proper function):
I know this is asking a lot from a stranger, but after countless attempts I am at a loss and don't know where else to go to figure this out.
Thank you for your time and consideration.
.....................................................
From what I can tell, there are four alerts included in this study, however I'd prefer the two different scans to each work off of one of the alert conditions shown below, (other alerts are not needed for the scan, unless you feel they are important to its proper function):
Code:
alert(AlertsOn && LTF from 1 bar ago >= 20 and LTF < 20 ,”Stochastic HPS Buy Setup”,alert.BAR,sound.Bell);
alert(AlertsOn && LTF from 1 bar ago <= 80 and LTF > 80 , ”Stochastic HPS Sell setup”, alert.BAR,sound.Ding);
...............................................................................................................................................................................................................................................................
plot Data = close;declare lower;
Input AlertsOn = yes;
Input ShowTodayOnly = yes;
Def Today = if !ShowTodayOnly then 1 else if getday() == getLastDay() then 1 else 0;
def over_bought = 75;
def over_sold = 25;
def priceH = high;
def priceL = low;
def priceC = (high + low) / 2;input ShortKPeriod = 14;
input ShortPercentK = 7;
input smoothing_period = 6;
input MidKPeriod = 24;
input MidPercentK = 8;
input LongKPeriod = 35;
input LongPercentK = 10;
def Sc1 = priceC - Lowest(priceL, ShortKPeriod);
def Sc2 = Highest(priceH, ShortKPeriod) - Lowest(priceL, ShortKPeriod);
def SFastK = Sc1 / Sc2 * 100;
def Mc1 = priceC - Lowest(priceL, MidKPeriod);
def Mc2 = Highest(priceH, MidKPeriod) - Lowest(priceL, MidKPeriod);
def MFastK = Mc1 / Mc2 * 100;
def Lc1 = priceC - Lowest(priceL, LongKPeriod);
def Lc2 = Highest(priceH, LongKPeriod) - Lowest(priceL, LongKPeriod);
def LFastK = Lc1 / Lc2 * 100;
plot STF;
plot STF2;
plot MTF;
plot MTF2;
plot LTF;
plot LTF2;
STF = Average(SFastK, ShortPercentK);
STF2 = Average(SFastK, ShortPercentK);
MTF = Average(MFastK, MidPercentK);
MTF2 = Average(MFastK, MidPercentK);
LTF = Average(LFastK, LongPercentK);
LTF2 = Average(LFastK, LongPercentK);
STF.SetDefaultColor(color.Light_Gray);
STF.SetLineWeight(1);
STF2.SetLineWeight(2);
MTF.SetDefaultColor(color.Light_Gray);
MTF.SetLineWeight(1);
MTF2.SetLineWeight(2);
LTF.SetDefaultColor(color.Light_Gray);
LTF.SetLineWeight(1);
LTF2.SetLineWeight(2);
STF.AssignValueColor(if STF < 25 then color.green else if STF > 80 then color.red else color.Light_Gray);
STF2.AssignValueColor(if STF2 < 50 and STF2 > 40 then color.yellow else if STF2 <= 40 and STF2 > 25 then color.Light_GREEN else if STF2 < 25 then color.green else if STF2 > 70 and STF2 < 75 then color.pink else if STF2 > 75 then color.red else if STF2 > 50 and STF2 < 60 then color.yellow else if STF2 >= 60 and STF2 < 75 then color.pink else color.Light_Gray );
MTF.AssignValueColor(if MTF < 20 then color.green else if MTF > 80 then color.red else color.Light_Gray);
MTF2.AssignValueColor(if MTF2 < 50 and MTF2 > 40 then color.yellow else if MTF2 <= 40 and MTF2 > 20 then color.Light_GREEN else if MTF2 < 20 then color.green else if MTF2 > 70 and MTF2 < 80 then color.pink else if MTF2 > 80 then color.red else if MTF2 > 50 and MTF2 < 60 then color.yellow else if MTF2 >= 60 and MTF2 < 80 then color.pink else color.Light_Gray );
LTF.AssignValueColor(if LTF < 20 then color.green else if LTF > 80 then color.red else color.Light_Gray);
LTF2.AssignValueColor(if LTF2 < 50 and LTF2 > 40 then color.yellow else if LTF2 <= 40 and LTF2 > 20 then color.Light_GREEN else if LTF2 < 20 then color.green else if LTF2 > 70 and LTF2 < 80 then color.pink else if LTF2 > 80 then color.red else if LTF2 > 50 and LTF2 < 60 then color.yellow else if LTF2 >= 60 and LTF2 < 80 then color.pink else color.Light_Gray );
# -- ALERTS --
alert(AlertsOn && LTF <= 25 and MTF <= 25 and STF from 1 bar ago <= 25 and STF > 25,”Stochastic Breaking Above 25”,alert.BAR,sound.Bell);
alert(AlertsOn && LTF >= 75 and MTF >= 75 and STF from 1 bar ago >= 75 and STF < 75 , ”Stochastic Breaking Below 75”, alert.BAR,sound.Ding);
alert(AlertsOn && LTF from 1 bar ago >= 20 and LTF < 20 ,”Stochastic HPS Buy Setup”,alert.BAR,sound.Bell);
alert(AlertsOn && LTF from 1 bar ago <= 80 and LTF > 80 , ”Stochastic HPS Sell setup”, alert.BAR,sound.Ding);
#---------------
plot OverBought = over_bought;
OverBought.SetDefaultColor(color.Green);
plot OverSold = over_sold;
OverSold.SetDefaultColor(color.Red);
plot MidLine = 50;
MidLine.SetDefaultColor(color.white);
Last edited by a moderator: