![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jun 2010
Posts: 25
Thanks: 0
Thanked 0 times in 0 posts
|
Hallo,
I want to use my residual indicator in a strategy. I want to do something if the indicator crossbelow 2. How should I do that? I tried somthing like: int Variable0 =2; ... // Condition set 1 if (CrossBelow(SpreadPlot2(10, 1, 10, "").Upper, Variable0, 10)) { PrintWithTimeStamp("works"); } But there occurs nothing in the output window. Thank you in advance. Benjamin |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
bascher,
Can we see some code for the SpreadPlot2 indicator? Its possible that this would never cross below 2, for example if the tick size is small.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jun 2010
Posts: 25
Thanks: 0
Thanked 0 times in 0 posts
|
Hallo Adam,
thank you for your reply. I have got the following code: #region Variables // Wizard generated variables private int Variable0 = 1; // 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 the second instrument Add("$USDCAD", PeriodType.Minute, 1); // Add the indicator with the values period=10, MyInput0=1, Frequency=10 //and second instrument=$USDCAD Add(SpreadPlot2(10, 1, 10, "$USDCAD")); } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Condition set 1 // If SpreadPlot indicator cross below Variable0=1 print to outputwindow="works" if (CrossBelow(SpreadPlot2(10, 1, 10, "$USDCAD"), Variable0, 1)) { PrintWithTimeStamp("works"); } } But it happens nothing. What I have to change? Thank you in advance. Best regards Benjamin |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
Hello,
I would suggest trying this : Variable0 = 2*TickSize; if (CrossBelow(SpreadPlot2(10, 1, 10, "$USDCAD"), Variable0, 1))
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Jun 2010
Posts: 25
Thanks: 0
Thanked 0 times in 0 posts
|
The condition variable is correct but I am not sure how to call the indicator and in which order this should be done.
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
bascher,
I suspect that the following is the issue here : CrossAbove(SpreadPlot2(10, 1, 10, "$USDCAD"), Variable0, 1) This may never occur. The Variable0 = 2 will make the CrossAbove check to see if the spread calculation crosses above 2. Generally, spreads are Price1 - Price2 and will be something like 0.001 or something to that effect. Does your spread indicator convert to ticks? What values does the Spread indicator output?
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Jun 2010
Posts: 25
Thanks: 0
Thanked 0 times in 0 posts
|
Attached is the output of my SpreadPlot indicator. There occurs nothing if cross below the value 1.I tried:
protected override void OnBarUpdate() { // Condition set 1 if (CrossBelow(SpreadPlot2(10, 1, 10, "").Plot0, Variable0, 1)) { Print("funktioniert"); } } because .Plot0 is the property of the indicator public DataSeries Plot0 { get { return Values[0]; } } Values refered to: if(outputStarted) Value.Set(output); Print(output); ??? and this is printed as: Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0")); But without any success. |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
bascher,
You tried using Variable0 = 1? In that example you showed me the value of spread doesn't seem like it ever reached 2.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Jun 2010
Posts: 25
Thanks: 0
Thanked 0 times in 0 posts
|
I have changed this value to 1.
Can I send you the indicator an you will take a look? |
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
bascher,
I can take a look, but I would need the spread indicator and your strategy. We don't typically offer full debugging assistance however if its simple we don't mind taking a peek and seeing if something is immediately obvious. You can send it to support at ninjatrader dot com with ATTN : Adam in the message.
Adam P.
NinjaTrader Customer Service |
|
|
|
![]() |
| Tags |
| pairs, strategy |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| End of session BaRs problem/Residual ticks | david111 | Version 7 Beta General Questions & Bug Reports | 3 | 04-15-2010 09:08 AM |
| Add warning to check for residual trailing stops | WhoKnows | Suggestions And Feedback | 1 | 02-03-2009 03:33 AM |