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 funk10101, Today, 12:02 AM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by GLFX005, Today, 03:23 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by nandhumca, Yesterday, 03:41 PM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by The_Sec, Yesterday, 03:37 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by vecnopus, Today, 06:15 AM
      0 responses
      1 view
      0 likes
      Last Post vecnopus  
      Working...
      X