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!
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
NinjaTrader
Unexpected error " #endregion directive expected"
Collapse
X
-
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. -
-
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
-
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 PostHi, 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 wzgy0920, 04-20-2024, 06:09 PM
|
2 responses
27 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:43 PM
|
||
Started by wzgy0920, 02-22-2024, 01:11 AM
|
5 responses
32 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:33 PM
|
||
Started by wzgy0920, 04-23-2024, 09:53 PM
|
2 responses
49 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:29 PM
|
||
Started by Kensonprib, 04-28-2021, 10:11 AM
|
5 responses
193 views
0 likes
|
Last Post
by Hasadafa
Yesterday, 10:19 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
11 responses
3,235 views
0 likes
|
Last Post Yesterday, 08:07 PM |
Comment