Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Correct argument passing, CrossBelow, Stochastics

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

    Correct argument passing, CrossBelow, Stochastics

    Hello support,

    I am developing a custom indicator and keep hitting a brick wall .
    Could you clarify the arguments for CrossBelow(); please?

    This won't work:
    if(CrossBelow(Stochastics(3,14,7).K[0],Stochastics(3,14,7).D[0],0)) SScrossDown=true; // test1

    it simply won't compile, something about overload methods and arguments, and yet this WILL compile:

    if (CrossBelow(EMA(20),Stochastics(3,14,7).D[0],0)) SScrossDown=true; // test2

    and so will this:
    if (CrossBelow(Stochastics(3,14,7).K[0],EMA(20),0)) SScrossDown=true; // test3

    and this works OK too:
    if (CrossBelow(EMA(10),EMA(20),0)) SScrossDown=true; // test4

    Note that as far as the documentation for V6.5 (and I am using V6.5.1000.1 with .NET V2.0.50727.42) is concerned both of the first two arguments for CrossBelow can be either IDataSeries or numeric so all of the above examples should work including test1.

    Is it a bug in NinjaTrader software? Or am I missing something after all?

    Ideally I would like to be able to do the following:
    // ideal code fragment
    double StochVal=Stochastics(3,14,7).K[0];
    double StochMA=Stochastics(3,14,7).D[0];
    if (CrossBelow(StochVal,StockMA,0)) SScrossDown=true;

    because this way I can call Stochastic only twice and then use the results in the rest of my code many times over. But I can't use the above code fragment because it doesn't compile either!

    Any help much appreciated,
    MarkB

    #2
    Hi MarkB,

    If you bring up the Help Guide in NT6.5 the proper syntax are only these:

    CrossBelow(IDataSeries series1, double value, int lookBackPeriod)
    CrossBelow(IDataSeries series1, IDataSeries series2, int lookBackPeriod)

    You cannot do double value on double value. Also you would generally leave the lookBackPeriod to be 1.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hello Josh,

      Correct me if I am wrong:

      the function call Stochastics(3,14,7);
      returns an IDataSeries type
      whereas
      the function call Stochastics(3,14,7).D[0];
      returns a Double type

      is this correct?

      That would then explain why the two arguments I was passing-in were both Double and therefore why the CrossBelow() wasn't compiling.

      The second part to the question is:
      If Stochastics(3,14,7); returns the IDataSeries type (in effect a pointer to an array that holds the values which then get plotted as a line), then is that a pointer to the K line or the D line array? And if it is (say) the K line, how do I get the pointer for the D?

      Much appreciate having this cleared up, thanks MarkBN

      Comment


        #4
        Originally posted by MarkBN View Post
        Hello Josh,

        Correct me if I am wrong:

        the function call Stochastics(3,14,7);
        returns an IDataSeries type
        whereas
        the function call Stochastics(3,14,7).D[0];
        returns a Double type

        is this correct?
        Your understanding is correct.


        Originally posted by MarkBN View Post
        The second part to the question is:
        If Stochastics(3,14,7); returns the IDataSeries type (in effect a pointer to an array that holds the values which then get plotted as a line), then is that a pointer to the K line or the D line array? And if it is (say) the K line, how do I get the pointer for the D?

        Much appreciate having this cleared up, thanks MarkBN
        Syntax
        Stochastics(int periodD, int periodK, int smooth)
        Stochastics(IDataSeries inputData, int periodD, int periodK, int smooth)
        Returns %D value
        Stochastics(int periodD, int periodK, int smooth).D[int barsAgo]
        Stochastics(IDataSeries inputData, int periodD, int periodK, int smooth).D[int barsAgo]
        Returns %K value
        Stochastics(int periodD, int periodK, int smooth).K[int barsAgo]
        Stochastics(IDataSeries inputData, int periodD, int periodK, int smooth).K[int barsAgo]
        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by quantismo, 04-17-2024, 05:13 PM
        4 responses
        30 views
        0 likes
        Last Post quantismo  
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        31 views
        0 likes
        Last Post love2code2trade  
        Started by cls71, Today, 04:45 AM
        2 responses
        10 views
        0 likes
        Last Post eDanny
        by eDanny
         
        Started by proptrade13, Today, 11:06 AM
        0 responses
        5 views
        0 likes
        Last Post proptrade13  
        Started by kulwinder73, Today, 10:31 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X