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

Candle time

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

    Candle time

    Hello, I am confused about how the candles work, I see now that the time it shows in the chart is when the candle closes.
    So, if I want to create a strategy based on the candle that closes at 7:30, should I use time = 7:30? see image.
    Would this work if I want to buy/sell with the candle after it? it would be the candle that opens at 7:30 and closes at 7:31, in the chart it would be candle 7:31
    I hope I make sense. if I set the time at 7:30, would it work at 7:30:01?
    Attached Files

    #2
    Hello Mathias79,

    Thank you for your post.

    You are correct; candles are stamped with the closing time of the bar. If you want a strategy condition based on the candle that closes at 7:30, you would want to check if the time of the candle equals 7:30. If you would like to refer to a candle that opens at 7:30 and closes at 7:31, that would be if time equals 7:31. If you check for the time to equal 7:30:01, there may not be a candle that matches that timestamp unless you have a candle that closed at that 1 second mark. To help illustrate what time is associated with each bar, you could consider adding print statements in your strategy for a deeper understanding:


    We also have a reference sample that demonstrates how to use a time filter to check the time of a candle so that it limits the trading hours within a certain time:


    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your help...
      what I meant by 7:30:01 is that one second after 7:30 it would be the next candle = 7:31 and that is when my strategy would execute if I say, for example, buy/sell after the high/low of candle that equals 7:30. based on what you share, I think that is how it will work, right?

      Comment


        #4
        Hello Mathias79,

        Thank you for your reply.

        It will depend on whether your strategy is calculating On Bar Close, On Price Change, or On Each Tick. If the strategy is calculating On Bar Close, it will not be capable of intrabar actions and would only be able to check the time of the candle once it is closed and the first tick of the next candle begins to form. If you wanted to enter immediately on the next candle after 7:30, you could set the condition to check for 7:30 and as soon as that bar closes the action will take place.

        As for checking for 7:30:01 that does not equal 7:31. You could try adding a print statement to see if that type of condition ever becomes true, though it may not because the bar time stamp will never equal that timestamp exactly. Another thing you could consider is checking if the time is greater than or equal to 7:30:01 and in that case, the 7:31 candle should meet that condition.

        Ultimately, I suggest testing it out on a simulated account. Try your conditions how you are explaining them and add prints to your strategy to understand which conditions are being met or not, and then you can modify your logic as needed. If you are not sure about which prints might be helpful, please provide a snippet demonstrating the logic you are trying to explain so I may better understand and assist you with some example prints you could try.

        Thank you for your time and patience. Please let us know if we may be of further assistance.
        Emily C.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,406 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        98 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        8 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        160 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        9 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X