Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trade Exit size doubled

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

    Trade Exit size doubled

    My strategy can take two trades, the first of 4000 and the second of 12000. Upon the entry for the first trade, targets are established for the first and second trades and are directed by the following instructions:
    double targetPoints = Target1Dollars / Trade1Size / Instrument.MasterInstrument.PointValue;
    double targetPrice = e.Order.AverageFillPrice - targetPoints;
    ExitShortLimit(0, true, e.Order.Filled, targetPrice, "Profit", "Sell short #1");

    double deficitPoints = Trade2DeficitDollars / Position.Quantity / Instrument.MasterInstrument.PointValue;
    double nextEntry = e.Order.AverageFillPrice + deficitPoints;
    EnterShortLimit(0, true, Trade2Size, nextEntry, "Sell short #2");

    double deficitPoints = Trade2DeficitDollars / Position.Quantity / Instrument.MasterInstrument.PointValue;
    double nextEntry = e.Order.AverageFillPrice + deficitPoints;
    EnterShortLimit(0, true, Trade2Size, nextEntry, "Sell short #2");

    If the target for the first trade is realized there will be no second trade taken and the target for the second trade is cancelled. If the target for the first trade is not realized but a deficit of $28 is realized then the second trade is taken in accordance with the target of the second trade.
    The variable declarations are as follows:
    Trade1Size = 4000;
    Trade2Size = 12000;

    When the second trade is entered the entries for a short target are directed by the following instructions::
    double deficitPoints = Trade2DeficitDollars / Position.Quantity / Instrument.MasterInstrument.PointValue;
    double nextEntry = e.Order.AverageFillPrice + deficitPoints;
    EnterShortLimit(0, true, Trade2Size, nextEntry, "Sell short #2");

    But what I get is as per the attached screenshot:: https://www.screencast.com/t/uoaNurwUUk

    The quantity for the Exit is twice the value of Trade2Size and I would think that it should be Trade1Size +Trade2Size but I did not want to make a correction until I could understand why it was doubling the quantity..

    I) have attached a copy of my <,cs.>, if needed.
    Attached Files

    #2
    IIIIIIIIIIIIIIIIII forgot to include the screenshot of a chart after First trade entry: https://www.screencast.com/t/QSgq3PSSDyyX

    Comment


      #3
      Hello galsermil,

      Thank you for your posts.

      This is occurring because you are setting the quantities for both the 1st entry and 2nd entry targets to the quantity of the current execution, which would be 12000 each, resulting in the doubled quantity of the second position.

      ExitLongLimit(0, true, e.Order.Filled, targetPrice, "Profit", "Buy #1");
      ExitLongLimit(0, true, e.Order.Filled, targetPrice, "Profit", "Buy #2");

      You've got a couple options here, but the easiest would be to use Trade1Size for the Buy #1 or Sell Short #1 quantity instead:

      ExitLongLimit(0, true, Trade1Size, targetPrice, "Profit", "Buy #1");
      ExitLongLimit(0, true, e.Order.Filled, targetPrice, "Profit", "Buy #2");

      Please let us know if we may be of further assistance to you.

      Comment


        #4
        Kate,

        I am returning to you with a different problem because you are the one that showed me the necessity of inserting in OnBarUpdate the following clip to prevent :trades and color changes being created from history::

        if(State != State.realtime)
        return

        I am including two screenshots to illustrate what happens when I first enable the strategy: and do not have the clip inserted
        1.) https://www.screencast.com/t/vvQpzNsDA7
        2.) https://www.screencast.com/t/6m75qJBUi
        but when I insert the clip, that solves my startup problem but it gives me problems with colors and existing trades later on as if I am dealing with historical data again and the background colors and the chart trader markings disappear but all of the info will remain in Orders, Executions, and Positions. Can you help me?.

        Comment


          #5
          Hello galsermil,

          Historical processing is a strategy behavior that is used to determine what the strategy position would be in. This is then used by the start behavior to determine how the strategy should start. Act like it is in position, or wait for the next entry signal.

          If you skip historical processing, the strategy will not calculate if it would be in a position. It will always start flat and will not have any historical trades calculated.

          If the strategy calculates it would be in a position, and Wait Until Flat is used, then the strategy will remain yellow indicating that it is waiting for that virtual position to close. (So the first live order submitted by the strategy enters the actual position on your account, instead of starting with an Exit order.)

          Strategies tab (explanation of different colors) - https://ninjatrader.com/support/help...eStrategiesTab

          Strategy vs. Account Position — https://ninjatrader.com/support/help..._account_p.htm

          Start Behaviors — https://ninjatrader.com/support/help..._positions.htm

          We look forward to assisting.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          71 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          143 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          76 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          47 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          51 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X