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 geotrades1, Today, 10:02 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by ender_wiggum, Today, 09:50 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by rajendrasubedi2023, Today, 09:50 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by bmartz, Today, 09:30 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by geddyisodin, Today, 05:20 AM
          3 responses
          27 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X