Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

One trade then flip flop?

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

    One trade then flip flop?

    Hey all,

    Back with another issue. I found a script in the forums for a flip flop condition, it works well for what I need but I would like to see if I can refine it. This is strictly for the strategy builder as my coding is lacking.

    I have a trend type indicator that I would like to buy when up, take profit, and then wait until the opposite signal to sell when down. I only want to be able to make one trade per direction. Is this possible in the builder?

    Example of sorts - TSSupertrend - when it turns green, buy, take profit at X$/ticks/%, and then "reset" until it turns red and then sell, take profit, and then wait for it to go the other direction. I also found a flip flop that "exits" when the opposite happens but I want to use TP and SL.

    Any ideas?

    #2
    Hello sprks7979,

    Thanks for your post.

    Yes, it would be possible to have a Strategy Builder strategy place one trade per direction.

    A bool could be used to control when trades are made by the strategy. You could create a bool named something like OkToTrade (initially set to false). You would create your order entry condition and set the bool to true. Then you would check if the bool is true and call your entry order method and set the bool to false.

    By doing this, the order entry method will only be called to place an order when the bool is true. When the bool is false, the order entry condition will not be called so the strategy will stop placing trades until the bool becomes true.

    See the attached example script demonstrating using a bool to control trades made by a strategy.

    Let me know if I may assist further.​
    Attached Files
    <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

    Latest Posts

    Collapse

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