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 2,536 views
    2. thumb_up 4 thanks given
    3. group 2 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

conditional logic using a set of values as determinant

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

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?
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Deepmoney LLM
Elite Quantitative GenAI/LLM
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
Battlestations: Show us your trading desks!
24 thanks
The Program
17 thanks
  #2 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: RTY
Posts: 682 since Jun 2009
Thanks Given: 756
Thanks Received: 787


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,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,532


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 Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: RTY
Posts: 682 since Jun 2009
Thanks Given: 756
Thanks Received: 787


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: 485 since Jun 2009
Thanks Given: 232
Thanks Received: 415


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: 485 since Jun 2009
Thanks Given: 232
Thanks Received: 415


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: 485 since Jun 2009
Thanks Given: 232
Thanks Received: 415


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
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: RTY
Posts: 682 since Jun 2009
Thanks Given: 756
Thanks Received: 787


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: 485 since Jun 2009
Thanks Given: 232
Thanks Received: 415



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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts