♥ 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.
Now that I understand what you have been expecting to achieve I have some great news for you. Give up. You will never get there with Thinkorswim. This is because Thinkorswim uses a data aggregator for the streaming quotes. You will never have a one min bar close at exactly 60 seconds on Thinkorswim. The data comes through in buckets. Not for every single tick. If you want something that will sound an alarm at the end of every 60 seconds. Go buy one. I mean go by an application or a piece of hardware. Don’t rely on the data feed of a trading platform and expect to make this happen.
Just tried it on 5 min. It really is at most 19 seconds on that too. I should have realized it is will be a much smaller % on the 15 min. Really just amazed at that all the time-related function/ methods I tried, did not work at all.