Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AFTERRender event

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

    AFTERRender event

    Hi all,

    I'm taking a screenshot after an order is proceed and calling ForceRefresh();
    Then I'm watching OnRender event. This is also been touched but unfortunetely my screenshot is still to early.
    Think I need a way to create my screenshot ATERRender event.
    Is there any posibility?

    Thanks in advance.
    Airwave
    NinjaTrader Ecosystem Vendor - Airwave

    #2
    Hi Airwave, thanks for posting.

    You could set a boolean variable to false before the order is submitted, wait for OnRender to pass once and set it to true in OnRender then once that becomes true take the screenshot. You could also take the screenshot on the next bar where the Order object is State.Accepted or Working then take the screenshot on the next bar. If none of these ideas resolve, I will need to see a reduced test script from you to see the issue.

    Kind regards,
    -ChrisL

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      You could set a boolean variable to false before the order is submitted, wait for OnRender to pass once and set it to true in OnRender then once that becomes true take the screenshot. You could also take the screenshot

      Hello,

      thats exactly how I do it.
      Seems to be as if the Variable in OnRender is set a bit to early. Thats why I asked for "After"OnRender.

      Or what do you mean with "wait for Render to pass once". Maybe I should wait for second OnRender run through and not already the my variable to true in the first run through?

      Thanks in advance.
      Last edited by Airwave; 07-27-2021, 09:35 AM.
      Airwave
      NinjaTrader Ecosystem Vendor - Airwave

      Comment


        #4
        Hi Airwave, thanks for your reply.

        You should monitor the order in OnOrderUpdate if you are not already. The order should be rendered to the chart once the order has reached State.Accepted or State.Working. If you are already doing this, please share a reduced code example so I can test on my end.

        Kind regards,
        -ChrisL

        Comment


          #5
          Hi Chris,

          Thank you for your answer.
          I'm trying to change a bit of my code.

          Here I came to a new question:

          You wrote: "You should monitor the order in OnOrderUpdate if you are not already. "

          Can you tell me how I can identify and track the same order in OnOrderUpdate from each time OnOrderUpdate is called. Tryed the the OrderI, but this is changeing?

          Thanks in advance.

          Airwave
          Airwave
          NinjaTrader Ecosystem Vendor - Airwave

          Comment


            #6
            Hello Airwave,

            I have attached an example that takes a screenshot from OnRender after we signal that an order is accepted/working from OnOrderUpdate when it would be present on the chart. This is set up for an indicator but you may override OnOrderUpdate for strategy level order update events.

            OnOrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm

            Please let us know if you have issues testing this script or taking this approach.
            Attached Files

            Comment


              #7
              Hu Jim,

              thank you. Problem was I used:
              protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)
              {
              }

              With the account.OrderUpdate it's working perfectly.


              Unfortunetely following is always "null":
              // Find our Sim101 account
              lock (Account.All)
              account = Account.All.FirstOrDefault(a => a.Name == AccountName);

              I have the chance to select this manually in the properties but would like to fill this by default also with SIM101.

              Any suggestions?

              Thanks
              Airwave
              NinjaTrader Ecosystem Vendor - Airwave

              Comment


                #8
                Hi AirWave,

                The Account documentation page has an example on initializing the account as the Sim101:


                Or use the Account selector property to initialize the Account object in State.Configure:
                [TypeConverter(typeof(NinjaTrader.NinjaScript.Accou ntNameConverter))]
                public string AccountName { get; set; }

                Kind regards,
                -ChrisL

                Comment


                  #9
                  Originally posted by NinjaTrader_ChrisL View Post
                  Or use the Account selector property to initialize the Account object in State.Configure:
                  [TypeConverter(typeof(NinjaTrader.NinjaScript.Accou ntNameConverter))]
                  public string AccountName { get; set; }

                  Thats exactly I've added on top of the class
                  public class mystrategy: Strategy
                  {
                  [TypeConverter(typeof(NinjaTrader.NinjaScript.Accou ntNameConverter))]
                  public string AccountName { get; set; }
                  .
                  .
                  .
                  .

                  But in StateConfigure it's still always null:

                  if (State == State.Configure)
                  {

                  // Find our Sim101 account
                  lock (Account.All)
                  account = Account.All.FirstOrDefault(a => a.Name == AccountName);


                  Any suggestions? Thanks in advance.
                  Airwave
                  NinjaTrader Ecosystem Vendor - Airwave

                  Comment


                    #10
                    Hi Airwave, thanks for your reply.

                    That can be fixed by checking objects for null:

                    Code:
                    else if (State == State.Configure)
                    {
                    if(AccountName != null)
                    {
                    lock (Account.All)
                    myAccount = Account.All.FirstOrDefault(a => a.Name == AccountName);
                    }
                    
                    if (myAccount != null)
                    {
                    myAccount.ExecutionUpdate += OnExecutionUpdate;
                    }
                    }
                    else if (State == State.Terminated)
                    {
                    if (myAccount != null)
                    myAccount.ExecutionUpdate -= OnExecutionUpdate;
                    }

                    Comment


                      #11
                      Originally posted by NinjaTrader_ChrisL View Post
                      That can be fixed by checking objects for null:
                      Hi Chris,

                      sorry the question was a bit different. My issues answer was just was to define
                      AccountName = "Sim101";
                      in SetDefaults
                      :-)

                      Thanks
                      Airwave
                      NinjaTrader Ecosystem Vendor - Airwave

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by NullPointStrategies, Today, 05:17 AM
                      0 responses
                      19 views
                      0 likes
                      Last Post NullPointStrategies  
                      Started by argusthome, 03-08-2026, 10:06 AM
                      0 responses
                      119 views
                      0 likes
                      Last Post argusthome  
                      Started by NabilKhattabi, 03-06-2026, 11:18 AM
                      0 responses
                      63 views
                      0 likes
                      Last Post NabilKhattabi  
                      Started by Deep42, 03-06-2026, 12:28 AM
                      0 responses
                      41 views
                      0 likes
                      Last Post Deep42
                      by Deep42
                       
                      Started by TheRealMorford, 03-05-2026, 06:15 PM
                      0 responses
                      45 views
                      0 likes
                      Last Post TheRealMorford  
                      Working...
                      X