NexusFi: Find Your Edge


Home Menu

 





conditional logic using a set of values as determinant


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Saroj with 5 posts (0 thanks)
    2. looks_two RJay with 3 posts (2 thanks)
    3. looks_3 Big Mike with 1 posts (1 thanks)
    4. looks_4 sefstrat with 1 posts (1 thanks)
    1. trending_up 3,321 views
    2. thumb_up 4 thanks given
    3. group 2 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 
Saroj's Avatar
 Saroj 
Arcata, CA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: index futures, oil
Posts: 482 since Jun 2009
Thanks Given: 232
Thanks Received: 416

I've used languages in the past that allowed one to declare a set of values and then do an 'if' statement against that set... for example:

----------------------
procedure_A_ok = [1, 2, 9];
procedure_B_ok = [2, 3, 9];

v1 = 2

If (v1 == procedure_A_ok) Print ("procedure_A_ok");
------------------------

Output window:
procedure_A_ok

Is this construct available in NS/C# ? I couldn't find anything similar in the User doc... but it could be because I don't know what it is called... I did find the multiple case / Switch logic, but I don't really want that.

Thanks!


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The Week Ahead -- CPI Wednesday With Oil Past $90, PPI L …
Traders Hideout
$12M Ceasefire Contract Goes Disputed as Bandar Abbas St …
Prediction Markets & Event Contracts
After $87M Settles NO: Irans Nuclear Redline Sets Up the …
Prediction Markets & Event Contracts
NYSE Owner ICE Invests in Crypto Exchange OKX at $25 Bil …
Cryptocurrency
CFTC Approves First US Bitcoin Perpetual Futures -- Kals …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #2 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 Vendor: www.innovative-trading-solutions-online.com 
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: ES
Posts: 687 since Jun 2009
Thanks Given: 765
Thanks Received: 789


Saroj View Post
I've used languages in the past that allowed one to declare a set of values and then do an 'if' statement against that set... for example:

----------------------
procedure_A_ok = [1, 2, 9];
procedure_B_ok = [2, 3, 9];

v1 = 2

If (v1 == procedure_A_ok) Print ("procedure_A_ok");
------------------------

Output window:
procedure_A_ok

Is this construct available in NS/C# ? I couldn't find anything similar in the User doc... but it could be because I don't know what it is called... I did find the multiple case / Switch logic, but I don't really want that.

Thanks!

Hi Saroj,

I would do something like this,

if (variable1==1 && variable2==2 && variable3==9)v1 == procedure_A_ok;

RJay


Reply With Quote
Thanked by:
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,557


I would use an array or list and check to see if the value exists in the array.

This is from one of my strategies.

 
Code
                            

        
private double NearestAbove()
        {
        
double _retval 0;
            
        
double [] _array = {N28[0], N18[0], N08[0], P18[0], P28[0], P38[0], P48[0], P58[0], P68[0], P78[0], P88[0], PP18[0], PP28[0]};
        
        if (
_array[0] > 0)
            
_retval _array[0];
        else
            return 
0;
        
        for (
int x _array.Length0x--)
        {
            
//Print("Above: x - 1 =" + (x-1).ToString() + ", _array = " + _array[x-1]);
            
if (_array[x-1] > Close[0])
                
_retval _array[x-1];
            
        } 
Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 Vendor: www.innovative-trading-solutions-online.com 
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: ES
Posts: 687 since Jun 2009
Thanks Given: 765
Thanks Received: 789


Big Mike View Post
I would use an array or list and check to see if the value exists in the array.

This is from one of my strategies.

 
Code
                            

        
private double NearestAbove()
        {
        
double _retval 0;
            
        
double [] _array = {N28[0], N18[0], N08[0], P18[0], P28[0], P38[0], P48[0], P58[0], P68[0], P78[0], P88[0], PP18[0], PP28[0]};
        
        if (
_array[0] > 0)
            
_retval _array[0];
        else
            return 
0;
        
        for (
int x _array.Length0x--)
        {
            
//Print("Above: x - 1 =" + (x-1).ToString() + ", _array = " + _array[x-1]);
            
if (_array[x-1] > Close[0])
                
_retval _array[x-1];
            
        } 
Mike

The difference between a real programmer and a guy like me who counts on his fingers.


Reply With Quote
Thanked by:
  #5 (permalink)
 
Saroj's Avatar
 Saroj 
Arcata, CA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: index futures, oil
Posts: 482 since Jun 2009
Thanks Given: 232
Thanks Received: 416


RJay View Post
Hi Saroj,

I would do something like this,

if (variable1==1 && variable2==2 && variable3==9)v1 == procedure_A_ok;

RJay

Thanks, RJay...that's basically what I'm doing except "or" instead of "and"


Started this thread Reply With Quote
  #6 (permalink)
 
Saroj's Avatar
 Saroj 
Arcata, CA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: index futures, oil
Posts: 482 since Jun 2009
Thanks Given: 232
Thanks Received: 416


Big Mike View Post
I would use an array or list and check to see if the value exists in the array.

This is from one of my strategies.

 
Code
                            

        
private double NearestAbove()
        {
        
double _retval 0;
            
        
double [] _array = {N28[0], N18[0], N08[0], P18[0], P28[0], P38[0], P48[0], P58[0], P68[0], P78[0], P88[0], PP18[0], PP28[0]};
        
        if (
_array[0] > 0)
            
_retval _array[0];
        else
            return 
0;
        
        for (
int x _array.Length0x--)
        {
            
//Print("Above: x - 1 =" + (x-1).ToString() + ", _array = " + _array[x-1]);
            
if (_array[x-1] > Close[0])
                
_retval _array[x-1];
            
        } 
Mike

Thanks, Mike... that looks good... another code snippet!


Started this thread Reply With Quote
  #7 (permalink)
 
Saroj's Avatar
 Saroj 
Arcata, CA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: index futures, oil
Posts: 482 since Jun 2009
Thanks Given: 232
Thanks Received: 416


RJay View Post
The difference between a real programmer and a guy like me who counts on his fingers.

LOL... know exactly how you feel.. my problem is that I've used so many different languages in the past... hard to keep straight which is which...


Started this thread Reply With Quote
  #8 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 Vendor: www.innovative-trading-solutions-online.com 
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: ES
Posts: 687 since Jun 2009
Thanks Given: 765
Thanks Received: 789


Saroj View Post
Thanks, RJay...that's basically what I'm doing except "or" instead of "and"

if (variable1==1 || variable2==2 || variable3==9)v1 == procedure_A_ok;


Reply With Quote
  #9 (permalink)
 
sefstrat's Avatar
 sefstrat 
Austin, TX
 
Experience: Advanced
Platform: NT/Matlab
Broker: Interactive Brokers
Trading: FX majors
Posts: 285 since Jun 2009
Thanks Given: 20
Thanks Received: 768

In .net 3.5 you can do this much more elegantly using linq.. too bad we can't use .net 3.5 until the NT7 beta is ready probably in the next year or two


Reply With Quote
Thanked by:
  #10 (permalink)
 
Saroj's Avatar
 Saroj 
Arcata, CA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: index futures, oil
Posts: 482 since Jun 2009
Thanks Given: 232
Thanks Received: 416



sefstrat View Post
In .net 3.5 you can do this much more elegantly using linq.. too bad we can't use .net 3.5 until the NT7 beta is ready probably in the next year or two

hopefully by that time, I'll have a clue about utilizing .net 3.5 or .net anything for that matter..


Started this thread Reply With Quote




Last Updated on October 5, 2009


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts