Dear All, Happy Dushera to you all. I need a little for 'AlertIF' function help as I am very weak in Amibroker coding. Consider the following example formula: Code: Buy = Cross( MACD(), Signal() ); Sell = Cross( Signal(), MACD() ); Short = Sell; Cover = Buy; barcomplete = BarIndex() < LastValue(BarIndex()); AlertIf( barcomplete AND Short, "EXEC Calc.exe", "Launching external application", 3); AlertIf( barcomplete AND Cover, "EXEC Notepad.exe", "Launching external application", 3); Here an external application, for example, Calc.exe or Notepad.exe will execute when the signal bar will complete, i.e., at the beginning of the next bar. Now what I want is to insert some delay before this EXE triggeres, i.e. Signal bar completes, wait 5 seconds, and then execute the EXE files; something like: Code: Buy = Cross( MACD(), Signal() ); Sell = Cross( Signal(), MACD() ); Short = Sell; Cover = Buy; barcomplete = BarIndex() < LastValue(BarIndex()); [COLOR="Blue"]WAIT 5000 MILISECOND[/COLOR] AlertIf( barcomplete AND Short, "EXEC Calc.exe", "Launching external application", 3); AlertIf( barcomplete AND Cover, "EXEC Notepad.exe", "Launching external application", 3); How to achieve this? Please help. May God Bless all of us, Warm Regards, GG
Your "barcomplete = BarIndex() < LastValue(BarIndex());" will be always true for all bars less than the last bar. Wouldn't that cause the application to run at each bar? Is this maybe what you want? barcomplete = BarIndex() == LastValue(BarIndex());
AB's Status() function has these options for bar completion From the AB manual w w w.ami.....com/guide/afl/status.html "lastbartimeleft" - returns number of seconds to the completion of current last bar. Works for time-based bars only. Note that for proper operation this requires database timeshift to be set properly (so dates displayed on chart match your local computer time zone). (v5.60) "lastbartimeleftrt" - it works like "lastbartimeleft" but uses the most recent RT stream update time instead of Now(). Also added Status("lastrtupdate") - time of last RT stream update depends on RT plugin to deliver correct DateUpdate / TimeUpdate data. If plugin or date source sends incorrect datetimestamps or does not send DateUpdate/TimeUpdate correctly this function will not operate properly. Note that most data sources send weird (not current) datetime stamps on weekends. Also IQFeed plugin sends DateUpdate/TimeUpdate only inside regular trading hours. (v5.60) try this Code: if ( Interval() - Status( "lastbartimeleft" ) == 5 ) // 5 seconds after bar completion { AlertIf( Short, "EXEC Calc.exe", "Launching external application", 3); AlertIf( Cover, "EXEC Notepad.exe", "Launching external application", 3); }