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

RemoveDrawObject is not stable

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

    RemoveDrawObject is not stable

    Hi,

    In my indicator, I often have to remove labels, due to a setup being no longer valid.. I do this by having an object populate a list of tags for each setup. Then when that setup is no longer valid, I set a flag in the object so that the indicator can do a search for all setup objects with a flag that indicates for all the label tags to be deleted. In the following code example, I store the labellist and the flag in a struct.

    Below is the code.

    The reason I know its not stable is because if i click on Reload ninjascript, some of the labels for certain setups are removed and some are not. I hit the reload again, and a different set of setups have removed labels, so its rather random..

    Anyway , here is code:
    Code:
    List<SBRSetup> Disqualified_Setup_Longs = SBrSetupCollectionLongs.SSetups.FindAll(x => x.LabelList.FlaggedtoDeleteTradeLabels_Targets == true );
    			
    			foreach (SBRSetup SS_L in Disqualified_Setup_Longs)
    			{
    				SS_L.LabelList.FlaggedtoDeleteTradeLabels_Targets = false;
    				foreach (string DrawObject_Tag in SS_L.LabelList.SetupInfo)
    				{
    					RemoveDrawObject(DrawObject_Tag);
    				}
    				SS_L.LabelList.TradeDisqualifyInfo.Clear();				
    			}

    #2
    Hello KhaosTrader, and thank you for your report.

    While developing and debugging is beyond the scope of the support we may provide, I would like to suggest that if you are simply wanting to store a list of tags that are flagged or not flagged for deletion, a System.Collections.Generic.Dictionary<string, bool> may do the job. You will want to store this as a private variable, and initialize it during State == State.SetDefaults, should you decide as the developer to take this approach. Dictionaries have an ICollection<T> member called Keys which will let you loop over all the tags. You would then be able to set or retrieve an individual DrawObject_Tag's FlaggedtoDeleteTradeLabels_Targets values like this :

    Code:
    // set
    Disqualified_Setup_Longs[DrawObject_Tag] = true;
    // retrieve
    Print(Disqualified_Setup_Longs[DrawObject_Tag]);
    This is simply a suggestion. Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hi, thank you for your suggestion, but the way i do it now is that I have a set of tags for each setup, and i flag the setup (which there are many) that specifically needs its drawings deleted, then i iterate through all the setups list of tags.. Is this not a good way? shouldnt this work also?

      Comment


        #4
        Your approach would definitely work, and would have some advantages over the approach I recommended, since you could store more information than a simple boolean flag this way in each node member. My goal was only to provide one method to simplify the code on your end to the point where we could rule out anything occurring with your code, since you mentioned a difference in operation caused by a refresh. Currently it is difficult to tell the cause of this behavior, and we will not easily be able to tell if a flaw in NinjaTrader is causing this, or if this is the way the code is designed to operate on your end.
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jclose, Today, 09:37 PM
        0 responses
        5 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,413 views
        0 likes
        Last Post Traderontheroad  
        Started by firefoxforum12, Today, 08:53 PM
        0 responses
        11 views
        0 likes
        Last Post firefoxforum12  
        Started by stafe, Today, 08:34 PM
        0 responses
        11 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by sastrades, 01-31-2024, 10:19 PM
        11 responses
        169 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X