• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

onExecution informations

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

    onExecution informations

    Hello,

    I removed my stops from onexecution since they were not working some times. In onBarupdate they work every trade. OK.

    But I also dont have my variables from onExecution working. eg entrylevel always shows 0 in my output window.


    if(entryOrderSAa == execution.Order)
    {
    if(execution.Order.OrderState == OrderState.Filled)
    {
    // SetStopLoss("SAa", CalculationMode.Price, stop1, false); SetProfitTarget("SAa", CalculationMode.Price, startt1);
    entrylevel = levS;
    profittargetSAa = t1real;
    }
    }

    What is wrong with this code, as it looks same as samples I have from the forum.

    Thank you!
    Tony

    #2
    Hello,

    Thank you for writing to the support team.

    I am reviewing your inquiry and will be back with a reply shortly.

    I look forward to assisting further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Try checking execution.Price.
      eDanny
      NinjaTrader Ecosystem Vendor - Integrity Traders

      Comment


        #4
        Hi eDanny,

        thank you for your reply. Its not about the Price, its how to get values in onExecution.

        For example levS and t1real are calculated doubles from onBarupdate that should be assigned with execution one time (and not be updated anymore in onbarupdate)



        Best
        Tony
        Last edited by tonynt; 08-18-2017, 01:08 PM. Reason: translation error, clearifying

        Comment


          #5
          Hello tonynt,

          Thank you for your patience.

          To access information about an order, you will use an IOrder object.

          More on IOrder here:
          https://ninjatrader.com/support/help...htm?iorder.htm

          If you would like to store information from OnBarUpdate globally, you need to have them initialized at the class level like so:

          Code:
           public class MyStrategy : Strategy
              {
                  #region Variables
            private double levS;
            private double t1real;
                  #endregion
          To calculate a value only once, use a boolean flag to ensure the code only runs once.

          Code:
           public class MyStrategy : Strategy
              {
                      private bool flag1 = false;
          
          
          OnBarUpdate(){
          
                  if(flag1 == false){
                          
                         flag1 = true;
                         //perform the calculation/assignment. 
          
              }
          
          }

          Please let us know if we may be of any further assistance.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Hello,

            thank you for your reply and the snippet.

            I work with bools in onbarupdate. What I wanted to find out is if I can assign a value to a double in onexecution or in inorderupdate, meaning at the time, only at the time, when triggered. And if its possible to count up in onexecution (or in onorderupdate) the filled Positions. execution.Position++ (?)

            Thank you
            Tony

            Comment


              #7
              Hello tonynt,

              Thank you for the reply.

              You may assign any value from any function in your code as long as you have the variables set up as properties in your strategy class. The IPosition object from the OnPositionUpdate() method is read-only meaning it is immutable from this method. Your entry/exit/rejection handling will be done in OnExecution using the IOrder object, which belongs to the IExecution object.

              More on OnPositionUpdate() here:
              https://ninjatrader.com/support/help...tionupdate.htm

              More on OnExecution():
              https://ninjatrader.com/support/help...nexecution.htm

              More on the IExecution object:
              https://ninjatrader.com/support/help...iexecution.htm

              If we may be of any further assistance, please let us know.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Hello,

                thank you for your reply. I know about Print(execution.ToString());
                ... as I´m working with onExecution.

                The question is if one can assign a value to an int, bool or double from an execution in onExecution.
                if(e.order...... filled) int trades=1; double stop1=Low[0]-3*TickSize, bool happytrade=true;
                (or in onOrderupdate if(o.order....filled)...........happytrade=true;

                I can not explain in a different way anymore.

                Thank you!
                Tony

                Comment


                  #9
                  Tontnt, you should be able to do that. Try it and add some print statements in OnExecution() to print your new variable values.
                  eDanny
                  NinjaTrader Ecosystem Vendor - Integrity Traders

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Leeroy_Jenkins, Today, 06:54 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post Leeroy_Jenkins  
                  Started by rainbow47, Today, 06:10 AM
                  0 responses
                  7 views
                  0 likes
                  Last Post rainbow47  
                  Started by stenberg98, Today, 04:53 AM
                  2 responses
                  7 views
                  0 likes
                  Last Post NinjaTrader_Marco  
                  Started by wukefuha, Today, 03:20 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_Marco  
                  Started by mbcmbc, Yesterday, 10:12 PM
                  1 response
                  10 views
                  0 likes
                  Last Post NinjaTrader_ChrisSch  
                  Working...
                  X