Alerts not firing on timed exit
Author: jduke
Creation Date: 1/22/2020 4:15 PM
profile picture

jduke

#1
I am having problems with my alerts not firing on timed exit. I have read the excellent FAQ on this topic but can't tell what I'm doing wrong. Here is my trading loop and exit:

CODE:
Please log in to see this code.


When streaming, I have confirmed that the trade opens correctly (ie it is listed as open), then at the appointed time the trade changes to closed and has the correct closing time in the Trades list. It just doesn't trigger an Alert.

I'm sure I've missed something but not sure what it is.

Thanks!
profile picture

Cone

#2
Except for a missing matching brace, there's nothing wrong with the snippet. The Alert would depend on the specified value for barsIntoDay. The Alert will occur only if the number of bars for which the position has been held exceeds or equals barsIntoDay.

For example, if you're trading 5 minute bars and barsIntoDay is set at 10, you will get 1 Alert 50 minutes after the Position is entered.

We wouldn't be able to tell you any more than that without seeing all the pertinent code.
profile picture

jduke

#3
Sure. This is the full code. Just looks for gaps and trade with a timed exit buying at the first bar and selling after a period of time.

(I'm sure my coding is terrible! :))

CODE:
Please log in to see this code.
profile picture

Eugene

#4
The code is fine but you should make sure there is enough data loaded. Otherwise the strategy could get out of sync quickly. Are you loading at least ~100 bars?
profile picture

jduke

#5
Yes, I load in the 2 days worth of 1 minute data so should be enough bars.

And it's okay that my loop is to Bars.Count and not Bars.Count-1?
profile picture

Cone

#6
QUOTE:
And it's okay that my loop is to Bars.Count and not Bars.Count-1?
Yes, it's okay. The loop's last bar value is Bars.Count - 1. In other words, it exits the loop when bar is incremented to equal Bar.Count.

What could be happening is that the Alert is firing, but not Auto-Staged/Placed in the Orders tool. Is that what you're looking for? That would happen if the account that you're trading doesn't have the offsetting position (and Portfolio Sync is not disabled in Trading Preferences).

Make sure to turn on the Alert sound (in Preferences) for the tool that you're using so that you're sure when the Alert fires, and check the Alert view at that time.
profile picture

Eugene

#7
Just in case, expanded the FAQ ("Alerts are not triggered") with Cone's idea re: Orders tool.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).