Help Using Commentary for Debugging  [SOLVED]

Questions about MultiCharts and user contributed studies.
dwitkin
Posts: 36
Joined: 18 Apr 2013
Has thanked: 41 times
Been thanked: 11 times

Help Using Commentary for Debugging

Postby dwitkin » 21 May 2013

Hi. I'm still new to MultiCharts and EasyLanguage. I tried searching for an answer and didn't find one. Here's the situation.

I'm trying to use Commentary for debugging bar by bar, something I don't think the print statement can easily do (tell me if I'm wrong with that, though). So, here's my code:

Code: Select all

variables: Close_GT_Yes_High( false ),
Close_GT_Open( false ),
Low_GT_Yes_Low( false ),
BuyTrigger(false),
TriggerBarHigh(0),
TriggerBuyPrice(0);

Close_GT_Yes_High = Close > high[1];
Close_GT_Open = Close > Open;
Low_GT_Yes_Low = Low > Low[1];

{Debugging Code}
If CheckCommentary Then Begin
Commentary("Section 01: After Initial varible assignment / inspection", newline);
Commentary("Current Bar Number: ", Currentbar, newline);
Commentary("Close_GT_Yes_High: ", Close_GT_Yes_High, newline);
Commentary("Close_GT_Open: ", Close_GT_Open, newline);
Commentary("Low_GT_Yes_Low: ", Low_GT_Yes_Low, newline);
Commentary("Section 01: End", newline, newline);
End;
This works great, except the commentary window displays the expected commentary statement 4 distinct times, and several statements have different values for the same bar number when that shouldn't be the case. See the attached screenshot.

Any idea why the commentary statements are shown more than once?

Thanks for your help.
Attachments
2013-05-21 1900 Screen Shot 1.png
File shows the commentary is repeated 4 times and some of the occurrences show different results.
(95.53 KiB) Downloaded 496 times

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

Re: Help Using Commentary for Debugging  [SOLVED]

Postby Henry MultiСharts » 22 May 2013

Hello dwitkin,

It looks like you have IOG enabled for your signal.
Calculation on historical data. IOG enabled. Bar Magnifier disabled.
The script is calculated four times on OHLC of the bar...Source:How Signals are Calculated
That is why you have four expert commentary outputs.

You can add a condition to perform expert commentary calculation only on bar close:

Code: Select all

if barstatus=2 then begin
Here is the adjusted code:

Code: Select all

[ProcessMouseEvents=true]
variables: Close_GT_Yes_High( false ),
Close_GT_Open( false ),
Low_GT_Yes_Low( false ),
BuyTrigger(false),
TriggerBarHigh(0),
TriggerBuyPrice(0);

Close_GT_Yes_High = Close > high[1];
Close_GT_Open = Close > Open;
Low_GT_Yes_Low = Low > Low[1];

{Debugging Code}
If CheckCommentary Then Begin
if barstatus=2 then begin
Commentary("Section 01: After Initial varible assignment / inspection", newline);
Commentary("Current Bar Number: ", Currentbar, newline);
Commentary("Close_GT_Yes_High: ", Close_GT_Yes_High, newline);
Commentary("Close_GT_Open: ", Close_GT_Open, newline);
Commentary("Low_GT_Yes_Low: ", Low_GT_Yes_Low, newline);
Commentary("Section 01: End", newline, newline);
end;
end;

dwitkin
Posts: 36
Joined: 18 Apr 2013
Has thanked: 41 times
Been thanked: 11 times

Re: Help Using Commentary for Debugging

Postby dwitkin » 22 May 2013

Outstanding. Thanks Henry.


Return to “MultiCharts”