Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X