Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to make an action valid also for the following bars

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

    How to make an action valid also for the following bars

    Hello.

    This is probably a very simple problem, but I can't think of a solution. In the strategy builder, the condition and action tab, how can I set a defined action to be valid not only when conditions are met, but also for the next following bars? Something like a trigger.

    Thak you.

    #2
    Hello Bonifac,

    Thank you for the post.

    One way that I could see this being done would be to use a group condition and user variable. I will explain this at a high level in the steps below, please let me know if I need to provide more detail on any of the steps.
    1. Create a bool user variable with a default of false
    2. In set 1, select if Any of the conditions are met
    3. Click Group and create a group condition
    4. Select if All of the conditions are met and then define your conditions.
    5. Complete your conditions and go back to the main Set 1 page
    6. Create another condition, As the condition, check if the user variable is equal to true: User variable / equals / Misc -> true.
    7. In the conditions action, do your action and also set the user variable to true.

    What this is doing is first checking your condition. If that is true it continues and sets the user variable. Now on another bar if your condition is no longer true but the user variable was set, it should proceed with the condition because we are using if any of the conditions are true between your normal conditions or the bool variable.

    Later when you no longer want this to happen, you would set the user variable to false, likely from another condition.


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

    Comment


      #3
      Thank you for your advice. I followed your instructions but somewhere is still a mistake. I'm sending you pictures of two different situations to illustrate. Both don't work by my imagination ...

      I'll be grateful for further help.
      Attached Files

      Comment


        #4
        Hello Bonifac,

        I have attached a simple script which shows continuing a condition. I am unable to tell from your images where the problem is, however I do see you have multiple conditions setting the variable to true so that will complicate the question. I would suggest trying something similar to what this sample demonstrates, or defining a single condition that draws a dot to highlight where the condition is and is not true.

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

        Comment


          #5
          Thank you for your link. I already understand this logic. Is there any way to preserve the price level of drawn dots for the following bars? You know, your script says: "When SMA 10 crosses SMA 20, draw a dot at the CLOSE of EACH BAR." But my goal is: when SMA 10 crosses SMA 20, draw a dot at the close price, and for each following bar draw a dot on the same price.

          In general: if something happens, paint the dots at each bar still at the same price level. That's my intention.

          Thak you.

          Comment


            #6
            Hello Bonifac,

            Thank you for the reply.

            This description is different than what your question was, so this requires a different solution.

            What you are now asking requires different logic, lets break down what you are wanting to do:
            • When SMA 10 crosses SMA 20,
            A first set could be used to check this condition and set a price which will be used later. This also marks the start of the sequence so a UserVariable can be used here similar to the other sample to be set to true or false.
            1. You would need to create a bool variable and a double variable.
            2. Set the bool variable to true in this conditions action
            3. Set the double variable to the price you want the dot drawn at in this conditions action.
            • draw a dot at the CLOSE of EACH BAR." But my goal is: when SMA 10 crosses SMA 20, draw a dot at the close price, and for each following bar draw a dot on the same price.

            In a second set
            1. Check that the bool variable is true
            2. If so, as the action draw the dot.
            3. For the dots price, use the double variable that you had created which is set to the close price which was stored in set 1.

            In a third set, you can reset the bool variable to false when the dot should no longer be drawn.

            Set 1 will be checking that your condition became true and setting up the price and trigger. The second set checks for the trigger and applies the dot at the specified price.


            I look forward to being of further assistance.

            JesseNinjaTrader Customer Service

            Comment


              #7
              Thank you for your care but I'm still doing something wrong. I'm sorry, I'm a newbie builder.

              Let's try to set the following simple model situation. High [0] > High [1]. Draw a dot on Low [1] - price level X. And for each subsequent bar, draw a dot on the same "trigger" price X. I tried to set the proper bool and double variables, but every time the conditions are met again, the double price will change as well.

              Thank you for your assistance and I apologize for my programming illiteracy ...

              Comment


                #8
                Hello Bonifac,

                Can you provide the script or images of what you tried?

                From the description it sounds like something simple is probably missing here, but I would need to see what you tried to understand what is wrong.


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

                Comment


                  #9
                  Thank you for your answer. For a demonstration, I send a photo of a very simple situation. My goal: if the condition is met, draw a dot at the same price for each bar.

                  So as the situation is defined in the picture, the dots are drawn according to my intention, but only until the conditions are met again. This will then change the double price. So how can I specify that further fulfillment of the conditions be ignored and the double price will still be the same from the first fulfillment of the condition until the end of the day or session?

                  Thank you!
                  Attached Files

                  Comment


                    #10
                    Hello Bonifac,

                    but only until the conditions are met again.
                    Yes, what I had previously described would do this. You had not mentioned doing this one time only as being a requirement previously.

                    If you just want to set the price one time and always use that, you could make another condition/variable for that purpose.

                    Keeping the sets you have now, you could insert a new set between set 1 and 2 making the newly created set, set 2.

                    Add a new bool user variable called DoOnce
                    In set 1 when the condition becomes true, set the VariableDefaultFalse to true, remove setting the price from set 1
                    In set 2, check if VariableDefaultFalse is true also check if DoOnce is false, make sure if all conditions are met is used
                    In set 2's action, set the price to the variable
                    In set 2's action, set the DoOnce to true
                    In set 3, do the drawing in the same way you were before.

                    In set 2, if the DoOnce has not previously been set by Set2, it will happen one time and set DoOnce to true. The next time around when DoOnce is true the condition to set the price wont happen.


                    I look forward to being of fruiterer assistance.



                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Thank you very much. Now it works almost right. The last problem I have with resetting the conditions at the end of the day. I can't use the condition "when the first bar session = true, then user variables = false" because at least 3 bars of the session are required to meet the conditions. I could add a time condition, but this is not a very practical solution to me due to the alternation of the time frame and also due to the different date of change of winter and summer time in my country.

                      Do you think of any other solution? Something like
                      "if current bar =
                      first bar of session
                      or first bar of session + 1
                      (or first bar of session + 2 etc. )".

                      But the builder does not allow this setting. In general, I'm looking for a way to set a certain number of first bars of session. I hope I explained it understandably...

                      Thank you, I appreciate your help.

                      Comment


                        #12
                        Hello Bonifac,

                        In the builder you can only check if the first bar of session is true or false, so storing a value or counting like this would not be possible.

                        When you say that you cant reset on the first bar of session because you need at least 3 bars to meet the condition, do you mean to meet your condition to set the user variables? The first bar of session should be able to be used without any relation to your other condition, or to just reset some variables if needed. If your other conditions start working after 3 bars after the start of session, resetting on the session should work.

                        Otherwise likely a time condition would be next in line for the reset, but would have the problems you mentioned.


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

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by algospoke, Yesterday, 06:40 PM
                        2 responses
                        19 views
                        0 likes
                        Last Post algospoke  
                        Started by ghoul, Today, 06:02 PM
                        3 responses
                        14 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by jeronymite, 04-12-2024, 04:26 PM
                        3 responses
                        45 views
                        0 likes
                        Last Post jeronymite  
                        Started by Barry Milan, Yesterday, 10:35 PM
                        7 responses
                        20 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by AttiM, 02-14-2024, 05:20 PM
                        10 responses
                        181 views
                        0 likes
                        Last Post jeronymite  
                        Working...
                        X