♥ 0 |
I want something to alarm me at the end of each bar, specifically 15 min, but I am using 1 min so I can test it. It seems if I mention a function like Seconds from Time or GetTime, it does not work the alarm or sound alert at all. declare once_per_works with a true statement but the ticks come at any time in the time interval. These are methods I have tried. Could you give a hint. I remember in being easy in MTL4, and NinjaScript. #TimeAlert declare once_per_bar; #Method 1 input MinNo=15; def BarTimeCount=GetTime(); # (in milliseconds) def AlarmBarCount= GetTime() + MinNo*60*1000; #milliseconds
def Alarm= BarTimeCount[0] >= AlarmBarCount[1]; AddLabel(yes,”BarTimeCount is “+BarTimeCount is “+AlarmBarCount+ “AlarmBarCount,Color.DARK_GREEN);
#Method 2 def DaySecPST= SecondsfromTime(2100); def TFSec=MinNo* 60 *1000; def Alarm= if DaySecPST/TFSec- Floor(DaySecPST/TFSec) <= 60000;
#def Alarm= if SecondsfromTime(2100)/ TF*60*1000- Floor(SecondsfromTime(2100)/MinNo*60*1000) <= 60000; AddLabel(yes,”DaySecPST is “+DaySecPST+”Floor DaySecPST is “+Floor(DaySecPST,Color.DARK_GREEN);
#Method 3 def Alarm= RegularTradingEnd(GetTime())/MinNo*60*1000 – Floor(RegularTradingEnd (GetTime()) /MinNo*60*1000) <= MinNo*60*1000;
#Method 4 cum= cum[1]+1; def Alarm= if (cum/TF)- Floor(cum/TF) =0 then 1 else 0;
#Method 5 declare once_per_bar; Alarm==1; Alert(Alarm, MinNo+” Min Alarm”, Alert.Once, Sound.Bell);
RESOLVED
Marked as spam
|
Please log in to post questions.
Sorry, assumed it. I am using this as the alert paragraph.
Alert(Yes,MinNo+” Min Alarm”, Alert.Bar, Sound.Bell);
Alert(Alarm,MinNo+” Min Alarm”, Alert.Once, Sound.Bell);
Alert(Alarm,MinNo+” Min Alarm”, Alert.Once, Sound.Bell);
So I do have Alert.Bar-and not Alert.Once in one of them. I have changed them all to Alert. Bar but does not work.
Did you try my solution then? Set alert condition to yes. It always triggers. For every bar. It is set to Alert once per bar. So instead of alerting at the close of the bar it alerts at the beginning of the new bar. Which is just milliseconds apart.