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

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 12-05-2008, 09:42 AM   #1
wcmaria
Junior Member
 
Join Date: Oct 2008
Posts: 23
Thanks: 0
Thanked 0 times in 0 posts
Default Programming Conditions

I have a question I'm hoping someone can help me with regards to programming conditions into my code.

I am used to the Tradestation method of programming in which you can quickly identify say Condition1 = (insert condition), Condition2 = (insert condition) and so on and then in the end have an if statement.

if condition1 and condition 2 then do something

or

if condition 1 or condition 2 then do something.

I am currently trying to code an indicator that will indetify my setups with an up arrow or down arrow.

I have several condition that need to be meet in order to satisfy a trade setup or not.

What is the best way to code this?

Is it possible to use Bool statements for each condition with if statements, for example

bool condition1 = false;
bool condition2 = false;

if (high[0] > high[2]) {
condition1 = true}

if(low[3] < low[9]){
condition2 = true}

then have a statement at the end that checks for each condition to be true to run my code

if (condition1 && condition2){
drawarrowup}

Any other ideas?

Thanks
wcmaria is offline  
Reply With Quote
Old 12-05-2008, 09:52 AM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,


Yes, this is one way of doing it. If you do it this way be sure you have a reset for your bools to set them back to false.

Another way would be to just have one large if statement like this:

if(high[0] > high[2] && low[3] < low[9])
{

DrawArrowUp("myArrowTag", true, Low[0], Color.Red);

}
NinjaTrader_Ben 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
Problem with multiple conditions daven Strategy Development 10 01-08-2010 08:30 AM
Race Conditions TAJTrades Strategy Development 11 12-15-2008 07:19 AM
Rev Conditions Dobbes Strategy Development 0 08-05-2008 08:57 AM
how can I add extra conditions? Juanca Strategy Development 6 04-03-2008 01:26 AM
Same Conditions, Different Results jeremymgp Strategy Development 1 02-08-2008 04:07 AM


All times are GMT -6. The time now is 09:55 PM.