• 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 teafortwo, Today, 12:51 AM
          0 responses
          4 views
          0 likes
          Last Post teafortwo  
          Started by wevermord, Today, 12:17 AM
          0 responses
          1 view
          0 likes
          Last Post wevermord  
          Started by johnnymustard, Yesterday, 11:45 PM
          0 responses
          21 views
          0 likes
          Last Post johnnymustard  
          Started by Mttzern, 02-22-2020, 10:42 AM
          1 response
          26 views
          0 likes
          Last Post NinjaTrader_Marco  
          Started by saltminer, Yesterday, 10:40 PM
          0 responses
          4 views
          0 likes
          Last Post saltminer  
          Working...
          X