Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

trying to extract target & STOP price for ATM active strat

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

    trying to extract target & STOP price for ATM active strat

    hey guys,

    v 7.1

    i've used the code from the ATM section of the manual, but even if there is an existing and active ATM strategy running, the following code only returns 0's; i'm trying to get it to return the target, and the stop


    if (atmStrategyIdL.Length>0 && GetAtmStrategyMarketPosition(atmStrategyIdL)==Mark etPosition.Long)
    {
    ... stuff....

    string[,] orders = GetAtmStrategyStopTargetOrderStatus("TARGET1", atmStrategyIdL); // "idValue");
    //string[,] orders = GetAtmStrategyStopTargetOrderStatus("STOP1", atmStrategyIdL); // try 1, not 2
    Print(Time[0].ToString(dFmt)+header+ " **** extract the target/stop for atmStrategyIdL="+atmStrategyIdL);
    // Check length to ensure that returned array holds order information
    if (orders.Length > 0)
    { for (int i = 0; i < orders.GetLength(0); i++)
    { Print(Time[0].ToString(dFmt)+header+ " (tell us stop?) Avg fill=" + orders[i, 0].ToString()
    + " Filled amt=" + orders[i, 1].ToString()
    + " Current state=" + orders[i, 2].ToString());
    }
    }


    1/6 19:23:32 DevAtm r1 4.01 [CL] **** extract the target/stop for atmStrategyIdL=22f68cc02ddf4c75af2bf8a524724994
    1/6 19:23:32 DevAtm r1 4.01 [CL] (tell us stop?) Avg fill=0 Filled amt=0 Current state=Working

    #2
    ssylwester, was the ATM strategy started / created from a NinjaScript strategy? Or was the entry done manually by you?

    Thanks,
    BertrandNinjaTrader Customer Service

    Comment


      #3
      it was created by the ninja strategy


      private void SubmitOrderL(string atmSetup)
      { if (backtest)
      { if (Position.MarketPosition == MarketPosition.Long) return; // existing position
      else if (entryOrderL != null) return; // existing order already
      stopLong = 0;
      isNewStop( ref stopLong, longEntry-maxStopLoss*TickSize, true); // moves stop
      entryOrderL = EnterLongLimit(0, true, DefaultQuantity, longEntry, nameLong); // change to nameLongAct in a few lines
      }
      else // atm strategy
      { if (orderIdL.Length>0 || atmStrategyIdL.Length>0 ) return; // already open order
      if (myMktPosition=="Long") return;
      atmStrategyIdL = GetAtmStrategyUniqueId();
      orderIdL = GetAtmStrategyUniqueId();
      AtmStrategyCreate(OrderAction.Buy, OrderType.Limit, longEntry, 0, TimeInForce.Day, orderIdL, atmSetup, atmStrategyIdL);
      }
      nameLongAct=nameLong;
      if (devEnv && sounds) PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\alert3.wav"); // ricochet
      else if (sounds) PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\gong.wav");
      }

      Comment


        #4
        Thanks for clarifying, you could only check the order state / status - which is 'working' and none are filled yet, so a 0 is correctly shown in your prints.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I'm confused. I thought that code could be used to check the status of the STOP level for an existing position, a position that was launched by the NT strategy, and is being controlled by an ATM strat. What am i missing? I want to be able to check the current STOP level, as there are some code-level decisions i would like to apply, such as tightening stop further on other indicator outputs.
          Last edited by ssylwester; 01-11-2011, 11:22 AM. Reason: add material

          Comment


            #6
            Correct, you could check the status, unfortunately not the price level - if you need it you would need to custom track any adjustments to your stop to know where you're current at.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rocketman7, Today, 01:00 AM
            0 responses
            1 view
            0 likes
            Last Post rocketman7  
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            27 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, 04-23-2024, 09:53 PM
            2 responses
            74 views
            0 likes
            Last Post wzgy0920  
            Started by Kensonprib, 04-28-2021, 10:11 AM
            5 responses
            193 views
            0 likes
            Last Post Hasadafa  
            Working...
            X