0
0

Hello Peter,

I have some difficulties with setting up the alert of Donchian Long Entry. I use the strategy from www.thetatrend.com/donchian-channel-breakout-strategy-thinkscript/ and I need to setup the alert to pop up every time when Long Entry appears on the chart, but in TOS there is only: 1)Once, and then become disabled; 2)Repeatedly for each Tick; 3)Repeatedly for each Bar.

Donchian Channel Thinkscript Strategy Long Entry:

#Donchian Channel Long Entry Thinkscript Strategy #Written by ThetaTrend.com – Actionable Trend Following Trading with Options #Feel free to share the code, but please include a link back to ThetaTrend.com input length = 50; def upperBand = Highest(high[1], length); def lowerBand = Lowest(low[1], length); AddOrder(OrderType.BUY_AUTO, high > Highest(high[1], length), Highest(high[1], length));

Donchian Channel Long Exit Thinkscript Strategy:

<code>#Donchian Channel Long Exit Thinkscript Strategy

#Written by ThetaTrend.com – Actionable Trend Following Trading with Options

#Feel free to share the code, but please include a link back to ThetaTrend.com

#define inputs

input length = 25; #Number of days for Trailing Donchian Breakdown

input ATRlength = 20; #Number of days for ATR Calculation

input ATRMeasure = 3; #ATR stop value, 3 is for 3 times the daily ATR

def entryP = EntryPrice();

def stopValue = ATRMeasure * (AverageTrueRange(ATRlength));

def stopOut = entryP – stopValue;

#Determine if the stop was hit

def peaceout = if ((low &lt;= stopOut) or (low &lt; Lowest(low[1], length))) then 1 else 0;

#Determine the exit price

def chickendinner = if (low &lt;= stopOut) then (stopOut) else (Lowest(low[1], length));

AddOrder(OrderType.SELL_TO_CLOSE, peaceout, chickendinner, tickcolor = GetColor(7), arrowcolor = GetColor(7));</code>

Marked as spam
Posted by (Questions: 4, Answers: 6)
Asked on February 15, 2017 12:18 pm
918 views
 ▲ 0 ▼ Hello Pete, I would like to ask you if it’s possible to use this study with the pop-up alerts window to Watchlist, as in you example with TTM_squeeze? there it is color coded, but I am interested if you can add Donchian Long Entry study to those custom watchlist. Also I would like to know if it’s possible to use study MACDHistogramCrossover on the watchlist with the pop-up alert window? Thanks in advance for everything you do for us. (Victor Ioxa at February 22, 2017 11:59 am)
 ▲ 0 ▼ Yes, we should be able to do these. But please post each of those ideas as separate questions in the Watch List topic: https://www.hahn-tech.com/ans/cat/watchlists/ (Pete Hahn at February 22, 2017 2:38 pm)
1

Ok, after hashing out the details we have the information needed to assist with a solution. Victor would like to be alerted to a long entry in the same way the strategy creates a buy order on the chart. The strategy uses the following condition:

`high > Highest(high[1], length)`

This is one and the same as the Donchian upper band.

In english, this condition says: True if the current bar’s high is greater than the highest high from one bar ago within the previous length of bars. So if length is set to 10, the condition excludes the current bar and counts back 10 bars to see if there was a high that is higher than the current bar’s high. I tried to state that twice, in slightly different ways to help make sure you can picture that.

Before I post the solution I have a very important item to mention. A strategy is going to create an order only if there is no current position being tracked. And the strategy will skip any signals that follow, until an exit signal occurs and clears out the current position. So as I provide this alert, keep that in mind. The alert is going to trigger every time there is a “potential” for an entry. The strategy is going to skip many of them.

`Alert(high > Highest(high[1], length),  "Donchian Long Signal",  Alert.BAR, Sound.Chimes);`

Don’t forget to up-vote any answer that provides the best solution to your question.

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on February 16, 2017 11:31 am
 ▲ 0 ▼ Thanks for the Alert code, but do you have any ideas why it didn’t pop up any messages? Long Entry is ploted on my charts but no alerts? (Victor Ioxa at February 17, 2017 8:13 am)
1

Ok, so if you have a study added to a chart and you know that study contains alerts but they are not showing up in the message center, check your settings. We have covered this in several videos in which we provide a free custom study with alerts. For convenience, I will post a screenshot here showing the settings window. You access this via the Setup button in the upper right corner of the main Thinkorswim window, select “Application Settings…” from the menu.

Having asked this question, I realize you are missing out on a lot of great material. Watch the videos.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on February 17, 2017 8:52 am
0

I believe the alert type you want is:

`Alert.BAR`

This will enable the alert to be trigged once for each bar that meets the condition.

Here is a link to the Thinkorswim language reference for the Alert() function: