Recursive Alerts


0
0

Hi Pete,  I truly appreciate all you do for the trading community.  I have several alerts that I use for my watchlist, but the issue with the existing code is the use of  ‘def ‘ .  The alert only happens one time per day instead of every time the condition is triggered.

I found this link  https://toslc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/def.html

Is it possible to make changes to some of your indicators that you’ve developed and not use ‘def’ in the code so that they can be recursive?

declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageTypeMACD = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;

def Diff = MACD(fastLength, slowLength, MACDLength, averageTypeMACD).Diff;

input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 10;
input priceH = high;
input priceL = low;
input priceC = close;
input averageTypeSTOCH = AverageType.SIMPLE;

def SlowK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageTypeSTOCH).FullK;

def SlowD = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageTypeSTOCH).FullD;

plot data = (SlowK[1] < SlowD[1]) and (SlowK > SlowD) and (Lowest(SlowK[1], 3) < 20) and (Diff[1] < Diff);

Is it possible to replace the ‘def’ with something that is in the link above as a guide??

Thanks in advance.

Carol

 

Marked as spam
Posted by (Questions: 4, Answers: 5)
Asked on February 16, 2019 9:56 pm
142 views
0
Hi Carol, did you determine a solution for this? Regards, Brian
( at May 7, 2019 8:07 am)
0
Private answer

Using “def” is not a causing a problem. Despite want you believe. Def is the way we declare standard variables. When declaring recursive variables, “def” will work just as well as “rec”. I use rec when declaring recursive variables only to make the code easier to read and maintain. But it does not really matter at all.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 18, 2019 1:46 pm