Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Conditions trigger a Share, how to keep it from spamming?

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

    Conditions trigger a Share, how to keep it from spamming?

    Hello!

    I have a Set of conditions that triggers a share service. The connection is working, but it spams. While the strategy only takes 1 position, it triggers constant shares as long as it is in a position.

    I am currently using strategy builder for at least one more aspect of this project before unlocking it. Is it possible to have one share per position in strategy builder? I have tried many ideas, none solved the problem. Either no share or constant shares.

    If this can't be done in the wizard, what can I try with the code unlocked?

    Thank you!

    #2
    Hello trilliantrader,

    Thanks for your post.

    If the action is being triggered then this means that the condition to trigger that action is becoming true multiple times.

    You could add debugging prints to the script to confirm how the condition is behaving.

    See the "Debugging with the Strategy Builder" video on this Support article for information about using prints to understand behavior: https://support.ninjatrader.com/s/ar...nd-TraceOrders

    Something you could consider is using a bool to control when the action triggers.

    You could create a bool in the Inputs and Variables screen of the Strategy Builder (initially set to true), check if the bool is true in your condition to trigger the Share() method or SendMail() method, and set the bool to false in the actions section after calling Share() or SendMail(). By doing so, the Share() or SendMail() method would only be called when that bool is true.

    Note that you will need to flip the bool back to true at some point in the script or it will remain false. For example, the bool could be flipped back to true when you are in a Flat market position by checking if Position.MarketPosition == MarketPosition.Flat and setting the bool to true.

    See the help guide documentation below for more information.

    Builder Screens: https://ninjatrader.com/support/help...er_screens.htm
    Conditions: https://ninjatrader.com/support/help...on_builder.htm
    Actions: https://ninjatrader.com/support/help...t8/actions.htm
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      This all makes sense to me, but the bool does not keep the trigger from posting repeatedly. I have stripped everything out except for this function and it instantly starts spamming and sending copies of the same message despite the bool or sends nothing at all. I'm completely stumped.

      Free image hosting and sharing service, upload pictures, photo host. Offers integration solutions for uploading images to forums.

      Free image hosting and sharing service, upload pictures, photo host. Offers integration solutions for uploading images to forums.
      Last edited by trilliantrader; 04-12-2024, 07:55 AM.

      Comment


        #4
        Hello trilliantrader,

        In the conditions of Set 1, require OkToPost to be false.
        Click add to add another condition to the set. Select User variables > OkToPost, in the center select Equals as the operator, on the right select Misc -> False.

        The OkToPost variable is set to false by default on the Inputs and Variables page, is this correct?

        Then when the entry is submitted, the bool being set to true will keep this condition set from evaluating as true which prevents the actions from being repeated.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Then when the entry is submitted, the bool being set to true will keep this condition set from evaluating as true which prevents the actions from being repeated.
          Can you repeat this like I'm 5?

          I've noticed now that this script is not sharing at all. Should the bool be set to tru or false by default? I have tried both without getting a result.

          Comment


            #6
            Hello trilliantrader,

            I made a video to try and help clarify.


            If the condition in your script was comparing OkToPost to be false, you would want the default value for the bool to be false.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              This is EXACTLY how I have my bool for the share set up, but it posts multiple times a second. I have even used only this bool, the share service, and a simple enter if flat strategy.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Today, 05:17 AM
              0 responses
              53 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              130 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              70 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              44 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              49 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X