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

Indicator Properties Reset when Close and Open Ninjatrader for bool variable

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

    Indicator Properties Reset when Close and Open Ninjatrader for bool variable

    Hi ,

    I have a bool variable that can be tick on my indicator.
    By default the bool is on true. Now if i untick the bool on the chart save as default on template , close and reload my ninjatrader the bool comes back to true


    Steps with some screenshot:

    Step 1 Load my indicator for the first time:
    Click image for larger version

Name:	step1.PNG
Views:	222
Size:	737.3 KB
ID:	1156180

    Step 2 : Untick Show only one apply and save as default template

    Click image for larger version

Name:	step2.PNG
Views:	156
Size:	695.6 KB
ID:	1156181



    Step 3 : Close ninjatrader ( saving my chart settings)

    Step 4 : open ninjatrader again and unfortunately the Show only one is back ( enabled aKA tick)


    I am not sure if there is something on the state that i am doing wrong.

    Dummy code that i am doing




    Code:
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "MyCustomIndicator";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    [B]ShowOnlyCountOne=true;[/B]
    
    }
    else if (State == State.Configure)
    {
    }
    }
    
    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    
    if(ShowOnlyCountOne == true) {
    
    Print("Show only one");
    }
    
    
    if(ShowOnlyCountOne == false){
    
    Print("Show all");
    }
    
    
    }
    
    [XmlIgnore()]
    [Display(Name = "Show only one", GroupName = "Drawing", Order = 1)]
    public bool ShowOnlyCountOne
    { get; set; }
    
    }

    Thanks


    #2
    Hello papaoutai,

    Thanks for the post.

    I believe this would be caused because you have the XmlIgnore attribute, that prevents the property from being saved in the templates/workspaces. Please try changing:


    Code:
    [B][XmlIgnore()][/B]
    [Display(Name = "Show only one", GroupName = "Drawing", Order = 1)]
    public bool ShowOnlyCountOne
    { get; set; }
    to

    Code:
    [Display(Name = "Show only one", GroupName = "Drawing", Order = 1)]
    public bool ShowOnlyCountOne
    { get; set; }
    You will need to remove the indicator from where it is applied and re add it for this to take effect.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks you once again Jesse you save my time !!! Works perfectly

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by andrewtrades, Today, 04:57 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      6 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      7 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X