Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting Bool with StopTargetOrderStatus

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

    Setting Bool with StopTargetOrderStatus

    I'm having difficulty setting a bool to track the bar in which my targets or stops have been filled. I've gotten stuck at this point

    Code:
    string[,] orders = GetAtmStrategyStopTargetOrderStatus("Target1", 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("Average fill price is " + orders[i, 0].ToString());
    					Print("Filled amount is " + orders[i, 1].ToString());
    					Print("Current state is " + orders[i, 2].ToString());
    				}
    				
    			}
    			
    			if (orders[i, 2] == "Filled")
    				filledbar = CurrentBar;
    I've been getting error CS0103 - the name 'i' does not exist in the current context. The error is linked to
    Code:
    if (orders[i, 2] == "Filled")
         filledbar = CurrentBar;
    All of the documentation I have looked through has not explained how to set a bool using this method, or if it is in fact the correct method to be using.

    Guidance would be much appreciated. Thanks in advance.

    #2
    Hello MisterGee,

    Thanks for your post.

    The indexer "i' is undefined outside of the for loop. In order to use "i" you would need to move your code inside the for loop, for example:

    Code:
    if (orders.Length > 0)
    			{
    				for (int i = 0; i < orders.GetLength(0); i++)
    				{
    					Print("Average fill price is " + orders[i, 0].ToString());
    					Print("Filled amount is " + orders[i, 1].ToString());
    					Print("Current state is " + orders[i, 2].ToString());
    			                if (orders[i, 2] == "Filled")
    				                  filledbar = CurrentBar;
    				}
    				
    			}
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I've been tinkering with this for a while now and am still unsuccessful in getting this to work. Can I email you a copy of my strategy to test on your end?

      Comment


        #4
        Output window

        **NT** Submitting order with strategy 'SlenderTrender/720bd5fdc8e2405abc21a4be4a0a69bb'
        2/21/2016 11:54:41 PM TraleStop value is: 25.25

        2/21/2016 11:54:41 PM Lookback Period is: 0

        **NT** GetAtmStrategyStopTargetStatus() method error: OrderName 'Target1' does not exist

        (this is on market replay)

        This is where my problem lies. Why is the strategy unable to find the order? I use 'Target1' to move the profit target while the position is open else where in the strategy so...?

        Comment


          #5
          Hello MisterGee,

          Thanks for your posts.

          Please send your strategy to PlatformSupport[at]NinjaTrader[dot]com. Please set Atten: Paul and a link to this thread in the subject line.
          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Karado58, 11-26-2012, 02:57 PM
          8 responses
          14,828 views
          0 likes
          Last Post Option Whisperer  
          Started by Option Whisperer, Today, 09:05 AM
          0 responses
          1 view
          0 likes
          Last Post Option Whisperer  
          Started by cre8able, Yesterday, 01:16 PM
          3 responses
          11 views
          0 likes
          Last Post cre8able  
          Started by Harry, 05-02-2018, 01:54 PM
          10 responses
          3,204 views
          0 likes
          Last Post tharton3  
          Started by ChartTourist, Today, 08:22 AM
          0 responses
          6 views
          0 likes
          Last Post ChartTourist  
          Working...
          X