Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Switching between long & short positions with X number of counter-tendency bars

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

    Switching between long & short positions with X number of counter-tendency bars

    Good day, great people!

    I'm looking to backtest a strategy that I'm not being able to actually program. I'm using Strategy Builder on a demo account for now, and I would prefer not to unlock code (except if it's needed for what I want to accomplish).

    I would love to have some guidance to make the program enter a short position (closing all the current long orders) if X number of bearish candles appear, and entering in a long position (closing all the current short orders) if X number of bullish candles appear. And it's very important that the configuration adapts to my own chart settings (I clarify this in case this is not done by default: I think it should do that, but I'm not absolutely sure about it).

    I'll look forward to any tips. Thank you so much in advance for your time and effort!

    #2
    Hello Yasharandom,

    Thank you for your inquiry.

    You could create a custom series to use as an event counter. The event in this case would be detecting a bullish (or bearish) candle. You may need two custom series to count these two separate events.

    The forum post linked below has an example script demonstrating using a series to count an event. The event counted is when a fast moving average crosses above a slow.

    Is there a way to increment an int in the strategy builder? When I go to set an int equal to itself there's no way to add 1 to it as well. Just wondering if this is possible in the wizard.


    Please let us know if you have any further questions.

    Comment


      #3
      Hello, Gaby.

      Alright, I'll do so if I need further help. Thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      29 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      46 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      38 views
      0 likes
      Last Post CarlTrading  
      Working...
      X