I have about 4 different trading systems that I have worked on. I was wondering is it possible to mash all 4 systems into one system. I tried using the AND (&&) function and adding all of them together but it seems not to work. Any suggestions on how to set this up.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Mash Trading Systems
Collapse
X
-
Mash Trading Systems
Hello Ninjatrader Team,
I have about 4 different trading systems that I have worked on. I was wondering is it possible to mash all 4 systems into one system. I tried using the AND (&&) function and adding all of them together but it seems not to work. Any suggestions on how to set this up. -
Originally posted by wallsteetking View PostHello Ninjatrader Team,
I have about 4 different trading systems that I have worked on. I was wondering is it possible to mash all 4 systems into one system. I tried using the AND (&&) function and adding all of them together but it seems not to work. Any suggestions on how to set this up.
-
Yes, For example
Strategy 1: MA Cross Over
Strategy 2: Stochastic
Strategy 3: MACD
Strategy 4: Volume
================================================== ================
Sometimes all of the systems fire a Long position on the same BAR.. see pic. What I want to see is, If I mash all of the systems together and they all fire a long position on the same bar how profitable is it historically.Last edited by wallsteetking; 12-28-2012, 10:23 AM.
Comment
-
Originally posted by wallsteetking View PostYes, For example
Strategy 1: MA Cross Over
Strategy 2: Stochastic
Strategy 3: MACD
Strategy 4: Volume
================================================== ================
Sometimes all of the systems fire a Long position on the same BAR.. see pic. What I want to see is, If I mash all of the systems together and they all fire a long position on the same bar how profitable is it historically.
Comment
-
can you direct me on how to do this. My coding skills are average. I have no idea what boolean flag means or how to glue the codes together. is there an example that I can fallow or help page???
Comment
-
Hello,
We really do not have any specific examples, but here is a link to some basic programming concepts to help you:
A boolean flag is going to be a true/false variable that you can set when the condition is true.
For example
Code:if(yourMACDCondition) { macdFlag = true; } if(yourStochasticCondition) { stochFlag = true; }
Code:if(stochFlag == true && macdFlag == true) { //do something }
MatthewNinjaTrader Product Management
Comment
-
Hi, I keeping getting error message please see picture
here is the code (A1 And A2 are my personal 2 strategies)
Code:protected override void Initialize() { CalculateOnBarClose = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { Add(A1)()); Add(A2)()); // Condition set 1 if (A1) { A1Flag =true; } if (A2) { A2Flag =true; } if (A1Flag == true && A2Flag == true) { EnterLong(DefaultQuantity, ""); } }
Comment
-
-
Originally posted by wallsteetking View Postwhat is the correct way of doing it?
You then replace your orders as necessary. Using 2 strategies as source for example, you might declare new class Boolean variables:
Code:private bool EnterLongStrat1 = false; private bool EnterShortStrat1 = false; private bool EnterLongStrat2= false; private bool EnterShortStrat2 = false;
Then where you have EnterLong(...) in Strategy1, you will replace it with
Code:EnterLongStrat1 = true;
You then enter long if all the EnterLongStratx values are true, and short if all the EnterShortStratx are true.
Use the OnPositionUpdate() event handler to reset all the bools when you go flat. The example in the NT help details exactly that scenario.Last edited by koganam; 01-16-2013, 04:19 PM.
Comment
-
I am having a very hard time figure this out. please help me resolve this issue.
TO BE CLEAR I WANT TO MASH 2 of my strategies. NOT indicators.
Strategy 1 is called A1
I want to put strategy A1 into my MASHALL <-( mashall will be the main strategy)
For now I will NOT worry about strategy A2. I just want to add A1 into MASHALL
ALSO Both strategies are LONG never short
Here is the code for A1
Code:// This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { /// <summary> /// Enter the description of your strategy here /// </summary> [Description("Enter the description of your strategy here")] public class A1 : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 private BoolSeries a1bear; private BoolSeries a1bull; // User defined variables (add any user defined variables below) private double exposedVariable; #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() { a1bear = new BoolSeries(this); a1bull = new BoolSeries(this); CalculateOnBarClose = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (Close[0] >= EMA(20)[0] && Close[0] >= Close[1] + 15 * TickSize && Close[0] >= Open[0]) { a1bull.Set(true); a1bear.Set(false); } exposedVariable = Close[0]; } #region Properties [Description("")] [GridCategory("Parameters")] public int MyInput0 { get { return myInput0; } set { myInput0 = Math.Max(1, value); } } [Browsable(false)] [XmlIgnore()] public BoolSeries A1bull { get { return a1bull; } // Allows our public BearIndication BoolSeries to access and expose our interal bearIndication BoolSeries } [Browsable(false)] [XmlIgnore()] public BoolSeries A1bear { get { return a1bear; } // Allows our public BullIndication BoolSeries to access and expose our interal bullIndication BoolSeries } #endregion }
The issue becomes when I try to put this in MASHALL
Code:// This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { /// <summary> /// Enter the description of your strategy here /// </summary> [Description("Enter the description of your strategy here")] public class MASHALL : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 // 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; Add(A1()); } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { { EnterLong(DefaultQuantity, ""); } }
Code:CalculateOnBarClose = true; Add(A1[]);
'NinjaTrader.Strategy.A1' is a 'type' but is used like a 'variable'
does not work.
The error I get with Add(A1[]);[/CODE]
Argument expected.
'NinjaTrader.Strategy.A1' is a 'type' but is used like a 'variable'
Statement expected.
Syntax error; value expected
How to i Fix this issue?????
Comment
-
Originally posted by wallsteetking View PostI am having a very hard time figure this out. please help me resolve this issue.
TO BE CLEAR I WANT TO MASH 2 of my strategies. NOT indicators.
Strategy 1 is called A1
I want to put strategy A1 into my MASHALL <-( mashall will be the main strategy)
For now I will NOT worry about strategy A2. I just want to add A1 into MASHALL
ALSO Both strategies are LONG never short
Here is the code for A1
Code:// This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { /// <summary> /// Enter the description of your strategy here /// </summary> [Description("Enter the description of your strategy here")] public class A1 : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 private BoolSeries a1bear; private BoolSeries a1bull; // User defined variables (add any user defined variables below) private double exposedVariable; #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() { a1bear = new BoolSeries(this); a1bull = new BoolSeries(this); CalculateOnBarClose = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (Close[0] >= EMA(20)[0] && Close[0] >= Close[1] + 15 * TickSize && Close[0] >= Open[0]) { a1bull.Set(true); a1bear.Set(false); } exposedVariable = Close[0]; } #region Properties [Description("")] [GridCategory("Parameters")] public int MyInput0 { get { return myInput0; } set { myInput0 = Math.Max(1, value); } } [Browsable(false)] [XmlIgnore()] public BoolSeries A1bull { get { return a1bull; } // Allows our public BearIndication BoolSeries to access and expose our interal bearIndication BoolSeries } [Browsable(false)] [XmlIgnore()] public BoolSeries A1bear { get { return a1bear; } // Allows our public BullIndication BoolSeries to access and expose our interal bullIndication BoolSeries } #endregion }
The issue becomes when I try to put this in MASHALL
Code:// This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { /// <summary> /// Enter the description of your strategy here /// </summary> [Description("Enter the description of your strategy here")] public class MASHALL : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 // 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; Add(A1()); } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { { EnterLong(DefaultQuantity, ""); } }
Code:CalculateOnBarClose = true; Add(A1[]);
'NinjaTrader.Strategy.A1' is a 'type' but is used like a 'variable'
does not work.
The error I get with Add(A1[]);[/CODE]
Argument expected.
'NinjaTrader.Strategy.A1' is a 'type' but is used like a 'variable'
Statement expected.
Syntax error; value expected
How to i Fix this issue?????
My posts in this thread have given you the skeleton of how to concatenate the code from multiple strategies. If you want the exact, specific code written for your precise setup, you may want to pay someone (not necessarily me) to write it for you.
Whoever you pay to code for you is likely to know what to do, but you can always refer them to this thread. All the information needed is in here.
Comment
-
koganam thank you for the fast replay, but this should not be that hard to do, either there is something that I am missing or I am not given the correct information. Also, I tried it your way for some reason it doesn't work either can you look at the code and give me some advice. Thank you
Code:/// <summary> /// Enter the description of your strategy here /// </summary> [Description("Enter the description of your strategy here")] public class MASHALL : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 private bool enterLongStrat1 = false; private bool enterLongStrat2= false; // 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; SetProfitTarget("", CalculationMode.Ticks, 4); } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Strategy 1 if (Bars.BarsSinceSession >=7) if (Stochastics(7, 14, 3).D[0] >= 30) { enterLongStrat1 = true; enterLongStrat2 = false; DrawTriangleUp("My triangle up" + CurrentBar, true, 0, High[0] + 20 * TickSize, Color.Red); } //Strategy 2 if (Bars.BarsSinceSession >=7) if ( Close[0] >= EMA(30)[0]) { enterLongStrat2 = true; enterLongStrat1 = false; DrawTriangleUp("My triangle up" + CurrentBar, true, 0, High[0] + 30 * TickSize, Color.Blue); } if (Bars.BarsSinceSession >=7) if(enterLongStrat2 == true && enterLongStrat1 == true) { EnterLong(DefaultQuantity, ""); } } #region Properties [Description("")] [GridCategory("Parameters")] public int MyInput0 { get { return myInput0; } set { myInput0 = Math.Max(1, value); } } #endregion
Last edited by wallsteetking; 07-19-2013, 03:13 AM.
Comment
-
Originally posted by wallsteetking View Postkoganam thank you for the fast replay, but this should not be that hard to do, either there is something that I am missing or I am not given the correct information. Also, I tried it your way for some reason it doesn't work either can you look at the code and give me some advice. Thank you
Code:/// <summary> /// Enter the description of your strategy here /// </summary> [Description("Enter the description of your strategy here")] public class MASHALL : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 private bool enterLongStrat1 = false; private bool enterLongStrat2= false; // 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; SetProfitTarget("", CalculationMode.Ticks, 4); } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Strategy 1 if (Bars.BarsSinceSession >=7) if (Stochastics(7, 14, 3).D[0] >= 30) { enterLongStrat1 = true; [B][COLOR=Blue] // [/COLOR][/B] enterLongStrat2 = false; DrawTriangleUp("My triangle up" + CurrentBar, true, 0, High[0] + 20 * TickSize, Color.Red); } //Strategy 2 if (Bars.BarsSinceSession >=7) if ( Close[0] >= EMA(30)[0]) { enterLongStrat2 = true; [B][COLOR=Blue] // [/COLOR][/B] enterLongStrat1 = false; [COLOR=Blue]now, then [B]both[/B] conditions can [B]never[/B] be simultaneously true if you have this[/COLOR] DrawTriangleUp("My triangle up" + CurrentBar, true, 0, High[0] + 30 * TickSize, Color.Blue); } if (Bars.BarsSinceSession >=7) if(enterLongStrat2 == true && enterLongStrat1 == true) { EnterLong(DefaultQuantity, ""); } } #region Properties [Description("")] [GridCategory("Parameters")] public int MyInput0 { get { return myInput0; } set { myInput0 = Math.Max(1, value); } } #endregion
Corrections are in blue in your code.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by rdtdale, Today, 01:02 PM
|
0 responses
1 view
0 likes
|
Last Post
by rdtdale
Today, 01:02 PM
|
||
Started by alifarahani, Today, 09:40 AM
|
3 responses
15 views
0 likes
|
Last Post Today, 12:47 PM | ||
Started by RookieTrader, Today, 09:37 AM
|
4 responses
18 views
0 likes
|
Last Post
by RookieTrader
Today, 12:46 PM
|
||
Started by PaulMohn, Today, 12:36 PM
|
0 responses
6 views
0 likes
|
Last Post
by PaulMohn
Today, 12:36 PM
|
||
Started by love2code2trade, 04-17-2024, 01:45 PM
|
4 responses
40 views
0 likes
|
Last Post Yesterday, 10:31 PM |
Comment