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

CS0103 Issue Yet I Think I Have Already Defined A Variable

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

    CS0103 Issue Yet I Think I Have Already Defined A Variable

    Hi,

    In the following code I am getting a CS0103 Issue for the variables "OrderQuantity" and "OrderQuantityMultiplier" yet I thought I have defined it as a variable on lines 59 and 60 (emphasized in bold below)

    PHP Code:
    //This namespace holds Strategies in this folder and is required. Do not change it. 
    namespace NinjaTrader.NinjaScript.Strategies
    {
        public class 
    OneTradeADayUnlocked Strategy
        
    {
            private 
    EMA EMA1;
            protected 
    override void OnStateChange()
            {
                if (
    State == State.SetDefaults)
                {
                    
    Description                                    = @"Enter the description for your new custom Strategy here.";
                    
    Name                                        "OneTradeADayUnlocked";
                    
    Calculate                                    Calculate.OnEachTick;
                    
    EntriesPerDirection                            1;
                    
    EntryHandling                                EntryHandling.AllEntries;
                    
    IsExitOnSessionCloseStrategy                true;
                    
    ExitOnSessionCloseSeconds                    350;
                    
    IsFillLimitOnTouch                            false;
                    
    MaximumBarsLookBack                            MaximumBarsLookBack.TwoHundredFiftySix;
                    
    OrderFillResolution                            OrderFillResolution.Standard;
                    
    Slippage                                    1;
                    
    StartBehavior                                StartBehavior.WaitUntilFlat;
                    
    TimeInForce                                    TimeInForce.Gtc;
                    
    TraceOrders                                    false;
                    
    RealtimeErrorHandling                        RealtimeErrorHandling.StopCancelClose;
                    
    StopTargetHandling                            StopTargetHandling.PerEntryExecution;
                    
    BarsRequiredToTrade                         20;   

                    
    // Disable this property for performance gains in Strategy Analyzer optimizations
                    // See the Help Guide for additional information
                    
    IsInstantiatedOnEachOptimizationIteration    true;
                    
    StopLoss                    100;
                    
    Target                        10;
                    
    EntryTime                    DateTime.Parse("00:00"System.Globalization.CultureInfo.InvariantCulture);
                    
    OrderQuantity 1;
                    
    OrderQuantityMultiplier 2.0;
                }
                else if (
    State == State.Configure)
                {
                    
    AddDataSeries("ES 09-20"Data.BarsPeriodType.Day1Data.MarketDataType.Last);
                }
                else if (
    State == State.DataLoaded)
                {                
                    
    EMA1                EMA(Close20);
                    
    SetStopLoss(""CalculationMode.TicksStopLossfalse);
                    
    SetProfitTarget(""CalculationMode.TicksTarget);
                }
            }

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

                if (
    CurrentBars[0] < 1)
                    return;

                 
    // Set 1
                
    if ((Times[0][0].TimeOfDay > new TimeSpan(000))
                     && (
    Close[0] < Open[0])
                     && (
    Times[0][0].TimeOfDay < new TimeSpan(400))
                     && (
    Close[0] < EMA1[0]))
                {
                    
    int orderQuantity OrderQuantity;

                    if( 
    SystemPerformance.AllTrades.Count )
                        if( 
    SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count-1].ProfitTicks // last trade is a loss
                            
    orderQuantity Math.Max(1Convert.ToInt32(orderQuantity OrderQuantityMultiplier));

                    
    EnterLongLimit(orderQuantity, (Low[0] + (TickSize)) ,"") ;

                }

            }

            
    #region Properties
            
    [NinjaScriptProperty]
            [
    Range(1int.MaxValue)]
            [
    Display(Name="StopLoss"Order=1GroupName="Parameters")]
            public 
    int StopLoss
            
    getset; }

            [
    NinjaScriptProperty]
            [
    Range(1int.MaxValue)]
            [
    Display(Name="Target"Order=2GroupName="Parameters")]
            public 
    int Target
            
    getset; }

            [
    NinjaScriptProperty]
            [
    PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
            [
    Display(Name="EntryTime"Order=3GroupName="Parameters")]
            public 
    DateTime EntryTime
            
    getset; }
            
    #endregion

        
    }

    Many thanks

    #2
    Hello, thanks for your question.

    I do not see any definition for these two:

    OrderQuantity
    OrderQuantityMultiplier

    Please make sure there is a public property set up for these two variables.

    Code:
    #region Properties
            [NinjaScriptProperty]
            [Range(1, double.MaxValue)]
            [Display(Name="OrderQuantity", Order=4, GroupName="Parameters")]
            public double OrderQuantity
            { get; set; }
    
            [NinjaScriptProperty]
            [Range(1, double.MaxValue)]
            [Display(Name="OrderQuantityMultiplier", Order=5, GroupName="Parameters")]
            public double OrderQuantityMultiplier
            { get; set; }

    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by morrnel, Today, 06:07 PM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by thumper57, Yesterday, 04:30 PM
    6 responses
    19 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by sastrades, 05-10-2024, 09:59 AM
    3 responses
    54 views
    0 likes
    Last Post rc5781
    by rc5781
     
    Started by guyonabuffalo, Yesterday, 10:01 PM
    2 responses
    20 views
    0 likes
    Last Post guyonabuffalo  
    Started by reynoldsn, 05-10-2024, 07:04 PM
    5 responses
    27 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X