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 > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 09-24-2008, 08:32 PM   #1
designer
Senior Member
 
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
Default Help with Condition builder

Strategy: Entering on one specific price and exiting on another
In the Strategy Wizzard Condition builder I am trying to create an entry when price crosses above a specific price number and exit when it hits a specific price target. Say an equity is trading currently at 10 and my strategy calls to enter when that equity price hits 15 (MyInput).
I cant figure it out. Please post a screenshot of the Condition Builder to show if possible.
Thanks.
designer is offline  
Reply With Quote
Old 09-24-2008, 10:22 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

You would select Price Data -> Close on one side and compare it to Misc -> Numeric value on the right side. Alternatively, you can select User Defined Inputs and choose a variable you create in the previous page in the Wizard.
Attached Images
File Type: jpg 12.JPG (41.3 KB, 23 views)
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-25-2008, 05:49 AM   #3
designer
Senior Member
 
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank you Josh.
How do I create the MyInput under User Defined Inputs in your screenshot?
designer is offline  
Reply With Quote
Old 09-25-2008, 08:04 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Please see the tutorials in the Help Guide. http://www.ninjatrader-support.com/H...de.html?SetUp7
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-25-2008, 06:41 PM   #5
designer
Senior Member
 
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
Default

Josh,
I did watch the videos though in the video example the condition had a ... (3 dot) icon where one can click to insert the user defined input ; in our example the "Numeric Value" condition does not have the ... icon to be able to insert my user defined input, please help.
Thanks
designer is offline  
Reply With Quote
Old 09-26-2008, 08:02 AM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Right. Take a look at the screenshot I posted earlier. Look at the item pointed at on the lower right hand side. You want to just expand that and select your user defined input from there.
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-26-2008, 02:18 PM   #7
designer
Senior Member
 
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
Default

OK Josh,
Thank you that works real good.
Sorry I did not realize you can leave the bottom panel blank.
designer is offline  
Reply With Quote
Old 10-28-2008, 10:23 PM   #8
designer
Senior Member
 
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
Default

Josh,
Great seminar yesterday.
Question, similar to the buy question in this thread before...I want to create a strategy condition where i sell / close a specific quantity at a specific price. Please advice.
Thanks
designer is offline  
Reply With Quote
Old 10-29-2008, 08:12 AM   #9
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Hi designer,

Thank you. What you want to do is in the Conditions and Actions page add an action. You want to use either an "Exit short limit" or "Exit long limit" order depending on the type of position you have open already. From there you can select the price you want and the quantity you want.
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-29-2008, 10:53 AM   #10
designer
Senior Member
 
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks,
Would that work even if the strategy does not have a buy condition?
Say I just want to create an exit from an existing position.
Thanks again
designer is offline  
Reply With Quote
Old 10-29-2008, 10:56 AM   #11
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

No. Strategies can only interact with positions created from the strategy itself.
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-30-2008, 05:55 AM   #12
designer
Senior Member
 
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
Default

I created code (attached) using the Strategy Wizzard where I set a condition to buy at spec price and sell at spec price.
When I implement the strategy in a chart it does not trigger the buy sometimes. Please review code if i need to adjust something pls let me know.
Thanks
Attached Files
File Type: txt Buy and sell at specified price.txt (14.6 KB, 10 views)
designer is offline  
Reply With Quote
Old 10-30-2008, 08:08 AM   #13
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

designer,

The code you provided should work. Please remember that you will only be able to sell if you had a long position already open. You will also only be able to buy when you are flat. If you already have a long position, additional long orders will be ignored.
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-30-2008, 10:55 AM   #14
designer
Senior Member
 
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
Default

I had a long position already open when i had the sell position.
It works sometimes not always.
Try this one... In the Strategy set SKF 30 min chart Buy 100 at 141.5 Sell at 166.5.
Thanks
designer is offline  
Reply With Quote
Old 10-30-2008, 11:02 AM   #15
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

designer,

Unfortunately I cannot run it on my end. What you would want to do is debug your code. You will need to come out of the Strategy Wizard to do this. Please see these tips: http://www.ninjatrader-support.com/v...ead.php?t=3418
http://www.ninjatrader-support.com/v...ead.php?t=3627

Please use TraceOrders = true and then print values for your GetCurrentBid() as well as your PriceSell to evaluate if your condition is true. The TraceOrders will give you a reason why your order is ignored or rejected if that is what is happening. Otherwise the Print() will tell you if you are actually submitting the order or not.

Please also note that your SetStopLoss() may be closing your long position before you do ExitLong(). This could also be a potential factor in why your exit is not working.
NinjaTrader_Josh 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
Need help with Condition Builder amberwest Strategy Development 19 08-13-2008 03:09 PM
'Stops & Targets' missing from the Condition Builder? Elliott Wave Strategy Development 3 06-15-2008 07:44 PM
Condition builder - Swing HH nico_p Strategy Development 2 03-12-2008 05:17 PM
Condition Builder OUFan Strategy Development 6 12-19-2007 02:05 PM
Condition Builder - Time Comparison Error davidfw1866 Strategy Development 4 10-30-2007 07:16 AM


All times are GMT -6. The time now is 06:51 AM.