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

strategy not compiling in strategy builder

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

    strategy not compiling in strategy builder

    Hi, i built a strategy with a 3rd party indicator in strategy builder, however it does not compile. Other indicators from this 3rd party company works but some other ones do not, so i dont know if i need to edit the code so it can compile. ill have the code below. Thanks.










    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class test : Strategy
    {
    private NinjaTrader.NinjaScript.Indicators.MBoxWaveXE.MGan nSwing MGannSwing1;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "test";
    Calculate = Calculate.OnBarClose;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    TP = 30;
    SL = 10;
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    MGannSwing1 = MGannSwing(Close);
    SetProfitTarget("", CalculationMode.Ticks, TP);
    SetStopLoss("", CalculationMode.Ticks, SL, false);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (CrossAbove(MGannSwing1.WaveDeltaVolume, 0, 1))
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    }


    #2
    Hello ishcan,

    Thank you for your post.

    I don't see anything obvious here that would trigger a compile error. As you are using a third party indicator, I would suggest reaching out to the vendor to confirm this indicator may be used in a strategy and if they have any tips on how it needs to be set up to do so.

    Please let us know if we may be of further assistance to you.

    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi, thanks for the reply, im getting the error

      No overload for method 'MGannSwing' takes 1 arguments

      Comment


        #4
        Hello ishcan,

        Thank you for your reply.

        It's very possible the Strategy Builder is not capable of calling the indicator because it can't correctly set the parameters to call it. I would reach out to the vendor to confirm.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          i managed to get a bit of it fixed but now getting a different error. code will be bellow its saying The Name 'initMGannSwing' does not exist in the current context

          namespace NinjaTrader.NinjaScript.Strategies
          {
          public class MApiMGannSwingStrategy : Strategy
          {
          Indicators.MBoxWaveXE.MGannSwing myWave;

          protected override void OnStateChange()
          {
          // Initialize myWave using MGannSwing
          initMGannSwing
          (
          // Reference to myWave
          ref myWave,

          // Swing Size: Enter an integer
          2,

          // Compute Algorithmic Signals: None, All
          AlgoSelected.All,

          // Algo Filter: None, Smart, TrendFollowing, Countertrend};
          AlgoFilter.Smart,

          // Delta Type (Choose only one, comment the rest)
          DeltaTypeEnum.MBoxPrecisionDelta
          //DeltaTypeEnum.BidAsk
          //DeltaTypeEnum.UpDownTick
          //DeltaTypeEnum.Psuedo
          );

          if (State == State.SetDefaults)
          Calculate = Calculate.OnEachTick;
          }

          protected override void OnBarUpdate()
          {
          // Only process main data series
          if (BarsInProgress != 0) return;

          // Wait for at least 100 bars before doing anything
          if (CurrentBar < 100) return;

          // This is required to sync with our indicator instance
          myWave.Update();

          // Get Wave Swing Index for last 5 waves
          int SI0 = 0;
          int SI1 = SI0 + myWave.getWidth(SI0);
          int SI2 = SI1 + myWave.getWidth(SI1);
          int SI3 = SI2 + myWave.getWidth(SI2);
          int SI4 = SI3 + myWave.getWidth(SI3);

          // Get Wave Direction for last 5 waves
          int WD0 = myWave.getSwing(SI1) * -1;
          int WD1 = myWave.getSwing(SI1);
          int WD2 = myWave.getSwing(SI2);
          int WD3 = myWave.getSwing(SI3);
          int WD4 = myWave.getSwing(SI4);

          // Get Total Wave Volume for last 5 waves
          double TV0 = myWave.getVolume(SI0);
          double TV1 = myWave.getVolume(SI1);
          double TV2 = myWave.getVolume(SI2);
          double TV3 = myWave.getVolume(SI3);
          double TV4 = myWave.getVolume(SI4);

          // Get Delta Wave Volume for last 5 waves
          double DV0 = myWave.getDeltaVolume(SI0);
          double DV1 = myWave.getDeltaVolume(SI1);
          double DV2 = myWave.getDeltaVolume(SI2);
          double DV3 = myWave.getDeltaVolume(SI3);
          double DV4 = myWave.getDeltaVolume(SI4);

          // NOTE ABOUT WAVE CONFIRMATION
          // WAVE 0 is always unconfirmed since it is drawn in real time

          // WAVE 1 may or may not be confirmed depending if there are
          // 2 higher highs / 2 lower lows, that is if swing size is 2.
          // In this case myWave.wave1Confirmed is a bool, and shows
          // if WAVE 1 is confirmed or not

          // WAVE 2 and greater are always confirmed

          Print("###### WAVE 0 ######");
          Print("Direction: " + WD0);
          Print("Delta Volume: " + DV0);
          Print("Wave Confirmed: False");

          Print("###### WAVE 1 ######");
          Print("Direction: " + WD1);
          Print("Delta Volume: " + DV1);
          Print("Wave Confirmed: " + myWave.wave1Confirmed);

          // Wave 2 and greater are always confirmed
          Print("###### WAVE 2 ######");
          Print("Direction: " + WD2);
          Print("Delta Volume: " + DV2);
          Print("Wave Confirmed: True");

          Print("###### WAVE 3 ######");
          Print("Direction: " + WD3);
          Print("Delta Volume: " + DV3);
          Print("Wave Confirmed: True");

          Print("###### WAVE 4 ######");
          Print("Direction: " + WD4);
          Print("Delta Volume: " + DV4);
          Print("Wave Confirmed: True");

          // Set 1
          if (CrossAbove(myWave, 0, 1))
          {
          BackBrushAll = Brushes.CornflowerBlue;
          }

          }

          #region Properties
          [NinjaScriptProperty]
          [Range(1, double.MaxValue)]
          [Display(Name="Gaan", Order=1, GroupName="Parameters")]
          public double Gaan
          { get; set; }
          #endregion

          }
          }

          Comment


            #6
            Hello ishcan,

            Thank you for your reply.

            The following code would not be valid to call an indicator, nor would in OnStateChange before State == State.DataLoaded be the place to instantiate it:

            // Initialize myWave using MGannSwing
            initMGannSwing
            (
            // Reference to myWave
            ref myWave,

            // Swing Size: Enter an integer
            2,

            // Compute Algorithmic Signals: None, All
            AlgoSelected.All,

            // Algo Filter: None, Smart, TrendFollowing, Countertrend};
            AlgoFilter.Smart,

            // Delta Type (Choose only one, comment the rest)
            DeltaTypeEnum.MBoxPrecisionDelta
            //DeltaTypeEnum.BidAsk
            //DeltaTypeEnum.UpDownTick
            //DeltaTypeEnum.Psuedo
            );

            I would highly suggest reaching out to the vendor to get assistance with this, as I have no idea what parameters in what order should be supplied to the indicator, since I don't have that particular indicator on my end, but indicators would be called as the Strategy Builder has set up in the original code you posted. It's just likely the parameters the strategy builder is supplying to the indicator aren't correct.

            MGannSwing1 = MGannSwing(/* you likely need different parameters here */);

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by wzgy0920, 02-22-2024, 01:11 AM
            5 responses
            32 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, Yesterday, 09:53 PM
            2 responses
            49 views
            0 likes
            Last Post wzgy0920  
            Started by Kensonprib, 04-28-2021, 10:11 AM
            5 responses
            191 views
            0 likes
            Last Post Hasadafa  
            Started by GussJ, 03-04-2020, 03:11 PM
            11 responses
            3,230 views
            0 likes
            Last Post xiinteractive  
            Started by andrewtrades, Today, 04:57 PM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X