Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Help with getting in too late
Collapse
X
-
OK, so I'm getting closer in applying a secondary bar series for backtesting but am having some difficulties with the Ninja Script.
I'm getting an error saying that the MAX indicator can hold a max of 2 arguments, but with this rule, I can't add the secondary series:
MAX(BarsArray [1], High, 1) [1]
which holds 3 arguments (use secondary bar series on the max high of previous bar.
I tried using the high of the previous bar with secondary bar series, but is said 'high is a property but used like a method'....
Any ideas?
Comment
-
Thanks for answering all my questions so efficiently, can you help me as have tried for hours and cannot get this code to work.
protected override void Initialize()
{
Add(PeriodType.Minute, 15);
Add(SMA(57000));
Add(ATR(4));
CalculateOnBarClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired)
return;
if (BarsInProgress == 0)
{
// Condition set 1
if (Open[0] > SMA(57000)[1]
&& High[0] > MIN(Lows[1],1)[1] + ATR(BarsArray[1], 4)[1])
{
EnterLong(DefaultQuantity, "");
}
// Condition set 2
if (Low[0] < MAX(Highs[1],1)[1] - ATR(BarsArray[1], 4)[1]
&& Open[0] < SMA(57000)[1])
{
EnterShort(DefaultQuantity, "");
}
}
else
{
return;
Thanks!Last edited by freddy250; 08-16-2011, 03:38 PM.
Comment
-
You're welcome. What particular issue are you having with the script? A couple areas I would look at:
MIN(Lows[1],1)[1] + ATR(BarsArray[1], 4)[1])
MIN with a lookback of 1 is exactly the same as using Lows[1][0]. Typically a lookback greater than 1 is used, as MIN & MAX express the highest and lowest values over so many bars.
Open[0] < SMA(57000)
This SMA takes 57000 bars to calculate. Most chart series will not have this many bars.Ryan M.NinjaTrader Customer Service
Comment
-
thanks, the issue is that i am trying to plot a 4 period 15 minute ATR on the graph, I have it backtesting but cannot see the ATR on the graph. I am only seeing that graph of the primary series(which is in seconds) and would like to see the secondary.
how can i edit this line to do this
protected override void Initialize()
ATR(BarsArray[1], 4)[1])
Thanks
Freddy
Comment
-
Last edited by NinjaTrader_RyanM1; 08-16-2011, 04:23 PM.Ryan M.NinjaTrader Customer Service
Comment
-
Yes, you're right. There is no way to use BarsArray and multiseries values from the strategies Initialize() method.
What you can do is create this in a multi time frame indicator, and then add your indicator to the strategy. Your indicator contains the multiTime frame reference, and sets a plot based on it. The strategy just adds this indicator in Initialize() to visualize.Ryan M.NinjaTrader Customer Service
Comment
-
Thanks,
I'm trying to set a profit target of ATR(4),[1] as well as a stop loss of ATR(4),[1], but am having difficulty doing so.
Thusfar, I have tried to build these conditions like this:
Open [BarsSinceEntry] + ATR(4),[1] for TP
Open [BarsSinceEntry] - ATR(4),[1] for SL
Any ideas?
Comment
-
OK, now I am trying to make a condition for an entry signal which does the following:
If High of this primary bar crosses above the (low of the last secondary bar + the 4 period ATR of the last secondary bar),
This is what I have so far:
CrossAbove(High[0], MIN(Lows[1],1)[1] + ATR(BarsArray[1], 4)[1],1)
However this code doesn't seem to work, is it written incorrectly?
FreddyLast edited by freddy250; 08-17-2011, 12:19 PM.
Comment
-
You don't want to apply indexing to CrossAbove and CrossBelow. If you're struggling with the code needed, you can use the point and click interface (Strategy Wizard) to create many of these types of expressions. Using this will produce the correct syntax that you can use for reference. All the built in functions like MIN, MAX also have examples you can work from.
Please see here for help with the strategy wizard.
Please see here for an alphabetical reference of all functions.Ryan M.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Mestor, 03-10-2023, 01:50 AM
|
16 responses
389 views
0 likes
|
Last Post
by z.franck
Today, 01:04 AM
|
||
Started by rtwave, 04-12-2024, 09:30 AM
|
4 responses
31 views
0 likes
|
Last Post
by rtwave
Today, 12:50 AM
|
||
Started by yertle, Yesterday, 08:38 AM
|
7 responses
29 views
0 likes
|
Last Post
by yertle
Today, 12:15 AM
|
||
Started by bmartz, 03-12-2024, 06:12 AM
|
2 responses
23 views
0 likes
|
Last Post
by bmartz
Today, 12:11 AM
|
||
Started by funk10101, Today, 12:02 AM
|
0 responses
7 views
0 likes
|
Last Post
by funk10101
Today, 12:02 AM
|
Comment