Modificate Bar Timer Hybrid indicator to use it as regular alarm

Hello guys,

my goal is to have an indicator, where i get the last second of an bar to make an alert combined with a strategy, fires when the bar closes.

The in ninjatrader included BarTime Counter cannot be accessed by the Alerts Condition for indicators.

So i searched an already modified one. I found the BarTimerHybrid indicator, which is quite good:

In Alerts you can use the indicator as condition:

BUT the Numeric value seems not to work. I tried several values and expressions equal, less etc.

Nothing works - no Alarm.

I think the reason is, that the indicator does not plots out a numeric value? I tried to change some variables, but i do not get it.

Maybe someone here has an idea what to do or what to change, that this works out.

Thank you very much

Trib

Hi I am the author - I am not sure if you could use this in a strategy as it’s really just a utility to assist with time stuff. You could certainly flash the panel or emit a sound alert at 1 second before the end of the bar - that’s the core design principle - but in my experience you’re better setting it at say 3-5 seconds to give you time to react, etc.. By the way there is a version 9 out which is way better IMHO :grin: I will try and post it here but otherwise it’s in NexusFi dot com.

Hello Mindset,

thank you for your response. Maybe it is possible to plot an extra int out with just a number such as 50 instead of a string 00:00:50?

Sadly, i am not a programmer, so i cannot find the codeline, where to edit it. Maybe you can help me out?

This would be great

yes that’s possible but in real time getting say the last second of a bar is fraught with difficulty. racing conditions. Gaps, large orders etc all can mean the last second ‘disappears’. but let me see what i can do for you

This would be phantastic. With this it is possible to have an alarm near closing Bars. I think many others would like that too.

Thank you for your support

I tried it myself in the editor, but when i try to change the string into int, it does not work. I always get an error. I do not have the skills for that i think :relieved_face:

NT are sorting out the file for the latest version of BarTimerHybrid - apparently I exported it in the wrong format somehow.

Anyway if you want a numerical countdown change this region in the code and it will give you a string output. It does depend on you having some sort of trigger and I would not set it at less than 5 if you want it to be reliable.

		#region FlashSwitcher
	private int FlashSwitch()
	{
		flashon = 0;
			if (Now.Second % 2 < 1)//not now
			flashon= 1;
			Print(counterstr);
			if (int.TryParse(counterstr, out int result))
			{
			    Print($"Converted: {result}");
			}
			else
			{
			    Print("Invalid number");
			}
			return flashon;
	}
	#endregion

Edit I realised you wanted a numeric output

Thank you very much. I will give it a try. Don´t know if it will work, but i hope so.

Updated version of the BarTimerHybrid is finally uploaded and available here.

Please note there are a number of links to explanatory videos - the last link at the bottom of the spiel is the correct one

Hello,

I think the link of the last eplonatory video is wrong:

Updated version of my BarTimer(v9).

Updated video is in a link in the indicator and [here.](https://studio.youtube.com/video/jMaFvzYEZX0/edit)

I will test the indicator on monday. I am pretty excited about these.

Thank you for your support. I really appreciate that.

Hello Russel,

i tried it out, but sadly it does not work with the alarm. When i set it as numeric value, there is still no reaction. :pensive_face:

click the link in the indicator - that works.

Yeah, i finally have found it. :slightly_smiling_face:

Unfortunately you still can’t access the contdown value in the alert.

I assume that the reason is that it is a string. I think in order to access the counter in the alerts, it must have values in the right scale.

At least that’s how it is with the other indicators if you want to access the numeric value. If that were possible, your HybridCounter would be the only indicator of this type that can do that at all.

Thx Trib

So there ist no chance to get there?

you can plug this into OnBarUpdate and it will fire once at your elected point in the seconds countdown

private bool triggerFiredThisBar = false;

protected override void OnBarUpdate()
{
if (IsFirstTickOfBar)
triggerFiredThisBar = false;

if (Trigger > 0 && !triggerFiredThisBar)
{
    triggerFiredThisBar = true;
    Print($"Trigger first fire for this bar: {CurrentBar}");
}

}