Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 10-21-2011, 10:09 AM   #1
Style
Member
 
Join Date: Jul 2009
Posts: 60
Thanks: 18
Thanked 2 times in 2 posts
Default Alert on new bar?

I trade with longer term tick bars, where it takes usually 15 to 30 minutes to complete a bar. I often find myself checking the chart, waiting on the bar to close before I take action. It would be nice if I didn't have to watch, if I could just check back after the bar completes.

Is there an indicator that will sound an audible alert on the close of the bar? If not, what would be the best way to create one?

Thanks!
Style is offline  
Reply With Quote
Old 10-21-2011, 11:11 AM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 383 times in 372 posts
Default

Style,

Yes, this is possible.

Just create a new Indicator using Tools > Edit NinjaScript > Indicator, make sure CalculateOnBarClose = true, then add the following code to OnBarUpdate()


Code:
        protected override void Initialize()
        {
            Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
            Overlay				= true;
        }

        protected override void OnBarUpdate()
        {
			Alert("Bar CLOSED!", NinjaTrader.Cbi.Priority.High, "Bar CLOSED!", "Alert1.wav", 10, Color.Red, Color.Yellow);
        }
NinjaTrader_AdamP is offline  
Reply With Quote
The following user says thank you to NinjaTrader_AdamP for this post:
Old 10-24-2011, 06:54 AM   #3
Style
Member
 
Join Date: Jul 2009
Posts: 60
Thanks: 18
Thanked 2 times in 2 posts
Default

Works like a charm. Thanks Adam!
Style is offline  
Reply With Quote
Old 10-28-2011, 09:05 AM   #4
Jim P
Junior Member
 
Join Date: Oct 2011
Posts: 4
Thanks: 1
Thanked 0 times in 0 posts
Default

Hello,
I'm new to Ninjatrader so please excuse my newbie slowness in figuring this out. I'm also looking for an alert at the close of a tick bar. When following these instructions "Tools > Edit NinjaScript > Indicator" I have come to the point where I have to choose the indicator to modify. Corrrect? If so which one should I choose? Or do I build one from scratch?
Jim P is offline  
Reply With Quote
Old 10-28-2011, 09:25 AM   #5
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 383 times in 372 posts
Default

Jim P,

I am happy to assist you.

The code I posted in post number 2 will work for you. For future reference, you can go to Tools > New NinjaScript > Indicator then just paste this code into your OnBarUpdate() method. However, Ill just attach this indicator below. To import it, go to Files > Utilities > Import NinjaScript.

Please let me know if I may assist further.
Attached Files
File Type: zip CloseBarAlert.zip (1.8 KB, 165 views)
NinjaTrader_AdamP is offline  
Reply With Quote
Old 10-28-2011, 09:36 AM   #6
koganam
Senior Member
 
Join Date: Feb 2008
Location: http://omegasigmaindicators.com
Posts: 4,840
Thanks: 31
Thanked 2,014 times in 1,647 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by JIm P View Post
Hello,
I'm new to Ninjatrader so please excuse my newbie slowness in figuring this out. I'm also looking for an alert at the close of a tick bar. When following these instructions "Tools > Edit NinjaScript > Indicator" I have come to the point where I have to choose the indicator to modify. Corrrect? If so which one should I choose? Or do I build one from scratch?
Create a new indicator.
koganam is offline  
Reply With Quote
Old 10-28-2011, 10:22 AM   #7
bbelliveau
Junior Member
 
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default MACD CrossOver Alert

Hi there. I'm not sure if I'm in the right forum, but i'd like to know if there's a custom indicator to get an Alert when there's a MACD crossover? I tried searching, but came up empty. Thoughts?
bbelliveau is offline  
Reply With Quote
Old 10-28-2011, 10:45 AM   #8
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 383 times in 372 posts
Default MACD w/ Alerts

bbelliveau,

I am happy to assist you.

Generally, we do not do custom programming here at NinjaTrader however you are in luck. I have previously created an indicator like this. Please find it attached.

Please let me know if I may assist further.
Attached Files
File Type: zip MACDwAlerts.zip (2.4 KB, 36 views)
NinjaTrader_AdamP is offline  
Reply With Quote
Old 10-28-2011, 10:47 AM   #9
bbelliveau
Junior Member
 
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default

SWEET! Thanks. I will try it out over the weekend!
bbelliveau is offline  
Reply With Quote
Old 10-28-2011, 10:54 AM   #10
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 383 times in 372 posts
Default

bbelliveau,

You will only get alerts in Market Replay or on live data with this indicator through the Alerts window. This is located in File > New > Alerts. It will play an alert sound and display some text in this window.

If what you meant was a signal such as a color change or a drawn object, such as an arrow, this is different.

Please let me know if I can assist further.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 10-28-2011, 10:57 AM   #11
bbelliveau
Junior Member
 
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default

No... sound alert is perfect!
bbelliveau is offline  
Reply With Quote
Old 10-28-2011, 12:00 PM   #12
Jim P
Junior Member
 
Join Date: Oct 2011
Posts: 4
Thanks: 1
Thanked 0 times in 0 posts
Default

Thanks for the help Adam.
Jim P is offline  
Reply With Quote
Old 10-28-2011, 12:22 PM   #13
Jim P
Junior Member
 
Join Date: Oct 2011
Posts: 4
Thanks: 1
Thanked 0 times in 0 posts
Default

Hello Adam,
Just wondering how/if I can change the alert to a different sound. Can I import different sounds for this indicator or would I have to create the indicator from scratch?
Jim P is offline  
Reply With Quote
Old 10-28-2011, 12:47 PM   #14
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 383 times in 372 posts
Default

Jim P,

Sounds are located in C:\Program Files (x86)\NinjaTrader 7\sounds

You can change the code by going to Tools > Edit NinjaScript > Select the indicator, then change the line :

Alert("Bar CLOSED!", NinjaTrader.Cbi.Priority.High, "Bar CLOSED!", "Alert1.wav", 10, Color.Red, Color.Yellow);

Where it says "Alert1.wav" to whatever you want in the Sounds directory. Afterwards, hit the compile button in the top toolbar. Using custom sounds is not supported but you can try adding a sound in there in .wav format.

Please let me know if I can assist further.
NinjaTrader_AdamP is offline  
Reply With Quote
The following user says thank you to NinjaTrader_AdamP for this post:
Old 10-28-2011, 01:28 PM   #15
Jim P
Junior Member
 
Join Date: Oct 2011
Posts: 4
Thanks: 1
Thanked 0 times in 0 posts
Default

Great! Thank you.
Jim P is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
One Alert per bar Viper3 Strategy Development 7 06-30-2011 11:39 AM
sound alert() for a big bar crmcwi Indicator Development 2 05-11-2010 05:30 AM
Alert set to once per bar blarouche Indicator Development 4 08-18-2009 09:12 AM
audio alert upon completion of a bar stephenszpak Market Analyzer 18 05-10-2009 01:57 AM
Alert on new bar? tradingcube Charting 2 02-03-2009 01:22 PM


All times are GMT -6. The time now is 12:35 AM.

FULL RISK DISCLOSURE: Futures trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.