Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitLongStopLimit not considering stop or limit prices

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

    ExitLongStopLimit not considering stop or limit prices

    I heard you guys have quite a good support team. Im new, Im inexperienced and Im hoping (and asking, please) you guys dont get mad at me, even if my question is too out of place (be patient, its my very first question on the forum).

    I believe Ninjascript is not considering stop or limit prices when calling ExitLongStopLimit.

    I search around and havent found anybody talking about it (therefore i must be missing something here ... ), I have came up with a strategy script which uses something like the command below

    Code:
    ExitLongStopLimit(BarsInProgress, true, 1, 1.0032, 1.0033, "ExitLong", "EnterLong");
    By what I understood of the function the order should not be filled until the market price reaches $1.0033 nor if it passes $1.0032. Giving the fact that I pass LiveUntilCanceled parameter as true the order would not be canceled until I say so (Note, Im not using "Unmanaged = true;" and event thought I´m controlling to have few orders I set "EntriesPerDirection = 300").

    I print out a few info on every ticket and place some of the output below

    Code:
    Line 01: Bar: 2231 Tick: 1/4 Close[0]: 1.0034
    Line 02: Bar: 2232 Tick: 2/4 Close[0]: 1.0034
    Line 03: Bar: 2232 Tick: 3/4 Close[0]: 1.0034
    Line 04: Bar: 2232 Tick: 4/4 Close[0]: 1.0034
    Line 05:  \- ExitLongStopLimit Bar: 2233 Stop: 1.0033 Limit: 1.0032 Close[0]: 1.0034
    Line  06:    OnOrderUpdate Order='5c4af500d3c24a29abe0e7ac93fe0251/Sim101'  Name='ExitLong' State=PendingSubmit Instrument='$AUDUSD' Action=Sell  Limit price=1.0032 Stop price=1.0033 Quantity=1 Type=StopLimit Tif=Gtc  OverFill=False Oco='' Filled=0 Fill price=0  Token='5c4af500d3c24a29abe0e7ac93fe0251' Gtd='1/1/0001 12:00:00 AM'
    Line  07:    OnOrderUpdate Order='5c4af500d3c24a29abe0e7ac93fe0251/Sim101'  Name='ExitLong' State=Accepted Instrument='$AUDUSD' Action=Sell Limit  price=1.0032 Stop price=1.0033 Quantity=1 Type=StopLimit Tif=Gtc  OverFill=False Oco='' Filled=0 Fill price=0  Token='5c4af500d3c24a29abe0e7ac93fe0251' Gtd='1/1/0001 12:00:00 AM'
    Line 08: Bar: 2232 Tick: 1/4 Close[0]: 1.0034
    Line  09:   OnOrderUpdate Order='5c4af500d3c24a29abe0e7ac93fe0251/Sim101'  Name='ExitLong' State=Working Instrument='$AUDUSD' Action=Sell Limit  price=1.0032 Stop price=1.0033 Quantity=1 Type=StopLimit Tif=Gtc  OverFill=False Oco='' Filled=0 Fill price=0  Token='5c4af500d3c24a29abe0e7ac93fe0251' Gtd='1/1/0001 12:00:00 AM'
    Line 10: Bar: 2233 Tick: 2/4 Close[0]: 1.0034
    Line  11:   OnOrderUpdate Order='5c4af500d3c24a29abe0e7ac93fe0251/Sim101'  Name='ExitLong' State=Filled Instrument='$AUDUSD' Action=Sell Limit  price=1.0032 Stop price=1.0033 Quantity=1 Type=StopLimit Tif=Gtc  OverFill=False Oco='' Filled=1 Fill price=1.0034  Token='5c4af500d3c24a29abe0e7ac93fe0251' Gtd='1/1/0001 12:00:00 AM'
    Line 12: Bar: 2233 Tick: 3/4 Close[0]: 1.0034
    Line 13: Bar: 2233 Tick: 4/4 Close[0]: 1.0035
    If you look at the line 11 we notice the order have been filled with $1.0034, therefor my questions:

    1. If I pass stop=1.0033 and Limit=1.0032 why does the order was filled with the price at $1.0034?
    2. Lets say the market reaches $1.0033, trigged the stop and was up to $1.0034 in the next ticket (which by the way was me) therefor i got $1.0034, why them have I not receive the $1.0033 ticket info (I set the print to the first line on the OnBarUpdate with "CalculateOnBarClose = false;")?


    And the real question, "what am I missing?".

    Thanks,

    #2
    Hello,
    Where you running this as a backtest, looking at historical trades on a chart that the strategy is applied to or were you running it with the Simulated Data Feed?
    I look forward to your reply.
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      Simulated Data Feed

      Comment


        #4
        Hello,
        Upon further review it appears this is what happened:
        The sell stop limit order was placed at 1.0032 with a limit price of 1.0033.
        The price hit 1.0032 initiating that the stop order submit the limit order. It submitted the limit order of 1.0033. The market price was better for a sell order though when the limit order was submitted(sell higher) and thus filled at the market price at the time of 1.0034 as limit orders will fill at the price designated or better.
        If you are not wanting orders to fill at a better price you would need to add in custom logic to cancel the order or modify it if it could fill at a better price.

        Please let us know if we can be of any other assistance.
        Cody B.NinjaTrader Customer Service

        Comment


          #5
          I understood your explanations and sure I want a better price, but inside the stop/limit boundaries. Is there some custom logic sample for this case you can share?

          And what about the other question, I was pring out the price information of every ticket, why have i not receive the $1.0033 ticket info, i do not receive information of my own tickets?

          Comment


            #6
            Hello,
            There is not custom logic that would make the stop limit orders not behave this way. You would need to use your own custom logic to submit limit orders at only the price that you want however limit orders still could fill at a better price.
            Can you clarify your second question as the information on the order did print out and you mention it in your first inquiry?
            Cody B.NinjaTrader Customer Service

            Comment


              #7
              Ok, i´ve done like this ...

              Code:
              protected override void Initialize() {
                  CalculateOnBarClose = false;
              }
              protected override void OnBarUpdate() {
                  Print("Bar: "+LastClosedBar+" Tick: "+Bars.TickCount.ToString()+"/"+Bars.Period.Value.ToString()+" Close[0]: "+Close[0]);
                  
                  ...
              }

              Lets say the market reaches $1.0033, trigged the stop and was up to $1.0034 in the next ticket (which by the way was me) therefor i got $1.0034, why them have I not receive the $1.0033 ticket info for as you can see in the logs (shown in the seccond "code" of the firste message) I was printing out all ticket info and this one wasn't printed?

              Comment


                #8
                Hello rstriquer,

                So you are stating the price level was never hit yet still filled at 1.0034?

                Can you send us your log and trace files so we may investigate this event as it occurred on the first of February?

                You can do this by going to the Control Center-> Help-> Mail to Platform Support. Please place 'ATTN: Patrick H - 1456887' in the subject line.

                Comment


                  #9
                  PS: just for clarifications ... I believe I was somehow mistaken, it seams to be working fine.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by wzgy0920, 04-20-2024, 06:09 PM
                  2 responses
                  26 views
                  0 likes
                  Last Post wzgy0920  
                  Started by wzgy0920, 02-22-2024, 01:11 AM
                  5 responses
                  32 views
                  0 likes
                  Last Post wzgy0920  
                  Started by wzgy0920, Yesterday, 09:53 PM
                  2 responses
                  49 views
                  0 likes
                  Last Post wzgy0920  
                  Started by Kensonprib, 04-28-2021, 10:11 AM
                  5 responses
                  191 views
                  0 likes
                  Last Post Hasadafa  
                  Started by GussJ, 03-04-2020, 03:11 PM
                  11 responses
                  3,230 views
                  0 likes
                  Last Post xiinteractive  
                  Working...
                  X