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

What am I doing wrong ?

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

    What am I doing wrong ?

    Hello NinjaTrader7 support,..

    I'm trying to code and indicator. I dont want to plot it but I want it to be re-used again and again so its a kind of function.

    I have created a DataSeries called fastK and I'm setting it up as follows.

    Code:
    double curC = Close[0];
    
    
    
                double var0= MIN(Close,40)[0];
                double var1 = MAX(High,40)[0];
                double var2 = curC - var0;
                double var3 = var1-var0;
    
                if (var3>0)
                {
                    fastK.Set( var2 / var3 * 100);
                }
                else
                {
                    fastK.Set(0);    
                }
    
    
            }
    
            #region Properties
            [Browsable(false)]
            [XmlIgnore()]
            public DataSeries fastK
            {
            get {return fastK;}
            }
            #endregion
    In variables section I declared private DataSeries fastK;
    and at Initialize() method i write fastK = new DataSeries(this);

    now the problem is, as u can see, I want that fastK to be exposed for another indicators. so i try make it public in #region Properties section. but I get an error that

    Indicator\fastKCustom.cs The type 'NinjaTrader.Indicator.fastKCustom' already contains a definition for 'fastK' CS0102 - click for info 70 21

    What am i doing wrong ??

    Thanks, And also How can i get average of this same indicator while i using it in another indicator ? (plz help i m not able to do things easily in ninja)

    Regards

    #2
    The actual EasyLanguage code for that fastKCustom function is as follows..
    Code:
    inputs: 
        PriceValueH( numericseries ),  
        PriceValueL( numericseries ), 
        PriceValueC( numericseries ), 
        StochLen( numericsimple ) ;
    
    variables: 
        var0( 0 ),               
        var1( 0 ),                 
        var2( 0 ),              
        var3( 0 ) ;                
    
    var0 = Lowest( PriceValueL, StochLen ) ;
    var1 = Highest( PriceValueH, StochLen ) ;
    var2 = PriceValueC - var0 ;
    var3 = var1 - var0 ;
    
    if var3 > 0 then
        FastKCustom = var2 / var3 * 100 
    else 
        FastKCustom = 0 ;
    Where current high, low, close and stochastic length is passed from other indicators , which i hardcoded as i dont know how to do things with ninja C#. I'm learning it again...

    Comment


      #3
      Hello hsrad,

      Thanks for your post and welcome to the forums!

      The compiler is advising that you cannot create a both a public and a private data series with the same name: fastK. In this case I would suggest changing the public name to be FastK (C# would recognize FastK and fastK as two different variables).

      You can use other indicators with an indicator or strategy by calling the class name and providing the parameters, for example:

      OnBarUpdate()
      {

      double test = SMA(High, 20)[0]; // assign the current value of a 20 period simple moving average of the High data series

      double test1 = Bollinger(2, 14).Upper[0]; // assign the current value of the upper plot of the bollinger line

      }


      You may want to spend some time reviewing the NT7 help guide and work through a couple of tutorials in there. Here are some good links:



      You can also find helpful information in these tips and examples:


      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Thanks Paul,

        Seems like it solved the problem.

        Somehow i managed to get it worked the way u suggested. I will need to check on live data stream about its efficiency. Thanks again...

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DayTradingDEMON, Today, 09:28 AM
        2 responses
        15 views
        0 likes
        Last Post DayTradingDEMON  
        Started by Stanfillirenfro, Today, 07:23 AM
        8 responses
        23 views
        0 likes
        Last Post Stanfillirenfro  
        Started by navyguy06, Today, 09:28 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        8 responses
        32 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by helpwanted, Today, 03:06 AM
        2 responses
        22 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Working...
        X