• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enter at Same-bar Close ?

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

    Enter at Same-bar Close ?

    I'm developing an Overnight daily strategy (Buy at Same-day-Close, Sell at next-day-Open).
    My Buy rules and indicators are based on Daily bars, hence i'm using Daily bars

    1) While backtesting/optimization, is there an easy way to specify Buy-at-Same-Day-Close?
    2) If not and i have to run Intra-day, how do i develop rules using Daily Close prices for the last N days and use daily indicators (e.g. ATR, Stochastic etc)? Some e.g. rules -
    - 3 concurrent days of lower Close
    - N-day High (on daily bars)
    - Daily Close drops by 1*ATR(25 days)

    thanks
    Kiran

    #2
    Hello Kiran,

    Thank you for writing in and thank you for your patience. As far as I am aware this would have to run intra-day because with calculate on bar close set to true, the order to enter wouldn't be filled until the open of the next day's bar, and with calculate on bar close set to false, it would be intra-day already.

    If you are running a 1 day chart with calculate on bar close set to false and the session template set to "Default 24/7" or "Default 24/5", you would simply enter at the regular session close time and exit at the first tick of the next bar by checking the FirstTickOfBar variable.

    On a 1 day chart, 3 concurrent days of lower closes would look like this:
    Code:
    if(Close[0] < Close[1] && Close[1] < Close[2] && Close[2] < Close[3])
    {
    //Do something
    }
    However you would have to keep in mind that with calculate on bar close set to false, the Close[0] value would always be in flux until it became Close[1]. If this is an issue, you would use the following which would determine if yesterday's close was lower than the day before it, and on and on:
    Code:
    if(Close[1] < Close[2] && Close[2] < Close[3] && Close[3] < Close[4])
    {
    //Do something
    }
    The N-Day high would be something like the following:
    Code:
    Print(HighestBar(High, N)); //N being the number of bars
    For your last question I would need further clarification as to what you mean. Are you asking if the current close is less than the previous close - the 25 day ATR value?
    Code:
    if(Close[0] < Close[1] - ATR(25)[0])
    {
    //Do something
    }
    Please let me know if I may be of further assistance.
    Michael M.NinjaTrader Quality Assurance

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mestril, Today, 06:00 AM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by Bionian, Yesterday, 11:47 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by Gerik, Today, 12:14 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by Goolden, Today, 05:47 AM
    0 responses
    7 views
    0 likes
    Last Post Goolden
    by Goolden
     
    Started by kujista, Today, 12:59 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_PatrickG  
    Working...
    X