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 SalmaTrader, 07-07-2026, 10:26 PM
|
0 responses
50 views
0 likes
|
Last Post
by SalmaTrader
07-07-2026, 10:26 PM
|
||
|
Started by CarlTrading, 07-05-2026, 01:16 PM
|
0 responses
22 views
0 likes
|
Last Post
by CarlTrading
07-05-2026, 01:16 PM
|
||
|
Started by CaptainJack, 06-17-2026, 10:32 AM
|
0 responses
16 views
0 likes
|
Last Post
by CaptainJack
06-17-2026, 10:32 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:15 AM
|
0 responses
22 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:15 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:06 AM
|
0 responses
23 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:06 AM
|

Comment