Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy uses 2 conditions

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

    Strategy uses 2 conditions

    Hi,
    I'm trying to setup a strategy to wait for a macd cross and price to close past 2 sma lines. Can they be setup in the same set in strategy builder or does it need to be 2 sets, and do they have to be in any certain order? Thanks

    #2
    Hello Clevchin,

    If both of of those conditions need to be together, for example the macd cross AND close past 2 sma lines then that would go in a single set. Each set is evaluated independently so anything that should go together generally is in one set and anything that needs to operate separately would go in multiple sets.

    Comment


      #3
      Thanks. If I send screen shots would it possible to tell if I set them up right. I think I did, but I'm new to builder.

      Comment


        #4
        Hello Clevchin,

        You can attach a screenshot and we can go over what that code would be doing. To really know if it works right you will still need to test the strategy and make sure that is the result you wanted. You can test the strategy on the sim account or a demo account while developing the strategy to make sure its working as you wish.

        Comment


          #5
          Great. Here's a few screen shots. Click image for larger version

Name:	Input and Variables.png
Views:	53
Size:	79.9 KB
ID:	1310911 Click image for larger version

Name:	ema set1.png
Views:	52
Size:	148.4 KB
ID:	1310912 Click image for larger version

Name:	ema set2.png
Views:	51
Size:	159.0 KB
ID:	1310913 Click image for larger version

Name:	mac set2.png
Views:	50
Size:	202.7 KB
ID:	1310914 Click image for larger version

Name:	mac set1.png
Views:	53
Size:	204.3 KB
ID:	1310915

          Comment


            #6
            Hello Clevchin,

            I don't see anything obviously wrong in the images, when you run the strategy does it produce trades in the locations where you had wanted it to?

            Comment


              #7
              It does enter when I think from what I can tell. Does the builder go in order like in the sets it has the macd cross first and is that how that orders look to get placed? The mac d crossed and then price corsses the ema and thats when the order gets placed? Also how close does it have to be together for it to take the trade from what the screen shots show. Sometimes it looks like it should enter but I think the price crossing it to far away.
              .

              Comment


                #8
                Hello Clevchin,

                The sets in the builder do go in order, so set 1 will be checked before set 2 and so on. The conditions inside each set also go in order however those are controlled by the dropdown list at the top of the set that says if Any or if All. Depending on that setting the set could work in two different ways. If you are using if All that requires all the conditions in the set to be true at the same time. If you use if any that means if any one of the conditions in the set is true the whole set is true.

                For what you are describing the macd would need to cross in the same event as the price crossing the ema. If they are becoming true on different bars then that set won't be true.

                The question here would be are you trying to submit an order when both the macd and ema conditions are true at the exact same time or were you trying to do something where if the macd condition is true that enables a second set to check for a later time when the ema cross condition becomes true?

                Comment


                  #9
                  I would like to enter a trade when the macd crosses and the price closes past the ema either on the same candle as the macd cross or the candle right after.

                  Comment


                    #10
                    Hello Clevchin,

                    As long as those two conditions are in the same set then it would require them to happen in the same candle. To do anything else like the candle after would require using multiple sets and a variable. You would essentially just use the macd set to toggle a variable to true and then in a second set check if the variable is true and also if the ema crossed over, if so submit the order. That variable would need to be reset also when you submit the order so it can repeat that process again later.

                    Comment


                      #11
                      Is that able to be done in the builder, or would it require coding to set and reset the variable? Thanks

                      Comment


                        #12
                        Hello Clevchin,

                        Yes that is something you could do in the builder. Variables can be created in the inputs and variables screen where you configured the inputs. A bool variable would be how to make a true/false variable.

                        Comment


                          #13
                          Ok I'll try putting that together tomorrow as I'm heading out. If I have more questions can i respond again to this thread? Thanks

                          Comment


                            #14
                            Hello Clevchin,

                            Yes if you needed to follow up on this topic we can discuss that here. If you have new unrelated questions please make a new thread for those to keep them seperate.

                            Comment


                              #15
                              Click image for larger version

Name:	Set 3 for Longs.png
Views:	45
Size:	236.6 KB
ID:	1311034 Click image for larger version

Name:	Set 2 for Shorts.png
Views:	36
Size:	250.8 KB
ID:	1311035 Click image for larger version

Name:	Set 4 for Shorts.png
Views:	34
Size:	237.0 KB
ID:	1311036 Click image for larger version

Name:	Set 1 for Longs.png
Views:	37
Size:	257.0 KB
ID:	1311037Here's what I put together so far. I added to variables. one for if macd crosses up and one if macd crosses down. Both are set for true. I also broke up the sets. How far off am I and I also wasn't sure how to get it to reset after triggering it. Thanks

                              Comment

                              Latest Posts

                              Collapse

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