NinjaTrader Support Forum  

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 08-10-2012, 07:28 AM   #1
chiropharm
Junior Member
 
Join Date: Aug 2012
Location: Pennsylvania
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default Need assistance with indicator

I am new to Ninja Trader after working with e-signal for several years.

I need to re-develop my primary indicator. (I'm clueless with Ninja at this point)

When a bar closes above/below both of 2 EMA's and the shorter is above for a buy and below for a sell.

When this occurs for the first time after not occurring for at least 3 bars it will mark an arrow on the chart (above price for sell, below price for buy) and give an audible "Buy" or "Sell"

All assistance will be appreciated
chiropharm is offline  
Reply With Quote
Old 08-10-2012, 07:55 AM   #2
NinjaTrader_JC
NinjaTrader Customer Service
 
NinjaTrader_JC's Avatar
 
Join Date: Mar 2012
Location: Denver, CO
Posts: 1,317
Thanks: 158
Thanked 206 times in 205 posts
Default

Hello chiropharm,

Welcome to the NinjaTrader Support Forums!

To start we have a fully documented help guide which will help you get started with Ninja Script. In the help guide you will find language references to all of the methods and functions you will be using. You will also see a tutorial section which will help you create your first indicator and get you started with some of these concepts.
http://www.ninjatrader.com/support/h..._resources.htm

With that said, here is an example of how you can use the EMA to check the Close[] of the current bar.

Code:
if(EMA(14)[0] < Close[0] && EMA(15)[0] < Close[0])
{
      //Do Something
}
Here are some helpful references to help you get started that you may want to view.

EMA: http://www.ninjatrader.com/support/h...onential_e.htm

Using Brackets []: http://www.ninjatrader.com/support/f...ad.php?t=19346

Alert: http://www.ninjatrader.com/support/h...html?alert.htm

To see an example of an Alert() function you can view the code of the PriceAlert Indicators that comes preloaded in NinjaTrader by going to the Control Center -> Tools -> Edit NinjaScript -> Indicator and double click on the PriceAlert.

Also here is a link to our support forums that goes over how to debug your code which comes in handy if you run into a compiling errors when writing custom code.
http://www.ninjatrader.com/support/f...ead.php?t=3418


Let us know if we can be of further assistance.
Last edited by NinjaTrader_JC; 08-10-2012 at 07:57 AM.
NinjaTrader_JC is offline  
Reply With Quote
Old 08-13-2012, 01:22 PM   #3
chiropharm
Junior Member
 
Join Date: Aug 2012
Location: Pennsylvania
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank You.
This will get me started
chiropharm is offline  
Reply With Quote
Old 08-13-2012, 09:39 PM   #4
mrdude
Junior Member
 
Join Date: Jan 2012
Location: Portsmouth, NH
Posts: 13
Thanks: 0
Thanked 5 times in 4 posts
Default

Can you post an example picture of the buy and sell signals? I get a little confused when reading your description, but a picture could help me to understand this.
mrdude is offline  
Reply With Quote
Old 08-16-2012, 02:01 PM   #5
chiropharm
Junior Member
 
Join Date: Aug 2012
Location: Pennsylvania
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default

I will try and attach a screen shot from Ninja that has been manually annotated
Attached Images
File Type: jpg Ninja Chart.jpg (223.8 KB, 17 views)
chiropharm is offline  
Reply With Quote
Old 08-18-2012, 11:20 AM   #6
mrdude
Junior Member
 
Join Date: Jan 2012
Location: Portsmouth, NH
Posts: 13
Thanks: 0
Thanked 5 times in 4 posts
Default

Thanks, I've been playing around with this a bit and have it almost done. I'm going to be out for the rest of the weekend so I'll probably finish it next week.
mrdude is offline  
Reply With Quote
Old 08-20-2012, 07:36 PM   #7
mrdude
Junior Member
 
Join Date: Jan 2012
Location: Portsmouth, NH
Posts: 13
Thanks: 0
Thanked 5 times in 4 posts
Default

Here's what I've put together. It's drawing an arrow whenever the price is above the fast EMA and the fast EMA is above the slow EMA as long as there hasn't been an arrow drawn in the last 3 bars. I added in a BarsAgo parameter in case you want to change how many bars back to look for previous arrows.

I also played around with the idea of only drawing arrows if price crossed above the fast EMA while fast was still above slow or when the fast EMA crossed above slow EMA and price was above the fast. Minor difference, but it did result in fewer arrows. Let me know if you want to see that one.
Attached Files
File Type: zip chiropharmEMA.zip (4.0 KB, 1 views)
mrdude 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
Syntax assistance safetrading Automated Trading 1 01-03-2012 07:34 AM
Assistance with indicator for Range bars nicbizz Indicator Development 3 01-03-2011 03:12 PM
Assistance with MFI Indicator carlton Indicator Development 11 01-03-2011 02:26 PM
Alerts programming assistance JackWittaker Indicator Development 28 11-05-2009 02:30 AM
Indicator Assistance rollinghills Indicator Development 5 11-01-2009 03:02 PM


All times are GMT -6. The time now is 03:17 AM.