protected override void Initialize()
{
//SPY is Primary series 0
Add("DIA", PeriodType.Minute, 5); //series 1 primary for DIA
Add(PeriodType.Minute, 1); //series 2 secondary for SPY
Add("DIA", PeriodType.Minute, 1); //series 3 secondary for DIA
}
protected override void OnBarUpdate()
{
if ((BarsInProgress == 2) && //sma cross conditions here//)
{
EnterLong(200, "SPY");
}
if ((BarsInProgress == 3) && //sma cross conditions here//)
{
EnterLong(200, "DIA");
}
if ((BarsInProgress == 0) && (Position.MarketPosition == MarketPosition.Flat))
{
SetStopLoss("SPY", CalculationMode.Percent, stoppercent, true);
}
if ((BarsInProgress == 1) && (Position.MarketPosition == MarketPosition.Flat))
{
SetStopLoss("DIA", CalculationMode.Percent, stoppercent, true);
}
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
2 instruments in one script
Collapse
X
-
2 instruments in one script
This is for backtesting purposes. I made an attempt at having 2 instruments in one script below but when I compare it to running a single script against the same 2 instruments seperately I get different net profit results. I tried using "else if" as well. Is there anything else I'm doing incorrectly or is it not even possible to do what I'm attempting here?
Code:Tags: None
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
574 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment