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

Strategy Not Looping code

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

    Strategy Not Looping code

    Hi guys,

    I'm having trouble with a strategy that kicks off trades using a Bollinger line.

    for example

    OnBarUpdate=False

    If [close] CrossAbove Bollinger [Lower] BarsAgo=0
    Buy

    If [close] CrossBelow Bollinger [Lower] BarsAgo =0
    Sell

    The problem occurs when there is an intrabar spike through the line, say price action cross's above the Bollinger line, a Buy trade is placed, but within the same bar it then crosses below the line, the strategy doesn't close out and go short and vice versa when part of the code is kicking off trades from the upper Bollinger line.

    I'm using a 7 min chart on the HangSeng.

    Any suggestions would be appreciated.

    Thanks

    Leonie

    #2
    Within one bar going above the line means a cross above, but coming back down below the line is not a cross below. To determine a cross above/below it uses two data points, the current bar and the previous bar. Just because you are above on one tick and not above on another does not mean a cross below in relation to the previous bar.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by elirion, Today, 09:32 PM
    0 responses
    1 view
    0 likes
    Last Post elirion
    by elirion
     
    Started by cre8able, Today, 09:15 PM
    1 response
    3 views
    0 likes
    Last Post bltdavid  
    Started by cummish, Today, 08:43 PM
    0 responses
    6 views
    0 likes
    Last Post cummish
    by cummish
     
    Started by Option Whisperer, Today, 07:58 PM
    4 responses
    18 views
    0 likes
    Last Post Option Whisperer  
    Started by ETFVoyageur, 05-07-2024, 07:05 PM
    13 responses
    87 views
    0 likes
    Last Post ETFVoyageur  
    Working...
    X