protected override void Initialize()
{
CalculateOnBarClose = true;
Add("SPY",PeriodType.Minute,5);
}
protected override void OnBarUpdate()
{
if(CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired){return;}
else
{
if(BarsInProgress==0)
{
if(((ToTime(Time[0])>= 100000) && (ToTime(Time[0])<= 140000)) &&
(Closes[1][0]>Closes[1][Bars.BarsSinceSession-1])) //is market up?
{
if((Close[0]>EMA(50)[0])&&
(Close[0]>EMA(10)[0])&&
(Open[0]<EMA(50)[0])&&
((High[0]-Close[0])/(High[0]-Low[0])<=.25)&&
(CountIf(delegate{return High[1]<=EMA(20)[1];},30)>=28)&&
(CountIf(delegate{return EMA(20)[0]<EMA(50)[0];},30)==30)&&
(Volume[0]>=SMA(Volume,15)[2]*4))
{
EnterLong(0,100,"Signal");
}
}
if(Position.MarketPosition==MarketPosition.Long)
{
if(Close[0]<EMA(20)[0])
ExitLong(0,100,"Exit","Signal");
}
}
}
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Multi- instument strategy giving results I'm not expecting
Collapse
X
-
Multi- instument strategy giving results I'm not expecting
Hi... I thought I had the basics down of multi-instrument strategies but apparently not. The strategy below is returning trades that have no similarities to the conditions coded. For example, entries at 9:35am and 4:00pm (I have coded only between 10-2), no moving average conditions present as specified, etc. Any ideas?
Code:Tags: None
-
Where are you testing this? Market Replay? Strategy Analyzer? Sim? Live?
What is the time frame of the main series?
The code looks right glancing at it, but your setup might be incorrect.
Originally posted by CSharpTrader View PostHi... I thought I had the basics down of multi-instrument strategies but apparently not. The strategy below is returning trades that have no similarities to the conditions coded. For example, entries at 9:35am and 4:00pm (I have coded only between 10-2), no moving average conditions present as specified, etc. Any ideas?
Code:protected override void Initialize() { CalculateOnBarClose = true; Add("SPY",PeriodType.Minute,5); } protected override void OnBarUpdate() { if(CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired){return;} else { if(BarsInProgress==0) { if(((ToTime(Time[0])>= 100000) && (ToTime(Time[0])<= 140000)) && (Closes[1][0]>Closes[1][Bars.BarsSinceSession-1])) //is market up? { if((Close[0]>EMA(50)[0])&& (Close[0]>EMA(10)[0])&& (Open[0]<EMA(50)[0])&& ((High[0]-Close[0])/(High[0]-Low[0])<=.25)&& (CountIf(delegate{return High[1]<=EMA(20)[1];},30)>=28)&& (CountIf(delegate{return EMA(20)[0]<EMA(50)[0];},30)==30)&& (Volume[0]>=SMA(Volume,15)[2]*4)) { EnterLong(0,100,"Signal"); } } if(Position.MarketPosition==MarketPosition.Long) { if(Close[0]<EMA(20)[0]) ExitLong(0,100,"Exit","Signal"); } } } }
-
Thank you sledge. I was running it on 5 min bars in strategy analyzer. I had been backtesting a different strategy from the same analyzer before, and, going out on a limb here, I wonder if this had something to do with it. I say this since after restarting NT and rerunning the strategy (and removing the other instrument) it performed as expected..
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
671 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
379 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
111 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
575 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
582 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment