Trade Arrows Don't Get Saved When Saving Chart Bitmap
Author: MichiZH
Creation Date: 5/21/2013 5:09 AM
profile picture

MichiZH

#1
Hi

I want to run certain strategies and save the chart including all generated buy and sell indicators by the strategy to an Image. This code saves the chart, however without any strategy indicators. What am I doing wrong?

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

Eugene

#2
First of all, the use of bar for AtMarket, let alone bar-1 (!), is bluntly peeking into the future. You should correct the serious mistake by issuing orders for bar+1 if you want a usable strategy.

Aside from that, you're not doing anything wrong. According to the QuickRef, GetChartBitmap() renders an image of the chart, including plotted indicators and manually drawn objects, but that does not include trading signals.

Workaround: plot them manually, akin to what the FAQ suggests:

Is there a way to see the trades on secondary symbols?

Optionally, you can disable the regular arrows with EnableTradeNotes().
profile picture

MichiZH

#3
Hi Eugene

Thanks for your answer.

2 questions:

1. I've tried that with the triangles. Seems to work just perfectly. But how could I display these triangles only for the Bitmap but in the regular Chart window display the normal trade notes?
I mean I want to program a method which disables the trade notes and creates the triangles instead. And after the image is saved it should remove the triangles and display the trade notes again. Is there a short way to do this without looping again through all bars?

2. What do you mean about peeking in the future?
In the beginning I created the int barAdj = bar - 1. So this barAdj is always one day back further in the past. With this variable the program decides if it should go long or short. And if yesterday a signal is created, I enter or exit a trade today. That's at least what I meant the program does...isn't it the same as working with bar+1?
profile picture

Eugene

#4
1. Since there's no way to un-AnnotateBar, a direct way w/o using workarounds isn't coming up to my mind. The simplest would be to use two strategies, one regular and the other for saving bitmaps.

2. Now I see your point, but still you're losing alerts trading that way. Alerts are triggered on bar+1.
profile picture

MichiZH

#5
Ok changed that No. 2. Thanks a lot for your advice.

Is there a possiblity to add some methods to some external class and import it to all strategies that need these methods? Like exporting the bitmap, adding arrows etc.?

I'm new the C#, programmed in a lot of other languages though.
profile picture

Eugene

#6
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).