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 DayTradingDEMON, Today, 09:28 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by cmtjoancolmenero, Yesterday, 03:58 PM
    8 responses
    31 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by helpwanted, Today, 03:06 AM
    2 responses
    22 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by navyguy06, Today, 09:28 AM
    0 responses
    5 views
    0 likes
    Last Post navyguy06  
    Started by rjbtrade1, 11-30-2023, 04:38 PM
    2 responses
    77 views
    0 likes
    Last Post DavidHP
    by DavidHP
     
    Working...
    X