Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to prevent Longs or Shorts from being opened?

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

    How to prevent Longs or Shorts from being opened?

    Hi, small question here:

    I have a condition of a crossing of 2 EMA, cross above must allow only Long and cross below must allow only short.
    But I can see also Longs are being opened after a cross below and vice versa.
    I also have close short on cross above and a close long on cross below condition built in this. But after the crossing they are still opened when
    other conditions are met.
    Could anyone tell how to solve this? Or how to prevent Longs/Shorts from being opened?

    Looking forward to your answer.
    Regards,
    Lourens

    Click image for larger version

Name:	Schermafbeelding 2024-04-11 131951.png
Views:	89
Size:	12.5 KB
ID:	1299258Click image for larger version

Name:	Schermafbeelding 2024-04-11 131959.png
Views:	77
Size:	12.8 KB
ID:	1299259Click image for larger version

Name:	Schermafbeelding 2024-04-11 132007.png
Views:	75
Size:	12.5 KB
ID:	1299260Click image for larger version

Name:	Schermafbeelding 2024-04-11 132015.png
Views:	76
Size:	12.4 KB
ID:	1299261​​

    #2
    Hello lourensjorna,

    With how you are using variables currently your logic should allow for multiple orders. When the EMA 60 and 80 comparison is done you toggle the long and short bool variables. That will determine which of the entry sets can now work. The entry set will continue to submit new orders any time the other entry conditions are true now that the bool has been toggled. If you only want a single long or short entry you would need to reset the bools back to false in sets 2 and 4.

    I also see that you have potential to submit exit orders and entry orders in the same event which can lead to the strategy becoming out of sync. For example if your Set 1 is true that toggles the bool variable enabling Set 2, if the other conditions in Set 2 are also true that means you have called Exit Short and Enter Long in the same event. If you were already in a short position that would result in a stacked exit meaning it will both exit and reverse the position leading to 2 long positions.

    Comment


      #3
      Hi Jesse,

      Thanks a lot for your reply!
      So maybe removing both the ExitLong and ExitShort would be the best option?
      That way there is no way of becoming out of sync?
      And also, I do would like to have the option that IF the 60/80 cross has happend, upfollowing entries are allowed as long as there is no crossing to the other side.

      Right?

      Looking forward to your reply again!

      Regards,
      Lourens

      Comment


        #4
        Hello lourensjorna,

        If the purpose is a reversal strategy then yes removing the exits would be suggested. An exit should only happen when an enter method is not happening, entry methods will automatically reverse the position if you are in a position in the opposite direction.

        For the entry conditions your bool variables will only be toggled if sets 1 or 3 become true or only for the ema crossing events. The entry conditions can become true any time sets 2 or 4 are true which could be anytime after the crossing event or anytime you have a touching event. As an example any time the set 2 condition low is less than the ema120 and the other two price conditions happen that could place an order at the crossing price of the set 1 condition or anywhere above.

        If you want to see specifically when the crossing conditions happen I would suggest adding another set with no conditions in it and then add a Misc -> Print action and output the bool variables values and the bar times. That will let you see what the bool value was on each bar so you can know why it was placing trades where it did.

        Comment


          #5
          Thanks again for your reply Jesse!
          And that is also a great idea to add, I will start working on it.

          Thanks for your help!

          Regards,
          Lourens

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          54 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          131 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          73 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