How to code? - page 326

 

yes, I corrected the name of the indicator just before posting, and I forgot to update the code here on the forum.

The problem was the buffer missing, thank you! I have inserted 0 for both buffers and it works.

Now how do I add the arrows?

 

Something like this (change the arrow code to the desired one in the indicator) :

thefxpros:
yes, I corrected the name of the indicator just before posting, and I forgot to update the code here on the forum.

The problem was the buffer missing, thank you! I have inserted 0 for both buffers and it works.

Now how do I add the arrows?
Files:
 

I have a quick question. To my understanding indicators update with each incoming tick. How does not change that so that the indicator updates only when a new bar forms? My goal here is to make the calculation easier on the CPU, Memory, and MT4. Any code snippet would be greatly appreciated.

Cheers,

Pip

 

Add something like this ate the very beginning of the start()

static datetime lastTime = 0;

if (lastTime == Time[0]) return(0);

lastTime = Time[0];

It will ensure that the rest of the code will execute only on a new bar formed

Pip:
I have a quick question. To my understanding indicators update with each incoming tick. How does not change that so that the indicator updates only when a new bar forms? My goal here is to make the calculation easier on the CPU, Memory, and MT4. Any code snippet would be greatly appreciated.

Cheers,

Pip
 

Thank you very much MLaden, that did the trick.

 

Hi all,

Do you know how to code a grid (not levels limited in numbers) in a separate window indicator, let's say an MA in a separate window , each 10 pips or so?

Is there any indicator already coded that way that I could copy?

Thanks everyone.

Have a good trading week.

Tomcat98

 

Hi Mladen, pls how can I write a trade alert that in MT4 that can tell anyone since the alert has happen ago from the live server e.g

EURUSD sell 5minutes ago or

GPBUSD buy 2 minutes ago

below is the example of my code but i dont know how to add the exact time in "ago" so that my user will know the time since the alert has happened.

Alert("Buy","\n","Current time is ",TimeToStr(CurTime()),"\n",Symbol());

 

Mastercash

You can not do that for multiple reasons - one would be that you would need to know the exact time when some condition happened and you can not reconstruct that on time series charts

Mastercash:
Hi Mladen, pls how can I write a trade alert that in MT4 that can tell anyone since the alert has happen ago from the live server e.g

EURUSD sell 5minutes ago or

GPBUSD buy 2 minutes ago

below is the example of my code but i dont know how to add the exact time in "ago" so that my user will know the time since the alert has happened.

Alert("Buy","\n","Current time is ",TimeToStr(CurTime()),"\n",Symbol());
 

Tomcat98,

Did you see this one (just one example) : https://www.mql5.com/en/forum/175518?

If you want it in a separate window, all you need to change is this line :

ObjectCreate( gridname, OBJ_HLINE, 0, 0, p );[/CODE]

into something like this :

[CODE]ObjectCreate( gridname, OBJ_HLINE, DesiredSubWindowNumber, 0, p );
Tomcat98:
Hi all,

Do you know how to code a grid (not levels limited in numbers) in a separate window indicator, let's say an MA in a separate window , each 10 pips or so?

Is there any indicator already coded that way that I could copy?

Thanks everyone.

Have a good trading week.

Tomcat98
 
Did you see this one (just one example) : https://www.mql5.com/en/forum/175518?

If you want it in a separate window, all you need to change is this line :

ObjectCreate( gridname, OBJ_HLINE, 0, 0, p );[/CODE]

into something like this :

[CODE]ObjectCreate( gridname, OBJ_HLINE, DesiredSubWindowNumber, 0, p );

Whohaaa...

It perfectly works! This is the kind of code I was surching...

mladen, you are the reference.

I sincerely thank you for you time.

Have a good trading week.

Sincerely

Tomcat98

Reason: