Highlighting buys and sell created by ImportHistoricalTrades
Author: Tobey
Creation Date: 4/10/2017 2:38 PM
profile picture

Tobey

#1
HI Eugene,

Thanks for your help. I now have my spreadsheet setup to export what I'm seeing in the spreadsheet. And it matches the DateTime.Parse format.

CODE:
Please log in to see this code.



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?? Or something else.

I know this can be done with a coded strategy, but in this case we just have imported historical data.



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

Cone

#2
QUOTE:
in this case we just have imported historical data.
In reality, you have a Strategy that executed a set of trades, which happened to be predetermined. All the Position data is the same as for any other Strategy. Example: Just put this at the end of your code to draw a big yellow circle around all the entries.

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

Tobey

#3
Hi Cone,

Thanks for the help!

I added the code and a second line to mark the exits with a pink circle. As you can see in the attached file the code is marking the buy and sell points. Plus it is adding a lot of additional dots. Are these buy and sell prices for other symbols in the list?

Thanks again for your help
Tobey
profile picture

Eugene

#4
QUOTE:
Are these buy and sell prices for other symbols in the list?

Hi Tobey,

Do you run this code in multi-symbol mode?
profile picture

Cone

#5
Simple fix -

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

Tobey

#6
Hi Cone & Eugene,

The Simple fix - works great!
Tell Mr V you have one more happy camper!

Thank you
Tobey
profile picture

Tobey

#7
Hi Cone & Eugene,

The code above works great!

Then I got the smart idea that I'd like to color code the exit circles to green for wining trades and red for losing trades.

I would think this code would work. But once again, I would be wrong!! Help please!

Many thanks
Tobey

CODE:
Please log in to see this code.

profile picture

Cone

#8
Well, the ExitBar is always going to be greater than the EntryBar, so that's not the right test. Try this instead (untested):
CODE:
Please log in to see this code.
profile picture

Eugene

#9
QUOTE:
Well, the ExitBar is always going to be greater than the EntryBar

But shouldn't it return -1 for trades still open, thus being less than the EntryBar?
profile picture

Tobey

#10
Hi Cone & Eugene,

The code is now tested and it works! The file importing historical trades only has completed trades, so the question of "-1 for trades still open does come into play.

I like the way it makes trades on the chart easy to spot. So I'll try it next in an active strategy and see what happens with open positions.


I added the code to the basic 3x2 Strategy that is included in the basic strategies list. I put at the end of the strategy after the code to buy and sell.

The code runs and creates the circles. But it does return a Runtime error: Bar number outside bounds of the chart -1
So Eugene, I think you're right it needs to be adjusted to account for open positions.

Thanks for looking at it again
Tobey


CODE:
Please log in to see this code.



profile picture

Eugene

#11
QUOTE:
The code runs and creates the circles. But it does return a Runtime error: Bar number outside bounds of the chart -1
So Eugene, I think you're right it needs to be adjusted to account for open positions.


Hi Tobey,

You're right and it's pretty simple. Add this check on top of these lines:
CODE:
Please log in to see this code.
profile picture

Tobey

#12
Hey Eugene,

It works! I love it!

Many thanks guys
Tobey
profile picture

Eugene

#13
Tobey,

You're welcome!