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;
                            
                          [COLOR=Red]  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};
    
    }
    [/COLOR]
    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.


    As well as a link to an early simple example.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    135 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X