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

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 Waxavi, Today, 02:10 AM
    0 responses
    3 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Started by TradeForge, Today, 02:09 AM
    0 responses
    9 views
    0 likes
    Last Post TradeForge  
    Started by Waxavi, Today, 02:00 AM
    0 responses
    2 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Started by elirion, Today, 01:36 AM
    0 responses
    4 views
    0 likes
    Last Post elirion
    by elirion
     
    Started by gentlebenthebear, Today, 01:30 AM
    0 responses
    4 views
    0 likes
    Last Post gentlebenthebear  
    Working...
    X