![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jul 2012
Posts: 6
Thanks: 3
Thanked 0 times in 0 posts
|
I am facing Multiple Timeframe issue.
The primary instrument is 5 min timeframe. I have initialized the other timeframes as below in Initialize() Add(PeriodType.Minute, 15); Add(PeriodType.Minute, 60); I have created a simple Spread function public double Spread(IDataSeries data1, IDataSeries data2) { return data1[0]-data2[0]; } I create a strategy where I want to compute a variable x such that x = Spread(15min-low, 60min-high)*100 Using x = Spread(Lows[1][0],Highs[2][0]) *100 doesnot work correctly due to datatype error. Please advise.
Last edited by ripwinkle; 07-29-2012 at 05:34 AM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
ripwinkle.
Could you show us the exact error here?
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jul 2012
Posts: 6
Thanks: 3
Thanked 0 times in 0 posts
|
the errors are as below :-
ErrorThe best overloaded method match for 'NinjaTrader.Strategy.Strategy.Spread(NinjaTrader. Data.IDataSeries, NinjaTrader.Data.IDataSeries)' has some invalid argumentsArgument '1': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries'Argument '2': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries' where method points to 'Spread' argument 1 points to 'Lows' argument 2 points to 'Highs' Please advise. |
|
|
|
|
|
#4 | |
|
Senior Member
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,184
Thanks: 178
Thanked 301 times in 259 posts
|
Quote:
but does this work? Code:
x = Spread(Lows[1],Highs[2]) *100; |
|
|
|
|
|
The following user says thank you to sledge for this post: |
|
|
|
#5 |
|
Junior Member
Join Date: Jul 2012
Posts: 6
Thanks: 3
Thanked 0 times in 0 posts
|
This does work Sledge and I have previously tried it also.
1. But I want to confirm if this is exactly going to provide the output that I originally intended ? Is Lows[1] = Lows[1][0] ? 2. Also, if the computation was not on the current bar, and I intended to compute on one bar ago i.e. x = Spread(Lows[1][1],Highs[2][1]) *100 then how can I achieve the same ? Please assist. |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jul 2012
Location: Houston, TX
Posts: 17
Thanks: 1
Thanked 15 times in 9 posts
|
ripwinkle,
Lows[1] refers to the dataseries of your 15 minute instrument. Lows[1][1] refers to the Low double value of [1] 15 minute candle ago. If you want to use the double values of a certain candle of your choice, instead of the current value, trying changing your function definition to take doubles as arguments instead of DataSeries': Code:
public double Spread(double data1, double data2) {
return data1-data2;
}
Code:
x = Spread(Lows[1][1],Highs[2][1]) *100 Kenny |
|
|
|
|
The following user says thank you to Coder_Kenny for this post: |
|
|
|
#7 |
|
Junior Member
Join Date: Jul 2012
Posts: 6
Thanks: 3
Thanked 0 times in 0 posts
|
Thanks Kenny!
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| multiple timeframe indiwator always 0 | altias | Market Analyzer | 3 | 04-12-2011 04:35 PM |
| Multiple Timeframe Question | canuck | Strategy Development | 20 | 12-12-2010 12:04 PM |
| Multiple Timeframe problem in 7.0 | paulca | Strategy Development | 1 | 11-12-2010 03:04 PM |
| Multiple Timeframe questions | paulca | Strategy Development | 3 | 07-24-2010 12:55 PM |
| multiple timeframe in a chart | stevebong | Charting | 1 | 02-20-2009 03:27 AM |