![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Jul 2009
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
|
When writing a Strategy Script, how can I test for the Background Color of the chart that was used on the Previous Bar?
Thanks, jhill |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi jhill,
There's unfortunately no supported way to access this from a strategy. You need to be able to know the conditions that caused a background color change, and can then use these same conditions in a strategy.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Jul 2009
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks very much for your prompt reply.
jhill |
|
|
|
|
|
#4 |
|
Member
Join Date: Jul 2009
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Ryan,
One more question if I may. When writing a Strategy Script, how can I test for the Background Color of the chart that is used on the current Bar? Thanks, jhill |
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
There is no way to access this from any bar. You need the underlying conditions that cause a background color change.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Member
Join Date: Jul 2009
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Ryan for your response. The conditions that you referred to are in a 3rd party Indicator script. Since I won’t be needing the plotting logic in my Strategy Script, can you suggest a simple way of eliminating the script that is only associated with the actual plotting, keeping only the conditions necessary for determining a color change?
Also, I use 4 different indicators in order to visually place a trade, so do I assume correctly that I’ll have to merge the 4 of them together into one Strategy in order to properly place an Auto Trade? |
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
If you don't have the source code available for these indicators, you will not be able to access the color changing conditions from a strategy.
Without the source code from the indicator, the only values you can access from the strategy are indicator plots. Best may be to work with the 3rd party vendor to see if they offer an automated trading system based on their indicators.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Member
Join Date: Jul 2009
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
|
Again, thanks for your time and prompt responses. I have set up a good Trading methodology using these indicators but wanted to try and create an auto system for me to eliminate the Psy. problems that I have in pulling the trigger. I'll keep plugging along to try and get the auto system to work.
jhill |
|
|
|
|
|
#9 |
|
Member
Join Date: Jul 2009
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Ryan, your response resulted in one more question.
Thanks for your prompt response! I have the .cs files from the 3rd party, for the indicators I currently use, and have opened them with the NinjaScript Editor. I assume that these .cs files are the source code which you addressed in the previous email? If so, is there a simple way to create a Strategy from the Indicator script? Thanks, jhill |
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Yes .cs can be used as source files, but also as a wrapper for protected dlls.
If you can view the indicator source code, you should be able to see the conditions that result in background color change. You can use the same conditions that are in the indicator code in your strategy, or create a bool series from the conditions, and expose the values of the boolseries following this sample: http://www.ninjatrader.com/support/f...ead.php?t=4991
Ryan M
NinjaTrader Customer Service
Last edited by NinjaTrader_RyanM; 08-15-2011 at 01:36 PM.
|
|
|
|
|
|
#11 |
|
Member
Join Date: Jul 2009
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
|
Again Ryan your time and responses are very much appreciated.
thanks, jhill |
|
|
|
|
|
#12 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
You're welcome, jhill. Best of luck with the strategy creation. Let me know if you have any additional questions.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Member
Join Date: Jul 2009
Posts: 41
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Ryan,
I have pasted below, the script that I added to my Indicator and Strategy, which follows the Strategy and Indicator examples in the SampleBoolSeries.zip from NT. My Indicator compiled fine, but the Strategy generated an error. Could you look at the code and help me understand what I need to correct? Thanks so much for your help! MY STRATEGY: protected override void Initialize() { // Add(JnD_ZlemaVma(14,6,9)); //JnD // Add(JnD_ZlemaVma()); //JnD CalculateOnBarClose = false; } MY INDICATOR: namespace NinjaTrader.Indicator { [Description("Combination of ZLEMA and VMA with background shading when the two cross. (v7.1)")] public class JnD_ZlemaVma : Indicator /* Revision 0. Combined indicators and used background flooding schemes and rising/falling selectable colors. Revision 1. Corrected error that removed changes to background flooding when the program was rebooted. */ { #region Variables private int zlemaPeriod = 14; private int downIntensity = 65; private int upIntensity = 75; private int direction = 0; private int lag = 0; private int vmaPeriod = 9; private int volatilityPeriod = 9; private double value1 = 0; private double value2 = 0; private double k = 0; private double oneMinusK = 0; private bool showFlooding = true; private Color backColorUp = Color.Green; private Color backColorDown = Color.Red; private Color colorUp = Color.Green; private Color colorDown = Color.Red; private DataSeries zlemaSeries; private BoolSeries bearIndication; //JnD private BoolSeries bullIndication; //JnD private double exposedVariable; //JnD #endregion |
|
|
|
|
|
#14 | |
|
Senior Member
|
Quote:
In other words, if the indicator generates trade signals, then the calculation logic behind those signals is implied by the signals themselves: you only need to process the signals, as if they were coming from a black box, which, in the absence of the source code, they in fact, are. |
|
|
|
|
|
|
#15 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
In your indicator code, you need a couple more components:
You need to set the boolseries when your condition is true. You need the properties region linking the private boolseries to the public (Uppercase) one that you then reference in your strategy. This is all in the sample you downloaded, so will have to look at how it's used there and do the same in your scripts.
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Accessing Previous Bar Data Question | Dreamer88zzz | Indicator Development | 1 | 01-25-2011 06:57 AM |
| if Target Profit reached on previous bar, dont trade current bar | paschall | Strategy Development | 4 | 09-02-2009 10:34 PM |
| Current Bar Open Equals Previous Bar Close | ramacan | Charting | 6 | 05-23-2009 11:07 AM |
| High and Low of previous bar and actual bar | Fernando | Miscellaneous Support | 1 | 03-18-2009 10:54 AM |
| CrossBelow previous bar and omit current bar | ct | General Programming | 1 | 06-03-2007 02:54 AM |