NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

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.

Reply
 
Thread Tools Display Modes
Old 06-27-2012, 03:38 PM   #1
relogical
Member
 
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
Default Please assist with using srategy wizard

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
relogical is offline  
Reply With Quote
Old 06-27-2012, 04:12 PM   #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 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.
Attached Images
File Type: png Set1.png (110.4 KB, 8 views)
File Type: png Set2.png (144.3 KB, 3 views)
NinjaTrader_JC is offline  
Reply With Quote
Old 06-27-2012, 04:45 PM   #3
relogical
Member
 
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
Default

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.
relogical is offline  
Reply With Quote
Old 06-28-2012, 06:15 AM   #4
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,356
Thanks: 24
Thanked 1,304 times in 1,067 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by relogical View 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
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.
koganam is offline  
Reply With Quote
Old 06-28-2012, 06:57 AM   #5
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

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
NinjaTrader_Brett is offline  
Reply With Quote
Old 06-28-2012, 03:05 PM   #6
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,356
Thanks: 24
Thanked 1,304 times in 1,067 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by NinjaTrader_Brett View Post
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
That sounds more like Assembler than C# !
koganam is offline  
Reply With Quote
Old 06-28-2012, 03:46 PM   #7
borland
Member
 
Join Date: Jan 2009
Posts: 94
Thanks: 0
Thanked 14 times in 12 posts
Default

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.
borland is offline  
Reply With Quote
The following user says thank you to borland for this post:
Old 06-28-2012, 07:47 PM   #8
marcow
Senior Member
 
Join Date: Dec 2009
Location: Netherlands
Posts: 180
Thanks: 15
Thanked 72 times in 51 posts
Default

Quote:
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.
is this what you're looking for ?
(To import use File/Utilities/Import Ninjascript)

Marco
Attached Files
File Type: zip test1.zip (5.5 KB, 13 views)
marcow is offline  
Reply With Quote
The following 3 users say thank you to marcow for this post:
Old 06-29-2012, 08:39 AM   #9
relogical
Member
 
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
Default

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.
relogical is offline  
Reply With Quote
Old 06-29-2012, 09:29 AM   #10
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 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.
Attached Files
File Type: zip SampleTrade.zip (4.3 KB, 16 views)
NinjaTrader_JC is offline  
Reply With Quote
The following user says thank you to NinjaTrader_JC for this post:
Old 06-29-2012, 09:54 AM   #11
relogical
Member
 
Join Date: Jun 2012
Posts: 87
Thanks: 3
Thanked 1 time in 1 post
Default

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
relogical is offline  
Reply With Quote
Old 06-29-2012, 10:29 AM   #12
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 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.
NinjaTrader_JC 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
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


All times are GMT -6. The time now is 12:04 AM.