You stated your main series is a daily bar, this would be the primary series (0). This would then be the input for Add(CloseWeekPer(MyInstrum1));. And thus be printed from your strategy with the Daily bars as the input.
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Multi instrument
Collapse
X
-
Originally posted by NinjaTrader_PatrickH View PostHello alexstox,
You stated your main series is a daily bar, this would be the primary series (0). This would then be the input for Add(CloseWeekPer(MyInstrum1));. And thus be printed from your strategy with the Daily bars as the input.
I mean how to call that parameter from strategy to use in indicator? Because as I know I can't do this via string PerType=PeriodType.Week; and use it than in indicator code CloseWeekPer(MyInstrum1, PerType));
Comment
-
Hello alexstox,
It is not possible to add an indicator to a strategy using a secondary data series.
When using the Add() method to add an indicator to a strategy, the primary data series (the data series of the chart) will be the data series that is used for the indicator. It is not possible to change this.
It would be possible, however, to add a secondary data series of 1 week to the indicator and process only during that bars in progress.Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHello alexstox,
It is not possible to add an indicator to a strategy using a secondary data series.
When using the Add() method to add an indicator to a strategy, the primary data series (the data series of the chart) will be the data series that is used for the indicator. It is not possible to change this.
It would be possible, however, to add a secondary data series of 1 week to the indicator and process only during that bars in progress.
in strategy Add(CloseWeek("MSFT"));
in indicator Add("MSFT", PeriodType.Week, 1);Last edited by alexstox; 07-24-2014, 02:23 PM.
Comment
-
Hello alexstox,
I am not quite sure what you are asking.
If you strategy is running on a daily chart (or chart that is not one week), you can have the indicator use a 1 week time frame by adding a secondary data series.
If you are going to have your chart be a weekly time frame then this is not needed.
At this point, from how I am understanding the correspondence in this thread, you should be adding the strategy to a daily chart, and then the strategy will call an indicator that has a 1 week added data series.
The data would then be processed in the indicator for the week time frame, and plotted on the chart.
Is this what you are trying to accomplish?Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHello alexstox,
I am not quite sure what you are asking.
If you strategy is running on a daily chart (or chart that is not one week), you can have the indicator use a 1 week time frame by adding a secondary data series.
If you are going to have your chart be a weekly time frame then this is not needed.
At this point, from how I am understanding the correspondence in this thread, you should be adding the strategy to a daily chart, and then the strategy will call an indicator that has a 1 week added data series.
The data would then be processed in the indicator for the week time frame, and plotted on the chart.
Is this what you are trying to accomplish?
================================================== ==============
I use indicator with BoolSeries UP and DOWN (week close up or week close down). So, in strategy script OnBarUpdate() condition CloseWeek.UP[0] is true only on week's end day. That's why days between two weeks' ends are false. How to avoid this?
Please look at attached Output. So, as you see there on week's end day (date at which week closes) everything is OK. But days betweens weeks' ends are contrary.
So, I think this because of BarsInProgress==1 is absent in between weeks's ends days. Indicator works with weekly bars. I use this indicator in strategy, where general instrument uses daily bars.
Indicator script
protected override void Initialize()
{.....................
Add(MyInstrum1, PeriodType.Week, 1);
.......................
uPweek = new BoolSeries(this);
dOWNweek = new BoolSeries(this);
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired /*|| CurrentBars[2] <= 20*/)
return;
.................................
if (BarsInProgress==1) //start BarsInProgress
{
if (blalblalllal.........
dOWNweek.Set(false);
uPweek.Set(true);
.................................}
Strategy script
protected override void Initialize()
{
...........................
Add(CloseWeek(MyInstrum2));
as you can see, I do not specify PeriodType for indicator, because it needs only in Symbol string input
.........................................
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] <= ATR_big_per || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired)
return;
if (CloseWeek(MyInstrum2).UPweek[0])
..........................
}
You know what is interesting? After week Up on following days Upweek==false, DOWNweek==true!!!! and vice versa after week DOWN on following days DOWNweek==false, UPweek==true!!! You can see this in Output, that I attached earlier.
Patrick answer
You have two input series, a Week and a Day series. The Day bars are not going to have the same value from the ClosePerWeek() indicator as the Week bars on the close of the of the week bar, as the Day bar is only looking at that day where the Week bar encompasses the entire week of data.
For example, compare the Open, High, Low, and Close of the Day bar on the closing day of the Week bar and you will see the Open, High, Low, Close is not the same as the Week bar.
My question
Patrick, please, advise me what to do.
Maybe I should add
if (BarsInProgress==2) //start BarsInProgress for weekly instrument only
{and here is everything with CloseWeekIndictor...
} this didn't help. I tried.
Patrick answer
Well, your indicator works great on it's own using the week bar as it's input. So if this is the only value you need, then don't use the Daily bar as an input for the indicator.
My question
Patrick, but I don't use Daily as input. As you see in indicator script
Add(MyInstrum1, PeriodType.Week, 1);
Than in strategy I only use string symbol as input for indicator. Main instrument data (not for indicator) still in Daily bars. Please comment.
Patrick answer
Originally Posted by alexstox
Patrick, CloseWeekPer is indicator. I add it in strategy, where main instrument series is Daily.
You stated your main series is a daily bar, this would be the primary series (0). This would then be the input for Add(CloseWeekPer(MyInstrum1));. And thus be printed from your strategy with the Daily bars as the input.
My question
Is there any sample how to add PeriodType for own indicator in strategy?
I mean how to call that parameter from strategy to use in indicator? Because as I know I can't do this via string PerType=PeriodType.Week; and use it than in indicator code CloseWeekPer(MyInstrum1, PerType));
ChelseaB answer
It is not possible to add an indicator to a strategy using a secondary data series.
When using the Add() method to add an indicator to a strategy, the primary data series (the data series of the chart) will be the data series that is used for the indicator. It is not possible to change this.
It would be possible, however, to add a secondary data series of 1 week to the indicator and process only during that bars in progress.
My answer
I'm confused. I used indicator, that have only Weekly data series. In strategy it take only Symbol of instrument. Than there is adding of weekly data series in indicator code. So, I did everything you wrote to do.
in strategy Add(CloseWeek("MSFT"));
in indicator Add("MSFT", PeriodType.Week, 1);
Comment
-
Hi alexstox,
If you are making calculations on a week size bar, the value is not going to change until that bar closes.
So I think what you are wanting is not possible.
From Patrick's explanation:
You have two input series, a Week and a Day series. The Day bars are not going to have the same value from the ClosePerWeek() indicator as the Week bars on the close of the of the week bar, as the Day bar is only looking at that day where the Week bar encompasses the entire week of data.Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHi alexstox,
If you are making calculations on a week size bar, the value is not going to change until that bar closes.
So I think what you are wanting is not possible.
From Patrick's explanation:
Are you using a week data series in the indicator and expecting the values calculated to be different every day?
Comment
-
Hi alexstox,
I think the issue is with the bool series and being synced with the primary data series.
When a custom data series or bool series is added, it syncs with the primary series which would be the day series. This means the value is set once per week and all the days inbetween are not set. Any value that is not set is null and will probably return false.
What I think needs to happen is in BarsInProgress 0 you should set the value of the current bar of the bool series to the value of the previous bar of the bool series.
This will cause the new values to continue until the week bar closes and updates the value.Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHi alexstox,
I think the issue is with the bool series and being synced with the primary data series.
When a custom data series or bool series is added, it syncs with the primary series which would be the day series. This means the value is set once per week and all the days inbetween are not set. Any value that is not set is null and will probably return false.
What I think needs to happen is in BarsInProgress 0 you should set the value of the current bar of the bool series to the value of the previous bar of the bool series.
This will cause the new values to continue until the week bar closes and updates the value.
P.S. I asked before. Is possible smth like this in strategy Add(CloseWeek, "MSFT", PeriodType.Week, 1);
I mean how to add this input parameter for indicator? Will this help?
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHi alexstox,
I think the issue is with the bool series and being synced with the primary data series.
When a custom data series or bool series is added, it syncs with the primary series which would be the day series. This means the value is set once per week and all the days inbetween are not set. Any value that is not set is null and will probably return false.
What I think needs to happen is in BarsInProgress 0 you should set the value of the current bar of the bool series to the value of the previous bar of the bool series.
This will cause the new values to continue until the week bar closes and updates the value.
Code:if (BarsInProgress==0) //start BarsInProgress2 { if(momUP==1) {dOWNweek.Set(false); uPweek.Set(true);} else if(momDW==1) {dOWNweek.Set(true); uPweek.Set(false);} } //end BarsInProgress2
Comment
-
Hi alexstox,
While adding a condition statement in there may not hurt anything, I do not know the logic of your script to say this is correct.
I was thinking something like:
if (BarsInProgress == 0)
{
dOWNweek.Set(dOWNweek[1]);
uPweek.Set(uPweek[1]);
}
This just sets to the old value.
When BarsInProgress is 1, then it overwrites the value and you get a new value.Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHi alexstox,
While adding a condition statement in there may not hurt anything, I do not know the logic of your script to say this is correct.
I was thinking something like:
if (BarsInProgress == 0)
{
dOWNweek.Set(dOWNweek[1]);
uPweek.Set(uPweek[1]);
}
This just sets to the old value.
When BarsInProgress is 1, then it overwrites the value and you get a new value.
I wish good luck, best sales, big bonuses and nice weekends!!!
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by volIQ, 03-27-2024, 04:28 PM
|
3 responses
21 views
0 likes
|
Last Post
by RJay
Today, 05:41 AM
|
||
Started by Nickgiaco, 02-26-2024, 10:23 AM
|
2 responses
72 views
0 likes
|
Last Post Today, 05:12 AM | ||
Started by Johndc, Today, 04:39 AM
|
0 responses
7 views
0 likes
|
Last Post
by Johndc
Today, 04:39 AM
|
||
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
10 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
13 views
0 likes
|
Last Post Today, 02:00 AM |
Comment