[Description("Enter the description of your strategy here")] public class BollingerStrategy1 : Strategy { #region Variables // Wizard generated variables // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { CalculateOnBarClose = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Condition set 1 if (CrossAbove(Close, Bollinger(2, 14).Lower, 1)) { EnterLong(DefaultQuantity, ""); } // Condition set 2 if (CrossBelow(Close, Bollinger(2, 14).Upper, 1)) { ExitLong("", ""); } } #region Properties #endregion } }
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
I need help with Bollinger Bands strategy
Collapse
X
-
I need help with Bollinger Bands strategy
I have created a simple BB strategy that buys when close price crosses above lower band and sells when close price crosses below upper band. The problem I am having is that ther are many places throughout the chart where there no buys or sells even though close price condition is met. My code is below. Thank you
Code: -
relogical, thanks for the post and welcome to our forums here - to which Bollinger Band settings are you comparing the strategy signals? Are you sure you're using the same paramters for those as the strategy would (it uses the default 14, 2) settings here...given a short period and relatively high deviation value I wouldn't expect all swings to generate a signal...but of course would depend on market and timeframe traded. To see visually when a condition trigger would occur it can be very helpful to draw from the strategy as well -
http://www.ninjatrader.com/support/h...gy_actions.htm (last section here please)BertrandNinjaTrader Customer Service
-
Agreed. What you are indicating would be the LOW crossing below the lower BB, not the close. I don't think there is an error in your code. I think you might be expecting something else from it, though.
EDIT: In fact, I'm not even sure why the BUY and SELL orders were triggered on the bars indicated in your graphic. I would not have expected any trades from this time period, since none of the bar closes were above or below the BBs.Last edited by Kevin_in_GA; 06-07-2012, 08:18 AM.
Comment
-
BB on MACD
Is there any way to place a Bolinger band ,applied to to a MACD sug graph,and hav eit apply to the BB and not the pirce chart plez?
Comment
-
laredo,
I would suggest creating a new thread to discuss this as we may need to ask you a few questions related to what it is you are trying to do, that and it isn't specifically related to what the original poster was discussing.
You can create a new thread by going here : http://www.ninjatrader.com/support/f...splay.php?f=15
Then, click the "New Thread" button like in the screen shot.Adam P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Johndc, Today, 04:39 AM
|
0 responses
2 views
0 likes
|
Last Post
by Johndc
Today, 04:39 AM
|
||
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
7 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
12 views
0 likes
|
Last Post Today, 02:00 AM | ||
Started by Mariawilcoxi, Today, 01:32 AM
|
0 responses
5 views
0 likes
|
Last Post
by Mariawilcoxi
Today, 01:32 AM
|
||
Started by gleichnerany, Today, 01:17 AM
|
0 responses
5 views
0 likes
|
Last Post
by gleichnerany
Today, 01:17 AM
|
Comment