Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:


          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:


              More on OnExecution():


              More on the IExecution object:


              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 nandhumca, Yesterday, 03:41 PM
                  1 response
                  12 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by The_Sec, Yesterday, 03:37 PM
                  1 response
                  11 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by vecnopus, Today, 06:15 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post vecnopus  
                  Started by Aviram Y, Today, 05:29 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post Aviram Y  
                  Started by quantismo, 04-17-2024, 05:13 PM
                  3 responses
                  27 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Working...
                  X