Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error in State.SetDefault

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

    Error in State.SetDefault

    Hi dear support,

    please help me to fix an error:

    I added objects in State.SetDefault to use "sub menů property" (set colors).



    This is the code:

    Code:
    if (State == State.SetDefaults)
                        {
                            Description                    = @"Multi Time Frame Impulse Strategy";
                            Name                        = "NTT01";
                            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;
                            
                            ColorTF1Variables            = new ColorTF1() { BrushTF1up = Brushes.LightGreen, BrushTF1dw = Brushes.LightPink, BrushTF1fl = Brushes.LightYellow};
                            ColorTF2Variables            = new ColorTF2() { BrushTF2up = Brushes.Green, BrushTF2dw = Brushes.Red};
                            ColorTF3Variables            = new ColorTF3() { BrushTF3up = Brushes.Blue, BrushTF3dw = Brushes.Magenta};
    
    }
    
    It work perfectly but if I charge the startegy in the chart (on or off) and "Compile" in the editor (compile without errors), the strategy stay active in the tab_startegy but desappear from chart.

    This after compile:



    If I try to "enable" from tab_strategy I get the following error.






    I test that the problem come from the 3 object "ColorTf1/2/3Variables" becouse if I cancel them there is no error.

    Can you help me please?
    Thanks

    #2
    Hello ClauTrade,

    Likely you are creating your own custom classes.

    This falls into general C# and is not specific to NinjaScript.

    However, it is possible to create a custom class and have this be a property by using type converters.

    Below is a link to a reference sample that demonstrates type converters.
    https://ninjatrader.com/support/foru...ad.php?t=97919

    As well as a link to an early simple example.
    https://ninjatrader.com/support/foru...289#post494289
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bjgjkhjuhgtybg, Today, 04:38 AM
    0 responses
    2 views
    0 likes
    Last Post bjgjkhjuhgtybg  
    Started by varun12343, Today, 03:09 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Marco  
    Started by Lance El Camino, Yesterday, 04:14 PM
    2 responses
    24 views
    0 likes
    Last Post NT-Roland  
    Started by MatthewLesko, Yesterday, 11:13 PM
    1 response
    14 views
    0 likes
    Last Post NT-Roland  
    Started by kevinenergy, Today, 01:44 AM
    0 responses
    7 views
    0 likes
    Last Post kevinenergy  
    Working...
    X