Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1104

 
Serfil2017:
Hello, I'd be grateful if you could give me a hint:
The iMA function returns 4 decimal places, although the quotes are 5 digits. Are there any ways to get 5 digits from technical indicators?
It returns more than that. See what you are outputting these values with.
 

Hello!

Can you please tell me,

How do I make the OnTick() function execute a print only once(when a series of conditions occurs) and not execute it on subsequent ticks?

 
odyn:

Hello!

Can you please tell me,

How to make the OnTick() function execute a print only once, and not execute it on next ticks?

use static modifier for the flag to be reset when you have printed it once, or define this flag globally and reset it when you have printed the print once

void OnePrint(string txt)
{
   static bool onerun = false;
   if(onerun) return;
   Print(txt);
   onerun = true;
}
 
Igor Makanu:

Use a static modifier for a flag that resets when you print once, or globally describe this flag and reset it when you print once

Thank you very much for your reply.

Sorry, what if we complicate things and allow only one Print for the current timeframe bar? And after creating a new bar you can print again?

 
odyn:

Thank you very much for the reply.

Sorry, what if we complicate things and allow only one Print for the current bar of the current timeframe? And after creating a new bar, you would be able to print again?

Search the forum"new bar" or "new bar" to find how to control the new bar and if there is a new bar, you will print your print - these examples of new bar at every step here

 
Igor Makanu:

search the forum for"new bar" or "new bar" to find how to control a new bar and if there is a new bar you will display your print - these examples of a new bar are at every turn here

Thank you!

 

Greetings.

Doing an indicator, at some point it causes a hang. I don't have time to print the last one to understand where it hangs.

Can you tell me if there's any way to prescribe a pause, or prioritise printing to a journal, or some other solution.

 
Andrey Sokolov:

Greetings.

Doing an indicator, at some point it causes a hang. I don't have time to print the last one to understand where it hangs.

Can you please tell me if there is any way to prescribe a pause, or make printing to the journal a priority, or another solution.

there is no way, just learn to use debugger - it used to be worse, there was no debugger, now there is everything

set a breakpoint and then track your cycles, usually if the indicator hangs, it means you got caught in an infinite loop somewhere

 
Igor Makanu:

there is no way, just learn to use a debugger - it used to be worse, there was just no debugger, now there is everything

If usually, if the indicator hangs, it means that you have hit an infinite loop somewhere.

Isn't there a DebugBreak() in mql4?

 
Alexey Viktorov:

Doesn't DebugBreak() exist in mql4?

ME is the same now.

what difference does it make in ME to put a breakpoint or use DebugBreak()? - I think the result is the same.

Reason: