• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unexpected error " #endregion directive expected"

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

    Unexpected error " #endregion directive expected"

    I am getting the above error when I try and compile my code. I have been thou it several times and cant find a #region without a #endregion. In total I have 7 regions. Its also refers to the error on line 752 when my code only has 748 lines?? Why would this be happening.

    #2
    Problem solved. Error went away when I corrected other compile errors.

    Comment


      #3
      Thanks for letting us know. Yes NT will always compile all your files, so could be also sometimes an issue in a non related file.
      BertrandNinjaTrader Customer Service

      Comment


        #4
        Hi, I am getting the following error with the code below, can you please let me know what to change?

        CS1038 #endregion-Direktive erwartet (enregion rirective expected)

        //
        // Copyright (C) 2015, NinjaTrader LLC <www.ninjatrader.com>.
        // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
        //
        #region Using declarations
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.ComponentModel.DataAnnotations;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;
        using System.Windows;
        using System.Windows.Input;
        using System.Windows.Media;
        using System.Xml.Serialization;
        using NinjaTrader.Cbi;
        using NinjaTrader.Gui;
        using NinjaTrader.Gui.Chart;
        using NinjaTrader.Gui.SuperDom;
        using NinjaTrader.Data;
        using NinjaTrader.NinjaScript;
        using NinjaTrader.Core.FloatingPoint;
        using NinjaTrader.NinjaScript.Indicators;
        using NinjaTrader.NinjaScript.DrawingTools;
        #endregion

        // This namespace holds all strategies and is required. Do not change it.
        namespace NinjaTrader.NinjaScript.Strategies
        {
        public class SamplePnL : Strategy
        {
        privateint maxprofit = 1000; // Max profit before halt strategy
        privateint maxloss = 1500; // Max loss before halt strategy

        protected override void OnStateChange()
        {
        if (State == State.SetDefaults)
        {
        Description = @"Using trade performance statistics for money management";
        Name = "Sample PnL";
        Calculate = Calculate.OnBarClose;
        EntriesPerDirection = 2;
        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.StopCancelClose;
        StopTargetHandling = StopTargetHandling.PerEntryExecution;
        BarsRequiredToTrade = 5;
        }

        }

        protectedoverridevoid OnBarUpdate()
        {

        // Only run on real-time data
        if (Historical)
        return;

        if (Performance.AllTrades.TradesPerformance.Currency. CumProfit<-maxloss ||
        Performance.AllTrades.TradesPerformance.Currency.C umProfit>maxprofit)

        #region Properties

        [Description("Maximum profit.")]
        [Category("Parameters")]
        [Gui.Design.DisplayName("\t\t\tMax Profit")]
        publicint MaxProfit
        {
        get { return maxprofit; }
        set { maxprofit = Math.Max(1, value); }
        }

        [Description("Maximum loss (enter positive value!).")]
        [Category("Parameters")]
        [Gui.Design.DisplayName("\t\t\tMax Loss")]
        publicint MaxLoss
        {
        get { return maxloss; }
        set { maxloss = Math.Max(1, value); }
        }
        }
        }
        }

        Comment


          #5

          Hi Tiger,

          You declared a region,
          #region Properties, but no #endregion. So just add an #endregion after the end of the properties section or remove the #region Properties


          Originally posted by CelticTiger View Post
          Hi, I am getting the following error with the code below, can you please let me know what to change?

          CS1038 #endregion-Direktive erwartet (enregion rirective expected)

          //
          // Copyright (C) 2015, NinjaTrader LLC <www.ninjatrader.com>.
          // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
          //
          #region Using declarations
          using System;
          using System.Collections.Generic;
          using System.ComponentModel;
          using System.ComponentModel.DataAnnotations;
          using System.Linq;
          using System.Text;
          using System.Threading.Tasks;
          using System.Windows;
          using System.Windows.Input;
          using System.Windows.Media;
          using System.Xml.Serialization;
          using NinjaTrader.Cbi;
          using NinjaTrader.Gui;
          using NinjaTrader.Gui.Chart;
          using NinjaTrader.Gui.SuperDom;
          using NinjaTrader.Data;
          using NinjaTrader.NinjaScript;
          using NinjaTrader.Core.FloatingPoint;
          using NinjaTrader.NinjaScript.Indicators;
          using NinjaTrader.NinjaScript.DrawingTools;
          #endregion

          // This namespace holds all strategies and is required. Do not change it.
          namespace NinjaTrader.NinjaScript.Strategies
          {
          public class SamplePnL : Strategy
          {
          privateint maxprofit = 1000; // Max profit before halt strategy
          privateint maxloss = 1500; // Max loss before halt strategy

          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Description = @"Using trade performance statistics for money management";
          Name = "Sample PnL";
          Calculate = Calculate.OnBarClose;
          EntriesPerDirection = 2;
          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.StopCancelClose;
          StopTargetHandling = StopTargetHandling.PerEntryExecution;
          BarsRequiredToTrade = 5;
          }

          }

          protectedoverridevoid OnBarUpdate()
          {

          // Only run on real-time data
          if (Historical)
          return;

          if (Performance.AllTrades.TradesPerformance.Currency. CumProfit<-maxloss ||
          Performance.AllTrades.TradesPerformance.Currency.C umProfit>maxprofit)

          #region Properties

          [Description("Maximum profit.")]
          [Category("Parameters")]
          [Gui.Design.DisplayName("\t\t\tMax Profit")]
          publicint MaxProfit
          {
          get { return maxprofit; }
          set { maxprofit = Math.Max(1, value); }
          }

          [Description("Maximum loss (enter positive value!).")]
          [Category("Parameters")]
          [Gui.Design.DisplayName("\t\t\tMax Loss")]
          publicint MaxLoss
          {
          get { return maxloss; }
          set { maxloss = Math.Max(1, value); }
          }
          }
          }

          #endregion
          }


          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by saltminer, Today, 05:19 PM
          0 responses
          3 views
          0 likes
          Last Post saltminer  
          Started by martyn73, Today, 04:18 PM
          0 responses
          2 views
          0 likes
          Last Post martyn73  
          Started by aprendiz, Today, 03:42 PM
          0 responses
          2 views
          0 likes
          Last Post aprendiz  
          Started by 1001111, Today, 09:10 AM
          1 response
          18 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Started by usero86, Today, 06:02 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Working...
          X