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 marcus2300, Today, 10:21 AM
    0 responses
    0 views
    0 likes
    Last Post marcus2300  
    Started by DawnTreader, 05-08-2024, 05:58 PM
    10 responses
    38 views
    0 likes
    Last Post DawnTreader  
    Started by gaz0001, Today, 10:09 AM
    0 responses
    2 views
    0 likes
    Last Post gaz0001
    by gaz0001
     
    Started by proptradingshop, Today, 10:07 AM
    0 responses
    2 views
    0 likes
    Last Post proptradingshop  
    Started by franatas, Today, 09:49 AM
    1 response
    2 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X