Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I've run into a bit of an issue coding an alert system in ThinkScript (AD Ameritrade's Think or Swim System). Because the project is confidential, I can only share limited information, but I hope it can be enough to get some help. Basically, my script recognizes entry and exit points, and plots them into the charts as UP and DOWN arrows. It works just fine. The only thing I'm trying to fix is to block it from making multiple of the same arrows in a row. I thought I could set up some sort of ticker that activated when a green arrow was produced, and got deactivated when a red arrow was produced. Any ideas as to how? I appreciate any help. {Tried to post screenshots but couldn't because my account is too new. I'll send them in a message to whoever answers}
Here is as much of the script as I can share:
def BuySignal = {CONFIDENTIAL} then 1 else -1 ;
plot UpFractal = if BuySignal == 1 and BuySignal[1] != BuySignal then close else Double.NaN;
#Sell Signals
def SellSignal = if {CONFIDENTIAL} then 1 else -1;
plot DownFractal = if SellSignal == 1 and SellSignal[1] != SellSignal then close else Double.NaN;
I would suggest you track the signal itself in the background, and only display it if it goes from off to on. Not sure how you do it Thinkscript, but you could build logic that displays the arrow only after the transition from off to on, but not after on to on.
Well guys, I found a beautiful solution to the issue using iterations. First of all, I defined a new variable, backscan_period = 200 / it's just how long the iterations will continue looking backward to find the last signal. Iterations finds the previous Up arrow, and the previous Down arrow, and then compares their periods. If the closest signal is a Sell, and it's trying to plot a Buy, it allows itself to do so, and vice versa. Here's the iterations code. Also, I cleared the Buy and Sell signals to only use boolean values of 1 and 0, instead of 1 and -1. I hope this helps anyone that comes across this problem in the future!
plot UpFractal = if BuySignal and (fold i1 = 1 to backscan_period with x while SellSignal[i1] != 1 do i1) < (fold i2 = 1 to backscan_period with y while BuySignal[i2] != 1 do i2) then close else double.NAN;
plot DownFractal = if SellSignal and (fold i3 = 1 to backscan_period with a while SellSignal[i3] != 1 do i3) > (fold i4 = 1 to backscan_period with b while BuySignal[i4] != 1 do i4) then close else double.NAN;
I came across this and I believe this is exactly what I'm looking for, except I'm only plotting one signal, so I'm only wanting to check and see if that signal has been plotted within a certain amount of time, and plot it if it has not occurred within that period.
How might I adapt the middle portion of this to do so?
For example say my code is basically the same as yours:
plot UpFractal = if BuySignal and ??????????????????????? then close else double.NAN;