No exit alert during trading hours
Author: jheffez
Creation Date: 6/1/2017 7:59 AM
profile picture

jheffez

#1
Hey guys,

During trading hours, the multi position strategy below generates only entry alerts (triggers a buy). It never triggers an exit (sell) alerts even though it created 3 actual buys throughout the trading hours yesterday, which I can see in the Accounts > Local Trade History window. I placed a printdebug(Activeposition.Count) in the trading loop which showed 0.
The logic works fine in simulate mode – I see both entry and exit orders.

What is wrong?
Also, does WL remember entry positions it created from prior minutes/hours/days and can generate a sell alert in the following days/hours/minutes even when the trading loop is set to start at Bars.Count-1?



Settings: raw profit mode, fixed dollar amount. During trading hours the logic is generated from the actual streaming strategy window, not monitor. Using latest WL pro 6.9.17.

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

Cone

#2
The problem is here:
CODE:
Please log in to see this code.
If you don't process any bars prior to the last bar, the strategy cannot create any positions to exit! Just delete that line.

QUOTE:
Also, does WL remember entry positions it created
There is no memory. The script is run "fresh" with each new bar added to the chart.

Furthermore, doing this is not a good idea:
CODE:
Please log in to see this code.


Use a fixed starting point. For example, you have a 14 bar RSI, so the rule of thumb for an IIR-type indicator is to use 3 times the period,
CODE:
Please log in to see this code.


Or, if you have Community.Components installed, you might fix the starting point at the start of the second day of data:
CODE:
Please log in to see this code.
profile picture

jheffez

#3
Thank you for the quick response Cone.

To clarify, if my strategy created a position, may it be yesterday or a week ago, I have to account for it in my code? Meaning, during trading hours my code should only alert (trigger) exit signals and suppress the entry ones that already created a position? This makes it complicated when it comes to multi-position strategies. Is there a way to address it?
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).