![]() |
|
|||||||
| Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
|
I am trying to figure out how to create a condition in strategy wizard:
1. If rule 1 is true then go long but if rule 2 is true then do nothing. How would I do this? Thank you |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Mar 2012
Location: Denver, CO
Posts: 1,317
Thanks: 158
Thanked 206 times in 205 posts
|
Hello relogical,
In the Conditions and Actions window you can create conditions that if true that they can do an action. For example in the Set 1 tab we can say that if the Close[0] of the current bar is greater than the Close[1] of the previous bar to go long. See attached image Set1. If you want a separate condition to go short you can use the Set 2 tab to create a separate list of conditions and actions. For example in the Set 2 tab we can say that if the Close[0] of the current bar is less than the Close[1] of the previous bar to go short. See attached image Set2. Here is a link to our help guide that goes over the Condition Builder in the Strategy Wizard. http://www.ninjatrader.com/support/h...on_builder.htm We do have a YouTube video that goes over the Strategy Wizard that you may view at the following link. http://www.youtube.com/watch?v=fVFqw...ure=plpp_video Please let me know if I can be of further assistance.
JC
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
|
Thank you for your assistance but this is not what I am trying to accomplish. I am trying to go long when one indicator tells me to do so but if another indicators tells me not then do nothing and wait for next rule.
|
|
|
|
|
|
#4 |
|
Senior Member
|
You will need an if ... else branch. You will have to unlock the code to add the else construct; the Strategy Wizard cannot natively do if ... else constructs.
|
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
|
Hello,
You could still do this with the strategy analyzer. What you would do is in set one check the value of the indicator A is in a range you want to trade, then in the Do The Following: sections Set a variable = 1 for example. 1 for true and 0 for false for flags that we then will check in another set to see if both confitions are true. Set 1 would check indicator A and set indicator to 1 Set 2 would check indicator A and set variable to 0 if its not ready to trade Set 3 would check indicator B and set variable to 1 Set 4 would check indicator B and set variable to 0 if its not ready to trade Finally Set 5 would check that Variable0 and Variable1 are both set to 1, if they are then enter the trade if not then wait. -Brett
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#6 | |
|
Senior Member
|
Quote:
|
|
|
|
|
|
|
#7 |
|
Member
Join Date: Jan 2009
Posts: 94
Thanks: 0
Thanked 14 times in 12 posts
|
Actually the solution is much easier since the Rule is just a conditional statement. What's needed is for Rule 2 to be made as an Override.
Since Conditions and Actions wizard only applies 'AND' logic to each rule, all rules must be TRUE for Actions to be triggered. All that's needed is for relogical's Rule 2 conditional statement to always be TRUE unless the condition is such that the Action be Overriden. For Rule 2 currently defined as A > B, the revised condition would be A < B, or more precisely, A <= B. |
|
|
|
|
The following user says thank you to borland for this post: |
|
|
|
#8 | |
|
Senior Member
Join Date: Dec 2009
Location: Netherlands
Posts: 180
Thanks: 15
Thanked 72 times in 51 posts
|
Quote:
(To import use File/Utilities/Import Ninjascript) Marco |
|
|
|
|
|
The following 3 users say thank you to marcow for this post: |
|
|
|
#9 |
|
Member
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
|
Thank you for your help but my brain seems to not function today and I am not able to figure out the logic. I am sure it is very simple so I am hoping that you can show or explain to me how to set it up. All I want to do is not trade if ADX is below SMA14 and SMA30. Any other time is ok to trade. Thank you.
|
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Mar 2012
Location: Denver, CO
Posts: 1,317
Thanks: 158
Thanked 206 times in 205 posts
|
Hello relogical,
Please be aware that we do not normally do any NinjaScript development for customers, since it can limit our level of support to our customers. We do have a number of Educational Partners that can teach you about NinjaScript. Also, we do have NinjaScript Consultants that can help you write NinjaScript for a fee. Please view our website for more information about our Partners. http://www.ninjatrader.com/partners#...pt-Consultants With that said I have attached a strategy that was made inside the Strategy Wizard that you can see how to create the strategy that you want and customize to your preferences if you need. To Import 1. Download the attached file to your desktop 2. From the Control Center window select the menu File > Utilities > Import NinjaScript 3. Select the downloaded file Please let me know if I can be of further assistance.
JC
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_JC for this post: |
|
|
|
#11 |
|
Member
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
|
Thank you for the sample. You have Variable0=0 and 1=0 but there is nothing to refer to these variables in your sample. The only rule to go long is if 0=1 and 1=1. So why are the other variables for?
Also, in your sample the condition to go long is if ADX crosses below SAM14 and SMA30. But what if ADX is between the two SMA14 and SMA30 or between SMA30 and SMA14, what happens then? Thank you |
|
|
|
|
|
#12 |
|
NinjaTrader Customer Service
Join Date: Mar 2012
Location: Denver, CO
Posts: 1,317
Thanks: 158
Thanked 206 times in 205 posts
|
Hello relogical,
Variable0 to Variable9 are User variables that are predefined inside a strategy to use, which comes in part to check logic in the Strategy Wizard as one of the Strategy Actions is to set user variable to a value. Nothing will happen until the ADX crosses below the SMA14 and SMA30. You can add more logic to define your Automated Strategy to your own preferences. You may read more about the condition builder at the following link. http://www.ninjatrader.com/support/h...on_builder.htm We do have a YouTube video that goes over Automated Strategy Development at the following link. http://www.youtube.com/watch?v=fVFqw...ure=plpp_video Please let me know if I can be of further assistance.
JC
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Please assist with Swing, ZigZag, Darvas | relogical | Automated Trading | 1 | 06-26-2012 09:56 AM |
| Missing variable in Srategy | Mannygags | General Programming | 5 | 11-04-2011 10:45 AM |
| Just a little code assist needed for entry filter | Trader.Jon | Strategy Development | 5 | 10-27-2010 11:20 AM |
| trade assist | vk2205 | Automated Trading | 0 | 04-07-2009 10:09 AM |
| Traders, can you assist? | ETemp | Connecting | 6 | 02-20-2007 07:36 AM |