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 PaulMohn, Today, 03:49 AM
      0 responses
      6 views
      0 likes
      Last Post PaulMohn  
      Started by inanazsocial, Today, 01:15 AM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by rocketman7, Today, 02:12 AM
      0 responses
      10 views
      0 likes
      Last Post rocketman7  
      Started by dustydbayer, Today, 01:59 AM
      0 responses
      4 views
      0 likes
      Last Post dustydbayer  
      Started by trilliantrader, 04-18-2024, 08:16 AM
      5 responses
      23 views
      0 likes
      Last Post trilliantrader  
      Working...
      X