NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 06-19-2012, 09:03 AM   #1
TWL21
Junior Member
 
Join Date: Jun 2012
Posts: 6
Thanks: 5
Thanked 0 times in 0 posts
Default Sell when price drops below a certain level.

Hello everyone. I am new to Ninja Trader and have no programming background hence I am using the strategy wizard to build my strategy. I have been building my strategy within the wizard and am starting to get more comfortable with it. However I've run into a problem I can't seem to solve. I need some help to place instructions using the wizard to sell once price drops below the lowest low in the last 10 days. Is this possible to do simply using the strategy wizard? Any help would be appreciated. Thanks!
TWL21 is offline  
Reply With Quote
Old 06-19-2012, 09:11 AM   #2
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,781
Thanks: 159
Thanked 565 times in 556 posts
Default

Hello,

Thank you for your post and welcome to our forums!

This would be possible, however it would require that you run the strategy on a Daily interval.

You can easily setup this condition by Comparing the Price Data--> Close to the "Misc"--> "Lowest Bar" function, with 10 as the Period.
Attached Images
File Type: png lowestbar.PNG (50.0 KB, 6 views)
NinjaTrader_Matthew is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Matthew for this post:
Old 06-19-2012, 09:35 AM   #3
TWL21
Junior Member
 
Join Date: Jun 2012
Posts: 6
Thanks: 5
Thanked 0 times in 0 posts
Default

Thanks for your quick reply. Setting up the condition is quite simple as you outlined, however, when I backtest this, it doesn't seem to capture my sell instructions. You mentioned running the strategy on a daily interval, where would I specify this? Just to make sure I'm inputting this correctly, I've put these instructions in the section where it says, "when the following conditions are true" in the wizard. I've then put "exit long" in the section where it says, "do the following" just to keep things simple. Did I input this correct and in the right spot/format?
TWL21 is offline  
Reply With Quote
Old 06-19-2012, 09:45 AM   #4
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,781
Thanks: 159
Thanked 565 times in 556 posts
Default

Hello,

Yes, that should be in the correct place.

When you're back testing the strategy in the Strategy Analyzer, you will have an option for the "Data Series" to test on.

In order for the Lowest Bar period to look back 10 days, you would need to run the strategy on the Daily interval, rather than a tick or minute.
NinjaTrader_Matthew is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Matthew for this post:
Old 06-19-2012, 10:02 AM   #5
TWL21
Junior Member
 
Join Date: Jun 2012
Posts: 6
Thanks: 5
Thanked 0 times in 0 posts
Default

Yes, in the strategy analyser I have the data series set to "day". I also have the minimum bars required set far back enough to allow the strategy enough time. But once again, my sell instructions are not being captured. That is my only exit condition. Any other thoughts/ideas?
TWL21 is offline  
Reply With Quote
Old 06-19-2012, 10:18 AM   #6
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,781
Thanks: 159
Thanked 565 times in 556 posts
Default

Hello,

Instead of using the DefaultSeries, please try using Price Data--> Low as the series of the Lowest bar
NinjaTrader_Matthew is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Matthew for this post:
Old 06-19-2012, 10:44 AM   #7
TWL21
Junior Member
 
Join Date: Jun 2012
Posts: 6
Thanks: 5
Thanked 0 times in 0 posts
Default

Thank you again, however, that still doesn't quite work for me. When I input the close as < the low of 10 bars ago, it only uses exactly 10 days ago as opposed to the lowest low in the last 10 days. Maybe I have this inputted wrong. Thanks for you patience on a simple issue.
TWL21 is offline  
Reply With Quote
Old 06-19-2012, 11:46 AM   #8
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,781
Thanks: 159
Thanked 565 times in 556 posts
Default

Hello,

Sorry for the confusion - we need to be using MIN to get the lowest price.

You will find this under Indicators--> Min

The parameters you would use would be Period of 10 and Barsago of 1.
NinjaTrader_Matthew is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Matthew for this post:
Old 06-19-2012, 01:04 PM   #9
TWL21
Junior Member
 
Join Date: Jun 2012
Posts: 6
Thanks: 5
Thanked 0 times in 0 posts
Default

OK, so I've tried using the MIN indicator as outlined, but it when I input the instructions like you've outlined, a sell signal is generated when the low goes below the lowest close of the last 10 days, not the low.
TWL21 is offline  
Reply With Quote
Old 06-19-2012, 01:07 PM   #10
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,781
Thanks: 159
Thanked 565 times in 556 posts
Default

Did you run this on the "DefaultInput" or did you change that to "Low"?
Attached Images
File Type: png low.PNG (59.3 KB, 6 views)
NinjaTrader_Matthew is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Matthew for this post:
Old 06-19-2012, 01:48 PM   #11
TWL21
Junior Member
 
Join Date: Jun 2012
Posts: 6
Thanks: 5
Thanked 0 times in 0 posts
Default

This worked, thank you very much!
TWL21 is offline  
Reply With Quote
Old 11-15-2012, 04:06 AM   #12
hifreq
Member
 
Join Date: Jan 2009
Posts: 42
Thanks: 0
Thanked 0 times in 0 posts
Default

hi - can you tell me how i would do a similar instruction via the GUI. I want to "exit" (a long) if price trades below - the low on the bar prior to entery if that can not be done than 25pip less than low of the bar upon which i entered the trade
hifreq is offline  
Reply With Quote
Old 11-15-2012, 04:55 AM   #13
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello hifreq,
You cannot do it via the Strategy Wizard. You can however do it by unlocking the code and further edit it via the NinjaScript editor.

As an alternative you can evaluate your code with the average entry price. The attached screenshot demonstrates how to exit a position if it is 25 below your average entry price.
Attached Images
File Type: png Pic4.png (51.7 KB, 4 views)
NinjaTrader_Joydeep 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
Check order on a price level er111222 Strategy Development 9 06-18-2012 04:09 AM
Position best price level cgeorgan General Programming 3 03-06-2011 07:39 PM
Version 6.5.1000.9 drops Gain feed connection popeyeuk Connecting 3 03-31-2009 11:09 AM
Price level colour on SuperDOM garyford Suggestions And Feedback 1 03-02-2009 04:25 AM
SA drops indicators on backtest Billy Valentine Strategy Analyzer 3 11-17-2008 03:12 PM


All times are GMT -6. The time now is 08:13 AM.