Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

error code cs1513

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

    error code cs1513

    please advise on the error code in the header regarding this code

    region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Strategy;
    using NinjaTrader.NinjaScript.Indicators;
    #endregion

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class MyStrategy : Strategy
    {
    region Inputs
    [Description("Linear Regression Period")]
    [GridCategory("Parameters")]
    public int RegressionPeriod { get; set; }

    [Description("ADL Period")]
    [GridCategory("Parameters")]
    public int ADLPeriod { get; set; }

    [Description("SMA Period 1")]
    [GridCategory("Parameters")]
    public int SMAPeriod1 { get; set; }

    [Description("SMA Period 2")]
    [GridCategory("Parameters")]
    public int SMAPeriod2 { get; set; }

    [Description("Stop Loss")]
    [GridCategory("Parameters")]
    public double StopLoss { get; set; }

    [Description("Take Profit")]
    [GridCategory("Parameters")]
    public double TakeProfit { get; set; }
    #endregion

    region Variables
    private LinearRegression LinearReg;
    private ADL ADL;
    private SMA SMA1;
    private SMA SMA2;
    private double entryPrice = 0;
    private bool stopLossMoved = false;
    private DateTime stopLossTime = DateTime.MinValue;
    #endregion

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "MyStrategy";
    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.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;

    // Set the default values for the inputs
    RegressionPeriod = 200;
    ADLPeriod = 14;
    SMAPeriod1 = 21;
    SMAPeriod2 = 13;
    StopLoss = 500;
    TakeProfit = 2000;
    }
    else if (State == State.Configure)
    {
    // Add the indicators to the chart
    LinearReg = LinearRegression(RegressionPeriod);
    ADL = ADL(ADLPeriod);
    SMA1 = SMA(SMAPeriod1);
    SMA2 = SMA(SMAPeriod2);
    AddChartIndicator(LinearReg);
    AddChartIndicator(ADL);
    AddChartIndicator(SMA1);
    AddChartIndicator(SMA2);
    }
    }

    protected override void OnBarUpdate()
    {
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    if (Close[0] > LinearReg[0]​

    #2
    the simple error pertains to this

    if (Position.MarketPosition == MarketPosition.Flat)
    {
    if (Close[0] > LinearReg[0])
    {
    // Place buy order
    entryPrice = Close[0];
    EnterLong();
    }
    else if (Close[0] < LinearReg[0])
    {
    // Place sell order
    entryPrice = Close[0];
    EnterShort();
    }
    }​

    Comment


      #3
      Hello hdge4u,

      The error indicates there is a missing curly brace.

      Below is a link to the help guide.


      Ensure every opening curly brace has a closing curly brace and every closing curly brace has an opening curly brace.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      62 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      134 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X