Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Build issue

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

    Strategy Build issue

    Hi ,
    I have below code which compiled succussfully and created DLL ,But if i try to create new indicator with same code it is giving complilation issue. Can u help me to solve.
    Last edited by shankar.deshapande; Yesterday, 08:32 AM.

    #2
    Hello shankar.deshapande,

    Thanks for your post.

    Are you having an issue with a strategy or an indicator?

    It looks like you are trying to add a Series in the same way a plot is used. Please see our AddPlot documentation for creating plots and assigning plot values. You can also use a New NinjaScript Wizard to have plots added to the script for you, and you can view the resulting syntax.

    AddPlot - https://ninjatrader.com/support/help...t8/addplot.htm

    New NinjaScript Wizards - https://ninjatrader.com/support/help.../ns_wizard.htm

    There are also several other syntax errors reported that would need to be corrected. If code was copied, it is possible that the code was copied improperly without minding curly braces. I suggest reviewing each line that is reported with errors and to check the syntax on that line. It can also help to build some simple logic with the Strategy Builder and to practice implementing it in a hard coded script if you are new to programming.

    Publicly available information on C# can be found here - https://www.tutorialspoint.com/csharp/index.htm

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      hi,
      thanks for reply . What is difference between plot and series ?. Attached is full source code. It also give error with NinjaScriptBase
      Last edited by shankar.deshapande; Yesterday, 08:27 AM.

      Comment


        #4
        Where did your original indicator come from?
        Did you try disassemble that indicator?
        Are you trying to use the disassembled indicator as the basis for a new indicator?

        I've looked at your attached code and I can't imagine why a human would write
        NinjaScript in that way ...

        Your compilation errors are a matter of simple programming issues.

        Comment


          #5
          Hello shankar.deshapande,

          A Series<T> is a collection of variables where one variable exists for each bar in the data series.

          Series<T> - https://ninjatrader.com/support/help...8/?seriest.htm

          A Plot uses a Series<double> to hold plot values in the Values array. If you have a look at our open source indicators, you may see that a public Series<double> is available that pulls from Values. This is to give other scripts that host this indicator a common name to work with, so they do not have to reference "Values[0][0]".

          The code provided does not look very familiar with NinjaScripts that are commonly written and the syntax errors will need to be corrected before the script can be usable. I suggest taking a step back and getting more familiar with existing indicators and how they are written so it is is clearer on how the C#/NinjaScript code should be written. You may reference our open source indicators as well as scripts that users have shared on our User App Share for further direction. Publicly available information on C# can help to understand compile error meaning as well.

          https://ninjatraderecosystem.com/user-app-share/

          The link above is publicly available.

          The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.


          We look forward to assisting.
          JimNinjaTrader Customer Service

          Comment


            #6
            Hi ,
            How can i replace (NinjaTrader.NinjaScript.NinjaScript) this) with alternative or can you please help me to compile above code succesfully

            Comment


              #7
              Hello shankar.deshapande,

              This code is hardly human readable. I suggest taking a step back from whatever you are attempting, and try to write the indicator cleanly, with an understanding on how to create your own indicators.

              If you are not familiar with NinjaScript development, you could consider following the NinjaTrader 7 tutorials and then review the Code Breaking Changes for NinjaTrader 8. This usually gives new developers a clear path to learning indicator development.

              NinjaTrader 7 tutorials - https://ninjatrader.com/support/help...indicators.htm

              NinjaTrader 8 Code Breaking Changes - https://ninjatrader.com/support/help...ng_changes.htm
              JimNinjaTrader Customer Service

              Comment


                #8
                I just need to compile above file successfully and I should be able to see long stop and short stop in strategy.

                Comment


                  #9
                  Hi ,
                  i have indiactor working fine but if i use in strategy as below
                  trendV1 = Volare_SuperTrendv1(BarsArray[0], 22, 11, true);
                  trendV1 = Volare_SuperTrendv1( 22, 11, true);

                  but i get error like Volare_SuperTrendv1 is a type but used like variable . This strategy has Longstop and shortstop variable but i am not able to use in strategy.Can u please tell me how to use this?

                  Comment


                    #10
                    Hi,
                    Why does NT8 generates this code with input as parameter :
                    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                    {
                    private STV1NEWIND[] cacheSTV1NEWIND;
                    public STV1NEWIND STV1NEWIND(int period, double multi, bool enableWicks)
                    {
                    return STV1NEWIND(Input, period, multi, enableWicks);
                    }

                    public STV1NEWIND STV1NEWIND(ISeries<double> input, int period, double multi, bool enableWicks)
                    {
                    if (cacheSTV1NEWIND != null)
                    for (int idx = 0; idx < cacheSTV1NEWIND.Length; idx++)
                    if (cacheSTV1NEWIND[idx] != null && cacheSTV1NEWIND[idx].Period == period && cacheSTV1NEWIND[idx].Multi == multi && cacheSTV1NEWIND[idx].EnableWicks == enableWicks && cacheSTV1NEWIND[idx].EqualsInput(input))
                    return cacheSTV1NEWIND[idx];
                    return CacheIndicator<STV1NEWIND>(new STV1NEWIND(){ Period = period, Multi = multi, EnableWicks = enableWicks }, input, ref cacheSTV1NEWIND);
                    }
                    }

                    ===========================

                    Indicator works fine and plot well on chart but when i call through strategy with below code it give runtime error as below

                    "Strategy 'STV1Strategy': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object."

                    When i debugged my strtegy i found that
                    i call it through strategy by using this code but it internally calls overloed method which don't have input object

                    try{
                    stv1newind= STV1NEWIND(22,1,true);
                    }catch(Exception ex)
                    {
                    Print("Exception="+ex.ToString());
                    }

                    So how to solve this?

                    Comment


                      #11
                      After debugging i found out that issues is with array series
                      i am pring indicator values in indicator as :
                      Print(string.Format("{0};{1};{2};{3}", Time[0],this.Long_Stop[0],this.Short_Stop[0],"STVV1NEWIND"));
                      but the same values if i print from strategy it is not getting these values for Long_stop and Short_stop

                      Below is properties code in indicator :
                      [XmlIgnore]
                      [Browsable(false)]
                      // public Series<double> Long_Stop => this.get_Values()[0];
                      public Series<double> Long_Stop {
                      get {return Values[0];}
                      }

                      [XmlIgnore]
                      [Browsable(false)]
                      // public Series<double> Short_Stop => this.get_Values()[1];
                      public Series<double> Short_Stop {
                      get {return Values[1];
                      }
                      }


                      How can i get these values in strategy?

                      Comment


                        #12
                        Hello shankar.deshapande,

                        // Decompiled with JetBrains decompiler
                        We will not assist you with decompiled code and thus will not answer further questions in this topic.

                        Further threads requesting assistance to build scripts which have been decompiled may lead to a ban from the forums.

                        Thanks for your understanding.
                        Last edited by NinjaTrader_Jim; Yesterday, 06:07 AM.
                        JimNinjaTrader Customer Service

                        Comment


                          #13
                          Hi,
                          Attached is source code which i written myself and generated indicator ,so now i need to call in startegy.
                          Print(string.Format("{0};{1};{2};{3}",Time[0],stv1newind.Long_Stop.Count>0 ,stv1newind.Short_Stop.Count>0 ,"STV1Strategy"));

                          if(stv1newind.Long_Stop.Count>0 )
                          Print(string.Format("{0};{1};",Time[0],stv1newind.Long_Stop[0]));

                          if(stv1newind.Short_Stop.Count>0 )
                          Print(string.Format("{0};{1};",Time[0],stv1newind.Short_Stop[0]));

                          even though i am printing count but stil it give below error.

                          23/02/2021 04:35:00;True;True;STV1Strategy
                          Strategy 'STV1Strategy': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
                          line 1
                          Attached Files
                          Last edited by shankar.deshapande; Yesterday, 08:36 AM.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by MatthewLesko, 02-01-2021, 07:50 AM
                          5 responses
                          111 views
                          0 likes
                          Last Post marcus2300  
                          Started by kabott, Today, 03:17 AM
                          0 responses
                          1 view
                          0 likes
                          Last Post kabott
                          by kabott
                           
                          Started by azuul, Today, 01:49 AM
                          1 response
                          12 views
                          0 likes
                          Last Post azuul
                          by azuul
                           
                          Started by rtwave, Yesterday, 11:52 PM
                          0 responses
                          3 views
                          0 likes
                          Last Post rtwave
                          by rtwave
                           
                          Started by tgn55, Yesterday, 09:51 PM
                          0 responses
                          3 views
                          0 likes
                          Last Post tgn55
                          by tgn55
                           
                          Working...
                          X