Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Manually modify an existing Limit Order on the chart

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

    Manually modify an existing Limit Order on the chart

    Hi,

    For an existing strategy I have designed using the Managed Approach, where the strategy automatically sets a Limit order for a Profit target at a predefined ticks distance, I would like to be able to modify the Limit Price Level manually.

    I guess I can modify the Limit Level on the Chart, but I am not sure whether this will screw up the strategy's internal state.

    Basically, the strategy is programmed to detect the fill of the Limit Level it has submitted. Will this work with a manually modified Limit Level?

    If not, I guess I have to add a small GUI with Buttons that allow to increase and decrease the Limit Level Price so that the strategy can modify the Limit order accordingly.

    The Manual Option on the Chart would be less work to program, of course.

    Any Input appreciated.

    Thanks,
    Martin

    #2
    Hello Martin,

    Thank you for writing in.
    Basically, the strategy is programmed to detect the fill of the Limit Level it has submitted. Will this work with a manually modified Limit Level?
    When you say "the fill of the limit level it has submitted", I would need to see the actual code for this to determine whether or not manually modifying the limit price would affect the logic. If you are dynamically grabbing the limit price then you won't have an issue, but if you have hardcoded the limit value into a variable (such as when the strategy first submits the order) then you will need to modify this to a dynamic value. This can involve changing around your code somewhat and depends on whether you are using ATM strategy methods, SetStopLoss/SetProfitTarget methods or ExitLongStop/ExitShortStop/ExitLongStopLimit/ExitShortStopLimit methods.

    Then you could just manually modify the limit using the Chart Trader.

    Please send me the relevant snippets of your code relating to where the limit price is checked (This would normally be in the OnExecution() or the OnOrderUpdate() method) and I can give you a more definitive answer.
    If you do not wish to provide this on the forums, please send in an email to platformsupport[AT]ninjatrader[DOT]com with the subject line: "ATTN: Michael M #1369096" and I will follow up with you via email.

    Thank you in advance.
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      Thanks, Michael.

      Here is the relevant snippets. I use Managed Approach, no ATM stuff whatsoever.

      Code:
      [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]
       [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// IOrder
      [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] IOrder marketEntryLong;
       [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] IOrder stopLossLong;
       [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] IOrder limitLong;
       
       [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] IOrder marketEntryShort;
       [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] IOrder stopLossShort;
       [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] IOrder limitShort;
       [/SIZE][/FONT][/SIZE][/FONT]
      When a Long Position is filled with the market entry order, the Limit order is set to a certain Limit Price Level:

      Code:
      [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]
       [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] limitPriceLevel = Instrument.MasterInstrument.Round2TickSize(Position.AvgPrice) + (setLongPositionLimit(longPositionSize, current, entryEnd) * renkoNumberOfTicks * TickSize);
       limitLong = ExitLongLimit(TickPriceSeriesIndex_BID, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], longPositionSize, limitPriceLevel, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"LimitLong"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"LongEntry"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);
       [/SIZE][/FONT][/SIZE][/FONT]
      Here, after the Limit order is visible on the Chart, I would like to mess around sometimes to put it to Price Levels having a better probability depending on the market Situation I see. I only Need to Change the Price Level manually by dragging it higher or lower.

      The strategy checks the fill like this:

      Code:
      [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]
       [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnExecution(IExecution execution)
       {
       [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (execution.Order != [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])
       {
      [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (limitLong != [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])
       {
       [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (limitLong == execution.Order && execution.Order.OrderState == OrderState.Filled)
       {
      [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// limit of long position filled
      [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]resetStateMachine();
       }
       }
       [/SIZE][/FONT][/SIZE][/FONT]
      Here, for the strategy to correctly continue it is only relevant that the strategy sees its Position flat afterwards in Position.MarketPosition object.

      I guess it should be OK, but I am not Aware of any pitfalls....

      Cheers,
      Martin
      Last edited by mstreck; 08-14-2015, 03:22 AM.

      Comment


        #4
        Hello Martin,

        Thank you for sending the relevant snippets. Based on the code you provided you should not have any issues doing what was described in your original post.

        The issue I was describing would only occur if you were checking the limitPriceLevel variable in your OnExecution method, which you are not in the code you provided.

        Please let me know if I may be of further assistance.
        Michael M.NinjaTrader Quality Assurance

        Comment


          #5
          That is great.

          I actually only read the filled Price for in live trading to send an email with the Information on the filled average Price of the Limit order in OnExecution()

          Code:
          [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]
           avgExitPriceLong = execution.Order.AvgFillPrice
           [/SIZE][/FONT][/SIZE][/FONT]
          I guess this should not constitute a problem either, or does it?

          Thanks for your help.

          Martin

          Comment


            #6
            Hello Martin,

            It is always my pleasure. What you said does not constitute a problem because it dynamically gets the variable.

            Again the only time this would be an issue is if you were manually setting the variable in the code and then using that variable for something after you would have been able to move the order around manually.

            Please let me know if I may be of further assistance.
            Michael M.NinjaTrader Quality Assurance

            Comment


              #7
              Tried it out today and it works nicely.

              Thanks,
              Martin

              Comment


                #8
                Hello Martin,

                Thank you for the update. I am glad to hear that everything is working nicely.
                Please have a great rest of your day!
                Michael M.NinjaTrader Quality Assurance

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                574 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                333 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                553 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                551 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X