alert based on realtime tick data?

 

Hi,


I'm trying to code an automated alert but my problem is that its triggered only after the candle closed, and is not using actual tick data from an unfinished candle to trigger the alert.


the code I tried is like:

RefreshRates();

if ( Bid >= Alertlevel)

{

Alert("Alert");

}


I tried the same with Close[0] before but both versions do only give me an alert once the candle has finished and meets the if requirements, but not while the candle is still open...

any suggestions? is this even possible?


thanks alot

 
herbun wrote >>

Hi,

I'm trying to code an automated alert but my problem is that its triggered only after the candle closed, and is not using actual tick data from an unfinished candle to trigger the alert.

the code I tried is like:

RefreshRates();

if ( Bid >= Alertlevel)

{

Alert("Alert");

}

I tried the same with Close[0] before but both versions do only give me an alert once the candle has finished and meets the if requirements, but not while the candle is still open...

any suggestions? is this even possible?

thanks alot

Check your Alertlevel data or if you are really executing those lines.

 
herbun:

Hi,


I'm trying to code an automated alert but my problem is that its triggered only after the candle closed, and is not using actual tick data from an unfinished candle to trigger the alert.


the code I tried is like:

RefreshRates();

if ( Bid >= Alertlevel)

{

Alert("Alert");

}


I tried the same with Close[0] before but both versions do only give me an alert once the candle has finished and meets the if requirements, but not while the candle is still open...

any suggestions? is this even possible?


thanks alot

Before your code, add this :

if (bartime == Time[0]) return(0);
else bartime = Time[0];

 
migmof:

Before your code, add this :

if (bartime == Time[0]) return(0);
else bartime = Time[0];



@mogmof


Thanks for your reply. could you explain that piece of code? I do not understand how it helps actualizing the Bid?


@jacques366


the alert does work as it should but it always gets only activated once the candle on the chart closed. so it seems logical to me that the code gets executed?

 
herbun:

@mogmof


Thanks for your reply. could you explain that piece of code? I do not understand how it helps actualizing the Bid?


@mogmof


I do understand now.

actually I found out that code similar to the one you gave me was already in the code and it was exactly that what prevented it from doing what I wanted...


if(bidlevel == Bid) return(0);

else bidlevel = Bid;


this line of code actualizes the alert every time the bid changes.


thanks for the creative input guys!

Reason: