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

Stop Print

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

    Stop Print

    Hello,

    is somehow possible to stop Print when condition is true? My goal is to reduce Print statements.

    Thank you.

    #2
    Hello emuns,

    This would be up to the logic your script.

    If the condition is true, do not call Print() in the code.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      that´s the problem. I need to use: when condition is true - Print something. But than I need something like: when condition change stop printing or print just x rows etc.
      If I understand it correctly, nothing like this can be used, so I have to deal with the situation on condition itself...?

      Thank you
      Last edited by emuns; 02-21-2020, 08:54 AM.

      Comment


        #4
        Hello emuns,

        Right, you would need to deal with this in your logic if you want to stop the print.

        As long as you are calling the Print command it will happen. If that should be reduced or not happen you would need to call it less or not at all. You could add variables or other logic to control that better if you want but that is going to be up to your logic.

        If you are trying to only see a print when the condition changes or want to control it based on condition changes you might be able to do that using a bool:




        Code:
        private bool printOnce = false;
        protected override void OnBarUpdate()
        {
            if(CrossAbove(SMA(12), SMA(16), 1))
            {
                printOnce = true;
            }
            else if(CrossBelow(SMA(12), SMA(16), 1))
            {
                printOnce = true;
            }
            if(printOnce == true)
            {
                Print("Print one time because one of the conditions was true");
                printOnce = false;
            }
        }

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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Tim-c, Today, 02:10 PM
        0 responses
        1 view
        0 likes
        Last Post Tim-c
        by Tim-c
         
        Started by cre8able, Today, 01:16 PM
        2 responses
        9 views
        0 likes
        Last Post cre8able  
        Started by chbruno, 04-24-2024, 04:10 PM
        3 responses
        48 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by samish18, Today, 01:01 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by WHICKED, Today, 12:56 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X