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

inside bar

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

    inside bar

    I am looking for an inside bar strategy...

    Basically:

    - Check (current bar low > previous bar low) AND (current bar high < previous bar high)
    - If true either

    go long current bar high + 1, stop loss current bar low -1

    Or
    go short current bar low -1, stop loss current bar high + 1

    thanks

    #2
    Hello,

    You can implement this as an inside-bar strategy by adding a secondary data series with a lower-timeframe interval, then testing its highs and lows against the highs and lows of the previous higher-timeframe bar. For example, you might do something like this for entries:

    Code:
     protected override void Initialize()
            {
                CalculateOnBarClose = true;
    	    Add(PeriodType.Minute,1);
            }
    
            protected override void OnBarUpdate()
            {
    			if(BarsInProgress == 1)
    			{
    				if(Highs[1][0] > Highs[0][1])
    				{
    					//entry order
    				}
    			}
            }
    For exits, you can use the SetStopLoss() overload below, set the calculation mode to Price, then pass in Lows[0][0] +/- TickSize:

    Code:
    SetStopLoss(CalculationMode mode, double value)
    For more information, please see the links below:

    BarsInProgress: http://www.ninjatrader.com/support/h...inprogress.htm

    Highs: http://www.ninjatrader.com/support/h...html?highs.htm

    SetStopLoss: http://www.ninjatrader.com/support/h...etstoploss.htm

    Reference Sample: http://www.ninjatrader.com/support/f...ead.php?t=5787

    Please let me know if I can assist further.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Hello,

      I'd like to make a quick note. My previous reply was assuming that you were looking for a intra-bar execution on this strategy. If you are just looking for an "inside bar" candlestick pattern, then you would not need to use the secondary timeframe. You could just use High[] and Low[], like so:

      Code:
      if(High[0] < High[1] && Low[0] > Low[1])
      The exit logic would be the same as my previous post.
      Dave I.NinjaTrader Product Management

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by llanqui, Today, 12:51 PM
      1 response
      2 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by llanqui, Today, 11:13 AM
      6 responses
      11 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by cmtjoancolmenero, 04-29-2024, 03:40 PM
      22 responses
      70 views
      0 likes
      Last Post cmtjoancolmenero  
      Started by reynoldsn, Yesterday, 04:40 PM
      2 responses
      13 views
      0 likes
      Last Post reynoldsn  
      Started by i2ogu3, Yesterday, 11:31 PM
      2 responses
      20 views
      0 likes
      Last Post i2ogu3
      by i2ogu3
       
      Working...
      X