Intraday Paper trades not exiting
Author: Hopmarks
Creation Date: 7/9/2020 8:52 PM
profile picture

Hopmarks

#1
Two questions I've not found answers to yet:

How do you close a paper trade position manually?

Intra-day Paper trades (at least for 1 min) haven't been exiting when its the next day, how do I get them to either exit when the closing positions conditions trigger the next day or close those positions before the end of the day?

Thanks!
profile picture

Eugene

#2
Let's get to the bottom of the issue instead of looking for workarounds i.e. "Close Paper Trader positions" (and name topics accordingly). So, why intraday paper trades haven't been exiting the next day? We'll need to see more details (code, message, errors etc.)
profile picture

Hopmarks

#3
Sounds good.

This was done with no personal coding (100% Build & Backtest).

Minute scale, Paper Account 2, 50,000 starting, 10% equity.

cover at market
price >= highest price in look back period


maybe since WLP isn't always open and is shut down (overnight especially) perhaps there's a dis-association from live positions with their exit conditions?

I didn't see an error or attempts to exit the trades in the system.
profile picture

Eugene

#4
Is entry at market or at stop/limit?
profile picture

Hopmarks

#5
Entry is at Stop/Limit

Exit is at Market.

orders get stuck in a hold position with no exit.

Right now there are 5 tickers that wont exit since this morning.

I was able to get an error message in the strategy monitor, not sure if it's associated: Error(3): The given key was not present in the dictionary.
profile picture

Eugene

#6
It's documented in the User Guide that there's a chance of paper trading going out-of-synch when stop/limit orders are employed whereas strategies using market orders should not be affected. You can also find explanation and an example in Cone's posts #7 and 9 here:

Paper Account Trading vs Real Account Trading
profile picture

Hopmarks

#7
That explains why some of the Limit orders don't execute, but I'm talking about the market orders that aren't executing (I'm not worried about the limit orders not executing).

Limit to enter, and market to exit.

The orders aren't exiting. It happens to trades that are held to the end of day, those positions don't exit the next day as they should.
profile picture

Eugene

#8
Let's have a look at your code first. Click "Open code in new Strategy window" and copy/paste here.
profile picture

Hopmarks

#9
I won't be able to paste the code for that particular strategy, but I will try to re-create the error in another strategy and post within the week.
profile picture

Eugene

#10
Sure, that'd be fine.

P.S. Have you upgraded to 6.9.24? There's quite a bit of Paper trading and Accounts fixes in it.
profile picture

Hopmarks

#11
Yes 6.9.24.4,

I've not tested the strategies since the upgrade, I'll try that as well.
profile picture

Hopmarks

#12
Thanks for looking into this. After updating WLP and getting a VPN I was able to access WLP again and finished the testing with the same results.

Paper Trade wont close with market orders. Error seems to occur when WLP turns off, and then back on, it seems to "forget" the code for closing and holds.

Providing code for two examples:

Example 1: (Limit open (not the problem), Market close (the problem))

CODE:
Please log in to see this code.




Example 2: (Market open (not the problem) Market Close (the problem))



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

Eugene

#13
What are your data loading settings?

Just a note. If not for this condition, #1 would be problematic to execute:
CODE:
Please log in to see this code.
profile picture

Hopmarks

#14
Since this is for live paper trading, and not a backtest, I did 1 day // 1 min scale for #1, and 7/1/2012 to 10/14/2015 // 1 min scale for #2
profile picture

Eugene

#15
QUOTE:
I did 1 day // 1 min scale

I doubt this would work. Erasing the history may break the link. Try choosing at least several days of data.

QUOTE:
7/1/2012 to 10/14/2015

Dates in the past for live paper trading? It does not make any sense to me.
profile picture

Hopmarks

#16
Perhaps I misunderstood, I did some searches but am not sure what is meant by "Data Loading settings". Could I get a screenshot or example?
profile picture

Eugene

#17
This is the dropdown box where you choose "1 day" or "7/1/2012 to 10/14/2015".
profile picture

Hopmarks

#18
I attached an image.

I don't know what is meant by erasing the history and breaking link. is the Data range associated with live trades then?

Sorry I'm really new.

I now changed both to be 20 days, Positions still wont close.

Thanks
profile picture

Eugene

#19
Are you using the same time-based exit in your real strategy as in your Wizard-generated code #1? It may not be working as intended. Check out this topic for insight into the issue:

Time based exit in Rules does not work with multiple open positions

Simply put, you can fix it by replacing all references to "LastActivePosition" in your code with "p".
profile picture

Hopmarks

#20
okay thanks, I'll work on it.

Example 2 still won't exit, and doesn't have "Lastactiveposition".
profile picture

Eugene

#21
Are you sure that the exit alerts are Auto-Staged/Placed in the Orders tool?

Is Portfolio Sync enabled in Trading Preferences?
profile picture

Hopmarks

#22
Yes, and yes.

However I also had Exit Orders (Sell and Cover) selected, it says that having that selected could interfere with backtesting, would it also interfere with paper trading with market orders?
profile picture

Eugene

#23
Given that both example strategies above employ multiple positions, looks like this setting may interfere with 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).