More efficient usage of PRINT beyond using Barstatus = 2  [SOLVED]

Questions about MultiCharts and user contributed studies.
Luto
Posts: 9
Joined: 18 May 2022
Has thanked: 3 times

More efficient usage of PRINT beyond using Barstatus = 2

Postby Luto » 31 Oct 2023

Hi All,

I use print statements to monitor the scripts. But want to make it more efficient wrt not printing for the entire chart when doing a recompile and applying the strategy.

Background:

1) If you use

Code: Select all

Print ("High: ", High);
Then it executes every HLOC. (Very bad)
2) If you use

Code: Select all

if Barstatus = 2 then Print ("High: ", High);
it executes on the last tick of the bar, i.e. the Close of bar)


So far so good. Now I want to

a) Add a study-recompile with statements like 2 above, but on the initial calculation only print for the last 10 bars, and NOT then entire period for the instrument on the chart, which can be hundreds or thousands of bars
BUT
b) If I playback the chart one bar at a time, then have the print statements execute for the newest bar.

Any suggestions? I hope this makes sense.

User avatar
rrams
Posts: 128
Joined: 10 Feb 2011
Location: USA
Has thanked: 7 times
Been thanked: 70 times
Contact:

Re: More efficient usage of PRINT beyond using Barstatus = 2

Postby rrams » 04 Nov 2023

Luto,
Try this and see if it is what you want:

Code: Select all

if Barstatus=2 and Symbol_Length-Symbol_CurrentBar<=9 then print("High: ", H);

Luto
Posts: 9
Joined: 18 May 2022
Has thanked: 3 times

Re: More efficient usage of PRINT beyond using Barstatus = 2  [SOLVED]

Postby Luto » 06 Nov 2023

Thanks RRam! Worked well. It was one of those things I was trying solve but forgot about the Symbol.XX library. MaxBars call was NOT what I wanted. Thank again for your help.


Return to “MultiCharts”