protected override void Initialize()
.......
BarsRequired = userValueFromVariables;
Add("MyStock", PeriodType.Day, 1);
...........
protected override void OnBarUpdate()
if (CurrentBars[0] <= BarsRequired || [COLOR="Red"]CurrentBars[1] <= BarsRequired[/COLOR]) [COLOR="Magenta"]//should I add BarsRequired for added instrument if BarsRequired = userValueFromVariables and is for main instrument? Can I just miss this condition?[/COLOR]
return;
if (Closes[1][0]>myS && [COLOR="Red"]conditions for long[/COLOR]) [COLOR="Magenta"]//conditions for long use main instrument values: Close[0] etc. Maybe problem is here? And I should write here if (Closes[1][0]>myS && conditions with Close[0][0]???[/COLOR]
{
there are only main stock values in use: Close[0] etc. and nothing from added instrument
}
if (Closes[1][0]<myS && conditions for Short)
{
there are only main stock values in use: Close[0] etc. and nothing from added instrument
}
if (conditions for trails) {there are only main stock values in use}
protected override void OnExecution(IExecution execution)
{there is EntryOrder and trails operating.}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
BarsInProgress
Collapse
X
-
Code structure is usual:
As you can see, I just add only 2 short conditions as filter on Entries. That's it. But after I did that, strategy went wrong.Code:
-
Hi Alex, that would depend mainly on code structure, as the Close would be sensitive to called context, so tied to the BarsInProgress you're in. If you want to access other bars array data in another BarsInProgress then you would need to specifically point to that via Closes[x] / BarsArray[x]
Leave a comment:
-
BarsInProgress
Hello. I've wrote script only for main instrument. Now after debugging I'd like to add some instruments to script. So, should I change Clolse[0] to Closes[0][0] etc. or I can leave everything as is for main instrument and only use Closes[1][0] for second instrument?Tags: None
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
152 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
89 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
133 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
127 views
1 like
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
107 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Leave a comment: