Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy builder dollar cost average

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

    Strategy builder dollar cost average

    Is there a way to use DCA in the strategy builder? I can add multiple entries, but they do not merge with current position price. They just act as separate entires. Trying to get the entries to function like manually trading. Say you are long at 2000 with one contract, price moves to 1000, you double down. Now your average entry price is 1500 for 2 contracts. Can the SB be configured to function that way?

    #2
    Hello Touch-Ups,

    Thanks for your post.

    It sounds like you are wanting to scale in or out of a position. Scaling in or out of a position is controlled with the signal names of your strategy, and properties EntryHandling and EntriesPerDirection.

    To scale in, you would give your entry order a Signal Name, such as "Long Entry 1". Then, when you want to submit another order you would call your entry order method and set it to use the same Signal Name, "Long Entry 1", to have the order being submitted scale into that position.

    If you set Entry Handling to EntryHandling.AllEntries, NinjaScript will process all entry order methods up to the maximum allowable entries set in the EntriesPerDirection property. For example, if you set EntriesPerDirection to 3 and use EntryHandling.AllEntries, up to a total of 3 entry orders will process.

    If you set Entry Handling to EntryHandling.UniqueEntries, NinjaScript will process order entry methods up to the maximum allowable entries set by the EntriesPerDirection property for each uniquely named entry. For example, if you have two entry order methods using unique signal names ("entry1" and "entry2"), set EntriesPerDirection to 3, and use EntryHandling.UniqueEntries, a maximum number of 3 entry orders will process for each uniquely named entry order (up to 3 orders for "entry1" and 3 orders for "entry2").​

    See the help guide documentation below for more information.

    EntryHandling: https://ninjatrader.com/support/help...ryhandling.htm
    EntriesPerDirection: https://ninjatrader.com/support/help...rdirection.htm
    Entering a Market Position: https://ninjatrader.com/support/help...MarketPosition
    Exiting a Market Position: https://ninjatrader.com/support/help...MarketPosition

    This reference sample can help with scaling in and out of a strategy.
    https://ninjatrader.com/suppport/helpGuides/nt8/en-us/scaling_out_of_a_position.htm

    This sample can assist further with managing multiple exit/entry signals:
    https://ninjatrader.com/support/helpGuides/nt8/en-us/using_multiple_entry_exit_sign.htm
    <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


      #3
      I am using several entry methods all set up under signal name "longs" with a defined profit and stop in "Stops and Targets" section. For this example, I only set entries to 2 to illustrate what is happening. In the screenshot, you can see the 2 entries, but the exits are different. I am wanting the entry prices to combine (average up/down) and the stop/target to be redefined per "Stops and Targets" set. Basically, just like manually trading when you double down (or keep adding contracts). The stops and targets should dynamic as you add/remove contracts. ThanksClick image for larger version

Name:	double.jpg
Views:	351
Size:	113.3 KB
ID:	1262339

      Comment


        #4
        Hello Touch-Ups,

        Thanks for your notes.

        When using Set methods like SetProfitTarget() and SetStopLoss(), the stop will be placed a set distance away from the entry order. This means that if you are placing 2 entry orders at different prices, the Stop Loss placed by SetStopLoss() will place an exit at two different prices.

        You could try modifying the custom logic in your script to use Exit methods (such as ExitLongLimit()/ExitLongStopLimit()) for your protective orders instead of using Set methods (SetProfitTarget()/SetStopLoss()) so that the second Exit order method uses the same SignalName and FromEntrySignal as the first Exit order method.

        Note that to keep the Exit orders alive, you will need to unlock the script from the Strategy Builder and manually program your script to use the isLiveUntilCanceled overload for Exit methods.

        For example: ExitLongStopLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, double stopPrice, string signalName, string fromEntrySignal)

        From the Managed Approach help guide: "By default, orders submitted via Entry() and Exit() methods automatically cancel at the end of a bar if not re-submitted"

        Managed Approach: https://ninjatrader.com/support/help...d_approach.htm
        Conditions: https://ninjatrader.com/support/help...on_builder.htm
        Action: https://ninjatrader.com/support/help...t8/actions.htm

        Here is a reference sample demonstrating keeping orders alive: https://ninjatrader.com/support/help...ders_alive.htm
        <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
        52 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 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
        48 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X