Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

OrderName 'STOP1' does not exist

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

    OrderName 'STOP1' does not exist

    Hi I'm getting this error

    **NT** AtmStrategyChangeStopTarget() method error: OrderName 'STOP1' does not exist

    it happens on the onbarupdate call but only when the bars are moving fast. Slow moving bars no problem tested 100s of examples.

    I use unirenko bars so the the range bars can go very fast on fast moving prices, I have run for days without issues then today I get a fast moving bars and the error


    Adding order

    atmStrategyId = GetAtmStrategyUniqueId();
    orderId = GetAtmStrategyUniqueId();

    AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Stop, 0, buystopp, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);

    then net time around on the onbarupdate call


    if ((atmStrategyId.Length > 0)&&(orderId.Length > 0)){

    status = GetAtmStrategyEntryOrderStatus(orderId);


    if (status.Length > 0)&&(status[2]=="Filled")


    AtmStrategyChangeStopTarget(0, tstop, "STOP1", atmStrategyId);


    ignore coding errors I just cut n paste the pertanient code

    the atmstrategy automatically creates a stop when order is filled

    maybe on fast bars I can check for the stop being created? I think it was eventually created, but it stayed and did no get cancelled
    when the order closed, this was a fast set of bars (fast price action) in and out fast.









    #2
    Hello Postalman,

    Thank you for your post.

    I suspect what's happening is that the market's moving fast enough where you're not getting updated that the stop's been placed before trying to change it. I'd suggest using GetAtmStrategyStopTargetOrderStatus() to check whether there's a status yet on the order before submitting any changes to it:

    Here's an example of how I've modified the SampleATMStrategy:

    Code:
    // You can change the stop price
    if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
    {
    string[,] orders = GetAtmStrategyStopTargetOrderStatus("STOP1", atmStrategyId);
    
    // Check length to ensure that returned array holds order information
    if (orders.Length > 0)
    {
    for (int i = 0; i < orders.GetLength(0); i++)
    {
    Print("Current state is " + orders[i, 2].ToString());
    AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "STOP1", atmStrategyId);
    }
    }
    
    }
    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Kate,

      I thtnk that will help, I think there another issue also, if the bars are moving so fast that I enter and exit before the stop is active, which I think has happened because after the trade is done there is a left over stop how do I handle that, somehow check if there are any hanging stops when the strategy is done? The hanging stop is dangerous since it is no longer tied to it's long trade and couls become a short (maybe?).



      Comment


        #4
        Hello postalman,

        Thank you for your reply.

        We shouldn't be seeing that leftover order after that occurs as if the entry is closed the associated ATM Strategy should automatically be cancelled. If you're able to replicate this behavior in real time operation using the Sim account after making the adjustments I mentioned, we'd want to test on our end with an example script so see what's occurring that the stop is still being placed without being connected to the entry order.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Kate,

          I will let you know, I think I'm going to add some logic that will not allow any future trades or actions until I get the stop active (it may take some bars), I'm still looking at why I had the stop left over. I'll need to look into cases where the price might go below the stop by the time it gets active, do these just close out or give an error that the price is already below the stop for a fast moving drop in price after doing a long/stop strategy. Thanks,

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by inanazsocial, Today, 01:15 AM
          0 responses
          2 views
          0 likes
          Last Post inanazsocial  
          Started by trilliantrader, 04-18-2024, 08:16 AM
          5 responses
          22 views
          0 likes
          Last Post trilliantrader  
          Started by Davidtowleii, Today, 12:15 AM
          0 responses
          3 views
          0 likes
          Last Post Davidtowleii  
          Started by guillembm, Yesterday, 11:25 AM
          2 responses
          9 views
          0 likes
          Last Post guillembm  
          Started by junkone, 04-21-2024, 07:17 AM
          9 responses
          70 views
          0 likes
          Last Post jeronymite  
          Working...
          X