Donchian Long Entry Alert


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
919 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.

( 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/

( at February 22, 2017 2:38 pm)
1
Private answer

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?

( at February 17, 2017 8:13 am)
1
Private answer

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
Private answer

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:

http://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/Alert.html

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on February 15, 2017 2:36 pm
0

Pete thank you for the response but the problem with the Alert.BAR is that once it triggered when the Long Entry appears on the chart it will continue on every new bar and this thing is disturbing when you try to trade. I need to set up it to pop up just once for example at the price of 2.15, after one hour if the price will go up this Long Entry on the chart will appear again at the price of 3.20, later if the price will go up again let’s say on the chart Long Entry will appear at 4.30 So I need just three pop-up messages to let me know that the price goes up. I need it just when it is ploted on the chart like when you set a price alert. Thanks in advance and I hope you can help to fix this.

( at February 15, 2017 3:51 pm)
0

It’s usually pretty simple to specify you alert condition so that it only triggers on the first cross and ignores bars that come after it until price falls back through the alert level. I just need to know the exact alert condition you are using. Please add a comment below with your complete Alert() statement. I will compare it to the code you posted and see if I can get you that little tweak you need. The code you posted contains only AddOrder() statements, there are no alerts included and this is why I\’m asking you to supply one.

( at February 15, 2017 4:51 pm)
0

Alert (lowerBand, ”UP”, Alert.BAR, Sound.Chimes); this is myalert

( at February 16, 2017 7:18 am)
0

Ok, I see you are using the lowerBand as your alert condition. Sorry to say that this is invalid. Alert conditions must be TRUE/FALSE results. If lowerBand is your target level for the alert, then you need something like CLOSE < LOWERBAND. Since there is nothing in the Strategy you supplied that uses the lowerBand for an order entry or exit we need to understand a whole lot more about what condition is supposed to trigger your alert. For example, in the script you provided for Long Entry the AddOrder() statement executes on the following TRUE/FALSE condition: high > Highest(high[1], length)
It’s not tied to the lowerBand variable to the slightest degree. So I fill us in on some more details about the conditions you want to use for triggering this alert and we’ll get you patched up and on your way in a jiffy.

( at February 16, 2017 8:34 am)
0

Ok, Pete, I am not really a specialist of TOS script, that’s why I am asking you to help me. If in the script Long Entry the AddOrder() statement executes on the following TRUE/FALSE condition: high > Highest(high[1], length), than use this to alert me once, everytime when it is plotted on my chart. Thank you.

( at February 16, 2017 10:55 am)