Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Correct sequence in the strategy

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

    Correct sequence in the strategy

    Hello!
    Someone could help me?
    My automated strategy sends a screenshot to my email each time makes an operation.
    and that's what i want. but ...
    the problem is that takes the screenshot too early, so, in the image, does not appear the operation itself, ( its important because i can't see things like the spreads for example)


    My questions is, what could I change to make it works. My strategy run like this:

    CalculateOnBarClose = true; // Can't Change!
    protected override void OnBarUpdate()
    {
    ... if ( bla ) EnterLong(..)
    }
    protected override void OnExecution(IExecution execution)
    {
    if (execution.Order.OrderState == OrderState.Filled) Send_Message();
    }
    void Send_Message()
    {
    ... bla ... // make the printscreen and then send the email...
    }

    Important: I cant wait until the next candle. because some of the candle's durations could be more than 4 hours.. Thanks!

    #2
    Hello juglar,

    What is the order of operations in your script?

    Does the other action happen before or after the screenshot is taken?

    Can you take and send the screenshot after the other action by having that code be triggered after the other action has been triggered?

    Can you wait 1 tick instead of waiting an entire bar?

    Could you use a timer?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Are you saying the call back happens before the screen is refreshed?

      Comment


        #4
        Hi Chelsea!, Thanks for the reply

        - The sequence:
        1. Send the order in OnBarUpdate()
        2 makes the comprobation in OnExecution(IExecution execution), if the order is filled. and then go to the function that takes a screenshot and sends the mail.


        -Can you wait 1 tick instead of waiting an entire bar? // Of Course, but i can't change the option : "CalculateOnBarClose = true;"

        -I am not use to use a "Timer " but if is the optimal i will use it. I prefer exhaust the other posibilities before.

        Comment


          #5
          Not really.
          all the screenshots have different names. the screenshot is the correct one, but the shot needs to be after it makes the operation. thats why i thought, to call the "screen function" after "execution.Order.OrderState == OrderState.Filled" but seems i am wrong.

          Comment


            #6
            Hi juglar,

            I think I'm understanding. An order is being placed, and in the execution you take the screenshot. However, when the screenshot is taken, the chart has not yet re-rendered showing the order.

            In this case, the strategy is not able to use the Plot override which triggers when the chart renders.

            So, the only options I can think of is to wait one tick (set a bool in the execution, and use OnMarketData to capture the next tick after the bool is set and take the screenshot, and then reset the bool back)

            OR use a timer. After the execution, start the timer and wait a second take the screenshot and then stop the timer.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Great!
              Tick was the answer. I tried with this:

              protected override void OnExecution(IExecution execution)
              {
              Count_Ticks = Bars.TickCount ;
              TickPass = true ;
              }
              protected override void OnMarketData(MarketDataEventArgs e)
              {
              if ( (Bars.TickCount > Count_Ticks || Bars.TickCount == 0 ) && TickPass == true )
              {
              TickPass = false ;
              ... Taking screenshot and sending mail ...
              }
              And thats All!
              Thanks Chelsea.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Shansen, 08-30-2019, 10:18 PM
              24 responses
              939 views
              0 likes
              Last Post spwizard  
              Started by Max238, Today, 01:28 AM
              0 responses
              7 views
              0 likes
              Last Post Max238
              by Max238
               
              Started by rocketman7, Today, 01:00 AM
              0 responses
              4 views
              0 likes
              Last Post rocketman7  
              Started by wzgy0920, 04-20-2024, 06:09 PM
              2 responses
              28 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 02-22-2024, 01:11 AM
              5 responses
              33 views
              0 likes
              Last Post wzgy0920  
              Working...
              X