![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
|
Thank you Josh.
How do I create the MyInput under User Defined Inputs in your screenshot? |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Please see the tutorials in the Help Guide. http://www.ninjatrader-support.com/H...de.html?SetUp7
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
|
OK Josh,
Thank you that works real good. Sorry I did not realize you can leave the bottom panel blank. |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#9 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#11 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
No. Strategies can only interact with positions created from the strategy itself.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#13 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#14 |
|
Senior Member
Join Date: Sep 2008
Posts: 289
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#15 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |