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 ZenCortexCLICK, Today, 04:58 AM
          0 responses
          2 views
          0 likes
          Last Post ZenCortexCLICK  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          172 responses
          2,280 views
          0 likes
          Last Post sidlercom80  
          Started by Irukandji, Yesterday, 02:53 AM
          2 responses
          17 views
          0 likes
          Last Post Irukandji  
          Started by adeelshahzad, Today, 03:54 AM
          0 responses
          4 views
          0 likes
          Last Post adeelshahzad  
          Started by Barry Milan, Yesterday, 10:35 PM
          3 responses
          13 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X