DrwText problem when using if (Bars.LastBarOnChart)

Questions about MultiCharts .NET and user contributed studies.
3strategy
Posts: 22
Joined: 31 Dec 2014
Has thanked: 2 times
Been thanked: 1 time

DrwText problem when using if (Bars.LastBarOnChart)

Postby 3strategy » 28 Jan 2015

I using DrwText in a signal.
When running in a LastBarOnChart if clause, this text disappears after less than a second, or does not display at all.
This happens both with and without [IOGMode(IOGMode.Enabled)]

I attach a simple signal that reproduces the problem. The signal creates long and short entry limit orders, which are charted on screen using my OrderEx class.
When the order's price is set it should print additional information to the chart (see png). However this does not happen when using LastBarOnChart check. Only the order line is charted, and the output to the debug.

if you comment the LastBarOnChart the DrwText works correctly.

Signal, OrderEx Class, and screen capture are attached.
Attachments
PTTCapture.zip
(14.57 KiB) Downloaded 263 times

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: DrwText problem when using if (Bars.LastBarOnChart)

Postby JoshM » 28 Jan 2015

I using DrwText in a signal.
When running in a LastBarOnChart if clause, this text disappears after less than a second, or does not display at all.
This happens both with and without [IOGMode(IOGMode.Enabled)]
Have you added the `RecoverDrawings` attribute to the top of your class, like this?

Code: Select all

[RecoverDrawings(false)]
public class Example : IndicatorObject
{
// Code here
}
See RecoverDrawings for more on what this attribute does.

3strategy
Posts: 22
Joined: 31 Dec 2014
Has thanked: 2 times
Been thanked: 1 time

Re: DrwText problem when using if (Bars.LastBarOnChart)

Postby 3strategy » 28 Jan 2015

I just tried it and it didn't help.
So I added a bool to my OrderEx class to remember re-printing on each intra-CalcBar, and close the flag at the close of the bar.

I attach the working and improved OrderEx class.
Attachments
TestLimitOrder.pln
(6.13 KiB) Downloaded 354 times

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: DrwText problem when using if (Bars.LastBarOnChart)

Postby JoshM » 28 Jan 2015

Sorry, I couldn't make sense of why the drawings aren't persistent, nor could I easily replicate order entries (since it depends on other variables) or find the `Bars.LastBarOnChart` check that would cause the error.

I did notice that, on historical data, plotting text and lines is done correctly (for ES). but for forex instruments there were lines with negative values.

Hopefully someone with a better insight (or more time) can locate the issue.

3strategy
Posts: 22
Joined: 31 Dec 2014
Has thanked: 2 times
Been thanked: 1 time

Re: DrwText problem when using if (Bars.LastBarOnChart)

Postby 3strategy » 28 Jan 2015

BTestOrderProtection is the signal that reproduces this error. It's part of the pln in the original zip.

The other file inside the the solution contains the OrderEx class that handles the order line drawing and DrwText. Each limit order that is created in the signal is enclosed in an OrderEx class instance.

The second study (TestLimitOrders) with the solution contains an updated OrderEx class with the fix. Thanks for your help.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: DrwText problem when using if (Bars.LastBarOnChart)

Postby Henry MultiСharts » 30 Jan 2015

3strategy,

What is the exact version and build of MultiCharts .NET where you have this issue?


Return to “MultiCharts .NET”