Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

enter short when price < 3 day low

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

    enter short when price < 3 day low

    I am working on a simple piece of code, but am having trouble with Ninja Trader doing the entry signal correctly.

    The code is suppose to enter short position at market when on the low of the previous 3 periods is met.

    When I put the strategy into a daily chart, I have it "calculate on bar close" set to "false" which would allow it to signal within a daily chart time frame is the idea.

    The strategy is always entering into a position at the open price of a bar for some odd reason and not somewhere within the bar is one of the glaring problems that I see.

    I am using the current bid price < low of prior days as you see here is the actual code:

    if (GetCurrentBid() < Low[1]
    && GetCurrentBid() < Low[2]
    && GetCurrentBid() < Low[3])
    {
    EnterShort(Cars, "SE");

    I have included the total code as well as an attachment if anyone is interested.

    Does anyone see what I am doing wrong?

    Thanks in advance...
    Attached Files

    #2
    Are you backtesting? GetCurrentBid() always returns as the close price of the bar during backtests.

    Also in backtesting you will only be able to place trades on the next bar which usually ends up having trades enter at the open of that next bar. You cannot trade on the signal bar despite CalculateOnBarClose = false during backtesting because you always have the Close value of the signal bar. Since the bar is closed it is untradeable.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      solution?

      ok, that makes sense... but is there a solution?

      What I am trying to do sounds simple enough.

      Any ideas what the logical way to code what I am wishing to accomplish keeping in mind what you state is appreciated...

      Comment


        #4
        For backtesting you simply cannot trade on the same bar as the signal bar. In real-time this is not the case though.

        Solutions could include multi-time framed strategies that include daily and minute bars. You take your daily time frame for signal, but submit to minute time frame. Please see this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=6652

        Alternatively you could try and get the Low of the previous three days through the use of PriorDayOHLC(). You will need to pass in a very high barsAgo parameter to get it all the way back at 1 day ago, 2 days ago, and 3 days ago.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        11 responses
        39 views
        0 likes
        Last Post cmtjoancolmenero  
        Started by FrazMann, Today, 11:21 AM
        0 responses
        3 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by DayTradingDEMON, Today, 09:28 AM
        4 responses
        26 views
        0 likes
        Last Post DayTradingDEMON  
        Started by George21, Today, 10:07 AM
        1 response
        22 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X