Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

onexecution errors

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

    onexecution errors

    I am attempting to use OnExecution() for placing a profit target and it isn't compiling.

    Here is what I have in my onexecution area.

    Code:
    		protected override void OnExecution(IExecution execution)
    		{
    			if (execution.Order != null
    				&& execution.OrderState == OrderState.Filled)
    				
    				LongLimit = ExitLongLimit(0, true,DefaultQuanity,(AvgPrice + (longSignalHigh - longSignalLow)*TargetPerc),"LongTarget","LongEntryA");
    		
    		}
    Is anybody able to determine what is wrong with the code?

    In short, 1 or more candles ago a signal candle was created. I take the high and the low from that candle and multiply it by a certain percentage and add it to my entry price. That becomes my profit target.

    LongLimit is a variable that I declared under variables and only here am I defining what it is. I am using the OnExecution() help page for samples as well as one of the sample education codes that are found on this site by Josh.

    Hopefully that is enough information.

    Thank you for your help
    Last edited by jg123; 03-21-2014, 02:57 AM. Reason: fixing typing errors

    #2
    I have made a couple of changes to the code.

    It still does not fix some of the errors, but it seems to have fixed a couple of others. Here is the updated code:

    Code:
    		protected override void OnExecution(IExecution execution)
    		{
    			TargetPriceLong = AvgPrice + (longSignalHigh - longSignalLow)*TargetPerc;
    			
    			if (execution.Order != null
    				&& execution.OrderState == OrderState.Filled)
    				
    				LongLimit = ExitLongLimit(0, true,DefaultQuantity,TargetPriceLong,"LongTarget","LongEntryA");
    		
    		}

    Comment


      #3
      jg123, sorry but I don't follow your last post - so you would be able to compile now with the latest changes or not? What issues would remain?

      Comment


        #4
        Oh, sorry for the confusion.

        Things still are not working with this updated code.

        Comment


          #5
          Hello jg123,

          The error message I think you are getting is the following:

          "NinjaTrader.Cbi.IExecution' does not contain a definition for 'OrderState' and no extension method 'OrderState' accepting a first argument of type 'NinjaTrader.Cbi.IExecution' could be found (are you missing a using directive or an assembly reference?)".

          If that is the message then you will need to change your Condition to:

          if (execution.Order != null && execution.Order.OrderState == OrderState.Filled)
          //Rest of code
          JCNinjaTrader Customer Service

          Comment


            #6
            ah, yes. That fixed it. Thank you

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            597 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            343 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            556 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            555 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X