Verify if is a Double

 

Hi.

I write a script that connect my app and send a message informating that has a new candle.

But I dont want to put this script in each chart time. I want to use this in only one and verify if for a new candle .

I start with:

if(DoubleToStr(Minute(),0) != lastTime_Minute){

So if diferent, we have a new candle in chart 1 minute. Now I need verify in chart 5 minute.

if the below code would work would be perfect

if(Minute() / 5.0 != double){

So number like 5/5=1 ; 10/5=2 ; 15/5=3...This results are Integer so we have a new candle in this times...

And for other periods like 15/15=1 ; 30/15=2...

But this line have an error because I dont use double as comparision.

Any idea?

Thanks

 
bisewski:

Hi.

I write a script that connect my app and send a message informating that has a new candle.

But I dont want to put this script in each chart time. I want to use this in only one and verify if for a new candle .

I start with:

So if diferent, we have a new candle in chart 1 minute. Now I need verify in chart 5 minute.

if the below code would work would be perfect

So number like 5/5=1 ; 10/5=2 ; 15/5=3...This results are Integer so we have a new candle in this times...

And for other periods like 15/15=1 ; 30/15=2...

But this line have an error because I dont use double as comparision.

Any idea?

You have to check for a new bar not a certain time passing . . . search for "once per bar" and adapt the code you find.
 

In this way, I will need to put the script in all charts times. If I work with 5 chart, I will need to put this script in all chart.

and this is the problem because I use a connection PIPE to send this information. So I haven't more then one.

So, I need in one script, detect in other chart a new bar. In .net is very easy:

Integer.TryParse( minute/ 5, val) //if minute = 8 the result is False. If = 5,10,15,20... the result is True. So we know when a New chart is created with the Server Time. If I use one timer in my .net, is possible too, however only in system local time.

 
bisewski:

. . .

So if diferent, we have a new candle in chart 1 minute. Now I need verify in chart 5 minute.

if the below code would work would be perfect

if(Minute() / 5.0 != double){

So number like 5/5=1 ; 10/5=2 ; 15/5=3...This results are Integer so we have a new candle in this times...

And for other periods like 15/15=1 ; 30/15=2...

But this line have an error because I dont use double as comparision.

Any idea?

First, I would suggest saving the current bar's time and then test whether that time changes. If it does, newbar is detected. See here.

Second, your above code won't work as you intended. Try using the remainder operator (the %) to calculate the remainder of division.

if (Minute() % 5 == 0)

Presumably (not necessarily saying correctly), a newbar is detected when Minute() is evenly divided by 5 (with no remainder).

 
bisewski:

In this way, I will need to put the script in all charts times. If I work with 5 chart, I will need to put this script in all chart.

No you don't . . . use iTime() and you can tell when a new bar has arrived on any timeframe for any symbol . . . did you search for "once per bar" ?
Reason: