I'm trying to build a strategy based on linear regression channel indicator. The idea is to enter short when price crosses above upper let's say 2 standard deviations line and to enter to enter long when price crosses below lower 2 standard deviations band. Unfortunately I have had no luck so far. Could somebody help me with this, please
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!
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
NinjaTrader
Regression channel strategy
Collapse
X
-
Regression channel strategy
Hello,
I'm trying to build a strategy based on linear regression channel indicator. The idea is to enter short when price crosses above upper let's say 2 standard deviations line and to enter to enter long when price crosses below lower 2 standard deviations band. Unfortunately I have had no luck so far. Could somebody help me with this, pleaseTags: None
-
Hello Alex Ledenev,
From the given details I couldn't really point a direction as I don't know what you tried or what was wrong when you tried it. If you can provide more details about what you tried and what the result was we could try to provide more help with the added context.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
-
Hello Jessy ,
Thank you for your reply and your willingness to help. You are 100% right, from my post it's unclear what I'm trying to do, so let me give you more details.
The goal of the strategy is to enter long when the price crosses below lower band of the regression channel and enter short when the price crosses above the upper band. Below the width of the channel is two standard deviations both ways and I want to enter short if the price crosses above 15951
I want to build strategy that will enter position if either band is crossed and take 4 ticks profit. Stop-15 ticks. So here how I tried to do it
I tried to backtest it and even got some results, but when I turn this strategy on on the chart nothing happens. Long position won't open when the price breaks through the lower band and I don't see my mistake unfortunately. Hope this clarifies what I'm struggling with and if you need any additional information, please let me know. Thank you again for your help
Comment
-
Hello Alex Ledenev,
A CrossAbove is considered when the previous bar value is lower, and the next bar value is at or above.
Please note that GetCurrentBid does not have any historical values like a Price Series (I. E. Open, High, Low, Close) So it is not well used with Crossover conditions which compare the previous value of a PriceSeries/Indicator to the current value of the PriceSeries/Indicator. I would suggest using Close in your crossover condition, or to consider making larger conditions using less than/greater than.
As another tip, it can be helpful to add debug prints so you can see the exact same values the strategy is processing in its logic, when that logic is processed. This can make it clear why some conditions are evaluating the way they are when you expect otherwise.
Debugging in the Strategy Builder - https://drive.google.com/file/d/1mTq...w?usp=drivesdk
JimNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Jim View PostHello Alex Ledenev,
A CrossAbove is considered when the previous bar value is lower, and the next bar value is at or above.
Please note that GetCurrentBid does not have any historical values like a Price Series (I. E. Open, High, Low, Close) So it is not well used with Crossover conditions which compare the previous value of a PriceSeries/Indicator to the current value of the PriceSeries/Indicator. I would suggest using Close in your crossover condition, or to consider making larger conditions using less than/greater than.
As another tip, it can be helpful to add debug prints so you can see the exact same values the strategy is processing in its logic, when that logic is processed. This can make it clear why some conditions are evaluating the way they are when you expect otherwise.
Debugging in the Strategy Builder - https://drive.google.com/file/d/1mTq...w?usp=drivesdk
Thank you very much for your reply. As you advised I changed to CrossBelow when the price hits upper band of the Regression Channel and boom, the strategy started to work, but only in case of upper band and entering short position. Now I'm struggling with opposite scenario: when the price hits lower band I want to enter into a long position and for some reason, I don't really understand why, it doesn't work. I mean, the programming logic is the same ( I only changed settings to the appropriate band and trade direction) but it just doesn't want to work. Also the color of the Buy strategy name remains yellow while the color of the working Sell strategy turned to green and strategy works like a charm.
Any idea what can be wrong with my programming? Thank you very much in advance.
Comment
-
Hello Alex Ledenev,
A Yellow strategy means you enabled it with WaitUntilFlat, and the strategy detected it would be in the middle of a position based on the processed historical data. The strategy is waiting for the position to close before the strategy can enter with an entry order. Please be sure to review the Running NinjaScript Strategies documentation below for clarity on Strategy/Account positions and how the Start Behaviors work. Strategy vs. Account Position and Syncing Account Positions are important to review to understand what a Yellow strategy means.
Running NinjaScript Strategies - https://ninjatrader.com/support/help...strategies.htm
It is quite likely that you do not see your buy take place because the strategy is in a position, waiting for the position to become flat before it can enter live.
Please also confirm with prints that the strategy is reaching your order submission methods when you expect.
JimNinjaTrader Customer Service
Comment
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Mestor, 03-10-2023, 01:50 AM
|
11 responses
303 views
0 likes
|
Last Post
by z.franck
Today, 02:29 AM
|
||
Started by Padan, Today, 02:02 AM
|
0 responses
6 views
0 likes
|
Last Post
by Padan
Today, 02:02 AM
|
||
Started by bukowa, 11-09-2023, 06:07 PM
|
20 responses
407 views
0 likes
|
Last Post
by Adfra
Today, 01:36 AM
|
||
Started by yertle, Yesterday, 05:49 PM
|
2 responses
11 views
0 likes
|
Last Post
by yertle
Today, 12:12 AM
|
||
Started by kaywai, Today, 12:06 AM
|
0 responses
10 views
0 likes
|
Last Post
by kaywai
Today, 12:06 AM
|
Comment