Cocoa, Florida, United States
Posts: 1 since Oct 2010
Thanks Given: 0
Thanks Received: 0
|
I am new to programming, and I think I understand the code below, I just can't understand why the editor won't accept it.
I copy/pasted the code for MA_Crossover_w_Alerts released by think or swim into the complex alert compiler. Everything is functioning except the alerts portion at the bottom. The following is written:
#Trigger alerts
alert(crossover[1], "Crossover", Alert.Bar, Sound.Ding);
alert(crossunder[1], "Crossunder", Alert.Bar, Sound.Ding);
Every time I paste that in, the scripter creates the error "No such constant: Sound.Ding" I know for a fact that Sound.Ding is a valid constant (it is in the thinkscript manual), I just don't know why it won't acknowedge it. Further, the compiler rejects all “Sound._” constants that are in the manual. I tried to just leave out the sound parameter altogether, since the manual indicates that it will default in that instance to Sound.NoSound, but then it gives me this error: "No default value for parameter 'parameter3' on alert". I talked to someone else that tried the same code in their own TOS program, and he didn't have any of the issues I'm having. He didn't tell me anything beyond that, though, so I'm kind of stuck.
To be clear, the whole script released from Think or Swim is as follows:
input EMAPeriod = 10;
input SMAPeriod = 20;
input price = close;
def na = double.nan;
plot fastema = ExpAverage(price, EMAPeriod);
plot slowema = Average(price, SMAPeriod);
def crossover = if fastema > slowema AND fastema[1] <= slowema[1] then 1 else 0;
def crossunder = if fastema < slowema AND fastema[1] >= slowema[1] then 1 else 0;
#Plot arrows
Plot up = if crossover then low - tickSize() else na;
Plot down = if crossunder then high + tickSize() else na;
up.SetPaintingStrategy(paintingStrategy.ARROW_UP);
down.SetPaintingStrategy(paintingStrategy.ARROW_DOWN);
#Trigger alerts
alert(crossover[1], "Crossover", Alert.Bar, Sound.Ding);
alert(crossunder[1], "Crossunder", Alert.Bar, Sound.Ding);
Thank you for any help you can provide!
|