• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on changeOrder Method

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

    Error on changeOrder Method

    Hi,

    I have this condition to change stoploss :

    Code:
    if (Position.MarketPosition == MarketPosition.Long 
    && enableShort == false)
    {
    if (stopOrderLong != null && stopOrderLong.StopPrice != (Position.AvgPrice - (stop * TickSize)))
    {
    ChangeOrder(stopOrderLong, 1, 0, (Position.AvgPrice - (stop * TickSize)));
    }
    }
    it seems correct as syntax, but when I activate the system at each bar it always changes the order at the same price. Here an example from output window. OutputSample.txt can someone help me??
    Thanks in advance

    Giuseppe

    #2
    Hi, thanks for your post.

    It looks like the ChangeOrder line is being called multiple times even though the price is still the same. Have you attempted using Print statements to see what kind of values your variables have? This is always the go-to for debugging. I solve 99% of the bugs I get with Prints.

    https://ninjatrader.com/support/help...nt8/?print.htm

    Our colleague Chelsea has an example using the unmanaged approach and ChangeOrder here (third script down):

    https://ninjatrader.com/support/foru...s-cs-expecting

    I look forward to hearing of your results.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Our colleague Chelsea has an example using the unmanaged approach and ChangeOrder here (third script down):

      https://ninjatrader.com/support/foru...s-cs-expecting
      fyi,
      those examples don't use ChangeOrder -- they are for NT8 and use SubmitOrderUnmanaged.

      Comment


        #4
        Originally posted by NinjaTrader_ChrisL View Post
        Hi, thanks for your post.

        It looks like the ChangeOrder line is being called multiple times even though the price is still the same. Have you attempted using Print statements to see what kind of values your variables have? This is always the go-to for debugging. I solve 99% of the bugs I get with Prints.

        https://ninjatrader.com/support/help...nt8/?print.htm

        Our colleague Chelsea has an example using the unmanaged approach and ChangeOrder here (third script down):

        https://ninjatrader.com/support/foru...s-cs-expecting

        I look forward to hearing of your results.
        Thanks Chris,
        sorry but in this case the only variable called is "enableshort" and it is for sure = false, just checked...
        if I remember well, I've read somewhere in the past that there was issues using for example "4*TickSize" instead "7 * (TickSize / 2)" because potential precisions with the doubles. Is that true and could be the case?

        thanks

        Comment


          #5
          Precision can be corrected by Instrument.MasterInstrument.Round2TickSize(4*TickS ize).
          eDanny
          NinjaTrader Ecosystem Vendor - Integrity Traders

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by linuxguru, Today, 06:02 PM
          0 responses
          7 views
          0 likes
          Last Post linuxguru  
          Started by kokobeef, Today, 06:00 PM
          0 responses
          5 views
          0 likes
          Last Post kokobeef  
          Started by Bionian, Today, 03:07 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by JakeOfSpades, Today, 03:05 PM
          2 responses
          14 views
          0 likes
          Last Post JakeOfSpades  
          Started by aligator, Today, 01:49 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Working...
          X