ImportHistoricalTrades throws DateTime.Parse error
Author: Tobey
Creation Date: 4/4/2017 6:18 PM
profile picture

Tobey

#1
Hi Cone & Eugene,

I am trying to use the code below to import my buys and sells on a chart. The code works but not always. Some trades give a DateTime.Parse error. And I can't see any difference in the data.

What I'm I missing?

Thanks for your help
Tobey

CODE:
Please log in to see this code.




DeBug error messages

DateTime.Parse error (exit): Long,AA,24-02-2017,33.63,03/01/2017,36.74
DateTime.Parse error (entry): Long,HP,02/08/2017,66.95,14-02-2017,70.72
DateTime.Parse error (exit): Long,WHR,27-01-2017,170.46,02/09/2017,173.28
DateTime.Parse error (exit): Long,NAVI,30-01-2017,14.9,02/06/2017,15.39
DateTime.Parse error (exit): Long,MU,30-12-2016,21.82,01/10/2017,22.36
DateTime.Parse error (entry): Long,NVDA,01/03/2017,104.43,01/10/2017,107.79
DateTime.Parse error (exit): Long,BBY,29-12-2016,42.83,01/05/2017,42.65
DateTime.Parse error (exit): Long,NUE,15-12-2016,61.77,01/05/2017,61.12
profile picture

Eugene

#2
Hi Tobey,

Your trade history file is misformatted i.e. there are multiple DateTime formats. Some of them match "dd-MM-yyyy" and some not ("MM/dd/yyyy"):

QUOTE:
DateTime.Parse error (exit): Long,AA,24-02-2017,33.63,03/01/2017,36.74
...
DateTime.Parse error (entry): Long,NVDA,01/03/2017,104.43,01/10/2017,107.79



There's no unity in the same trade line, let alone across the whole file. With this ambiguity, parsing will not work out. Normalize your trade file to have just a single DateTime format for all the entries and exits.
profile picture

Tobey

#3
HI Eugene,

Sorry I missed the out put inconsistency. I now have my spreadsheet setup to export what I'm seeing in the spreadsheet. And it matches the DateTime.Parse format. Thanks!!

Now the trades show up on the charts. But as you can see in the attach screenshot of NVDA. What could I add to the code to make the trades pop out and be easy to see. Change in background color? Bigger makers for the buy and sell? Darker line between the buy and sell points??

I'd appreciate any suggests that would make the the trade period and/or entry and exit points pop out.

Thanks for any suggestions you might have to make the trades on the chart quicker to read.

Thanks again
Tobey
profile picture

LenMoz

#4
QUOTE:
... that would make the the trade period and/or entry and exit points pop out.
Here's what I do (AnnotateBar).The true/false controls above/below the price. I also like it because it shows strategy-intended trades blocked by the PosSizer.
CODE:
Please log in to see this code.
profile picture

Tobey

#5
Hi LenMoz,

Thanks! This is going to work well in a regular strategy where we are defining the buy and sell points in the code.

In this case we are importing historical buy and sell points with just this one line of code.

CODE:
Please log in to see this code.


I'm hope there is a way to Annotate this historical data?

Thank for your help
Tobey
profile picture

Eugene

#6
Tobey,

ImportHistoricalTrades creates trades (Positions). I've helped you with the import issue (i.e. the DateTime.Parse error). Job done. What happens next is a different topic.

If you have further questions regarding their annotation, please either re-use a thread closely related to the WealthScript cosmetic functions or start a new one. We'll be happy to help you out.

Thanks.
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).