Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Overriding error

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

    Overriding error

    Hello

    First of all, I would like to say that I am an absolute beginner in ninjascript coding...
    I am currently in the learning phase and I need a little help with a problem that I don't know how to solve...
    I get an error when compiling ninjascript, it is probably an error in the object overriding and I don't know how to solve the problem...

    I have defined a range using
    private Series<double> MySeries;

    next I create an object
    MySeries = new Series<double>(this);

    then I specify a condition on this object that will hold the difference
    close - open of the current candle

    MySeries[0] = Close[0] - Open[0];

    and I would like to create a something like this
    if (
    MySeries[0] >2 * StdDev( MySeries[0] )[0]
    )


    but every time I try to compile the script, I get an error related to overriding..
    Once again I apologize for the beginner's question and thank you very much for any help..
    I would like to understand at least the basic logic of how to create ninjascript and where I am making a mistake..

    #2
    Hi Lejczek, thanks for posting. The initialization of MySeries should be:
    MySeries = new Series<double>(this, MaximumBarsLookBack.Infinite);

    If this does not resolve, please post a screen shot of the code and the compile error and I will have a look at it.

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Have a nice day Chris
      Thank you very much for your quick reply
      I tried to apply your fix, unfortunately I am getting the same overriding error CS502 CS503..
      In attachement I send my simple code..
      I would like to understand where the error is, so I can learn something and know how to solve similar problem
      Thank You again very much for your time and your help
      Attached Files

      Comment


        #4
        Hi Lejczek, the StdDev function had invalid arguments. It needs a Series and a Period. Something like this will work:
        StdDev(MySeries, 3)[0]

        Kind regards,
        -ChrisL
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Have a nice day ChrisL

          Thank you very much for your advice !
          The code compiles without problems and helped me to understand where the error is..
          I would like to ask one more thing..
          I would like to get the average range of the certain numbers of bar again using iSeries.
          I have again a similar code

          private Series<double> MySeries;
          MySeries = new Series<double>(this, MaximumBarsLookBack.Infinite);
          MySeries[0] = High[0] - Low[0];
          if (MySeries[0] > SMA(MySeries, 20)[0])
          .....

          I am not sure if using SMA() function to get the average value over a few numbers is the most appropriate or there is a better solution ...
          Thank you again very much for any help





          Comment


            #6
            Hi Lejczek, thanks for the follow up. Using the SMA would be the best method to take an average of a series. The code you posted looks good to me. Make sure to test it out.

            Kind regards,
            -ChrisL
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hi Chris
              Big thanks for your support and help !
              I will continue my study of ninjascript and if I don't know something I will write
              Have a nice day



              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Brevo, Today, 01:45 AM
              0 responses
              1 view
              0 likes
              Last Post Brevo
              by Brevo
               
              Started by aussugardefender, Today, 01:07 AM
              0 responses
              3 views
              0 likes
              Last Post aussugardefender  
              Started by pvincent, 06-23-2022, 12:53 PM
              14 responses
              238 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              9 responses
              384 views
              1 like
              Last Post Gavini
              by Gavini
               
              Started by oviejo, Today, 12:28 AM
              0 responses
              4 views
              0 likes
              Last Post oviejo
              by oviejo
               
              Working...
              X