Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to let a cell in the Market Analyzer compare two variables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to let a cell in the Market Analyzer compare two variables

    Currently the market analyzer can only compare a variable to a constant (fixed number) in each column. I believe that the Market Analyzer cannot compare two variables within one cell due to two main issues:

    The user may accidently create a infinite loop (Column A calling Column B, and then Column B calling Column A)

    The fields are probably currently propagated in a simple linear loop. (pretend its a 1 dimensional array instead of a 2d array.)
    for(x=0; x<=datafield.length(); x++)
    datafield.calculateBox[x];

    If the user was allowed to call another column, they could end up nesting the first real data to draw from 20 or so columns deep.
    Ex: Column 1 calls a variable in column 2, and the variable in column 2 calls a variable in column 3, then the variable in column 3 calls a variable in column 4..... .... which calls an actual number in column 20.

    the way to fix get around this is to: (very rough p-code)

    *test for infinite loops while the user is coding it

    *turn the simple linear loop into something like this:
    int BoxesCompleted=0;
    int BoxesToComplete = datafield.length();
    int Runs=0;
    int MaxRuns=10;
    Do
    {

    for(x=0; x<=datafield.length(); x++)
    {
    if ( the comparison is to a pre-establised or previously calculated figure) && (the box is not already calculated)
    datafield.calculateBox[x];
    BoxesCompleted++;
    }
    Runs++;

    }
    while(Runs<=MaxRuns && BoxesCompleted<BoxesToComplete);



    // you guys could limit the number of runs to 2 if you so wanted, or you could make it nearly unlimited but warn the user how many runs it will take to complete and that it will slow down the program

    You could do a recursive algorithm with a stack or que, which may be faster (but not by much), but this should be the simplest way to implement this new feature.

    for reference sake here is the original issue:

    Last edited by chris8sirhc; 04-19-2012, 12:45 PM. Reason: better p code

    #2
    Hi chris8sirhc,

    Thanks for the feedback. It's not currently possible to modify the framework to allow for multi-value filters, but I will forward your comments to our development team for consideration in a future release.

    You can do a lot more working with a NinjaScript indicator. A common approach is setting a plot value of 1 when your condition is true and 0 otherwise. The condition within the indicator script can have any level of complexity you want within the indicator, accessing multiple values if needed.
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by traderqz, Yesterday, 12:06 AM
    11 responses
    27 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by PaulMohn, Today, 03:49 AM
    0 responses
    7 views
    0 likes
    Last Post PaulMohn  
    Started by inanazsocial, Today, 01:15 AM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by rocketman7, Today, 02:12 AM
    0 responses
    10 views
    0 likes
    Last Post rocketman7  
    Started by dustydbayer, Today, 01:59 AM
    0 responses
    4 views
    0 likes
    Last Post dustydbayer  
    Working...
    X