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

Compare a bar with a Specific time and entry at the end of the day.

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

    Compare a bar with a Specific time and entry at the end of the day.

    For Example, In 1 hour NQ chart, I want to compare the open at 0100 and the close at 23;00, if open (0100) - close (2300) > 300, then take Entry at 23:59 in the same day.
    How can i do that?

    #2
    Hello strongelephant,

    Thank you for your note.

    You could check the open price when the time is 0100, and save that to a variable. Then, you could check for the time to be 2300, subtract the open you saved from the close price of that bar, and set a bool to true. Then, at 2359 on an added 1 minute series, check if the bool is true and submit an order if it is.

    I've created a simple example script that demonstrates this.

    You can also use GetBar to find the 0100 am open price at 2300:



    Either method would work.

    Please let us know if we may be of further assistance to you.
    Attached Files
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate,
      I do use your code and plugin to NinjaScript, but it seems doestn work. I don't know which part is wrong. Thanks for your answer.

      StrongElephant

      Comment


        #4
        Originally posted by NinjaTrader_Kate View Post
        Hello strongelephant,

        Thank you for your note.

        You could check the open price when the time is 0100, and save that to a variable. Then, you could check for the time to be 2300, subtract the open you saved from the close price of that bar, and set a bool to true. Then, at 2359 on an added 1 minute series, check if the bool is true and submit an order if it is.

        I've created a simple example script that demonstrates this.

        You can also use GetBar to find the 0100 am open price at 2300:



        Either method would work.

        Please let us know if we may be of further assistance to you.
        I use 60mins for the calculation.

        Comment


          #5
          Hello strongelephant,

          Thank you for your reply.

          Ah, I left a couple lines in there from starting out in the Strategy Builder that would block the entry. If you remove the following at the top of OnBarUpdate you should see it submit orders:

          if (BarsInProgress != 0)
          return;


          Please let us know if we may be of further assistance to you.​
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Kate View Post
            Hello strongelephant,

            Thank you for your reply.

            Ah, I left a couple lines in there from starting out in the Strategy Builder that would block the entry. If you remove the following at the top of OnBarUpdate you should see it submit orders:

            if (BarsInProgress != 0)
            return;


            Please let us know if we may be of further assistance to you.​
            Yes, Thanks!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by StockTrader88, 03-06-2021, 08:58 AM
            44 responses
            3,964 views
            3 likes
            Last Post jhudas88  
            Started by rbeckmann05, Today, 06:48 PM
            0 responses
            4 views
            0 likes
            Last Post rbeckmann05  
            Started by rhyminkevin, Today, 04:58 PM
            4 responses
            52 views
            0 likes
            Last Post dp8282
            by dp8282
             
            Started by iceman2018, Today, 05:07 PM
            0 responses
            5 views
            0 likes
            Last Post iceman2018  
            Started by lightsun47, Today, 03:51 PM
            0 responses
            8 views
            0 likes
            Last Post lightsun47  
            Working...
            X