Good morning to everybody, My idea is to obtain the weekly high of the last three weeks and the weekly low of the last three weeks to average them. I've read quite a bit on the matter, but haven't found a valid answer to what I need and that apparently shouldn't be too complicated, although it finally seems so. I have seen that there are several indicators, for example ana, but what I want is not to paint the signals, but to obtain the values to use them mathematically. I have tried to add a weekly data series, but including the strategy in the chart gives an error, which I am not able to solve, so I would like to know if there is a simpler way, which does not require adding additional data series . Thank you very much and greetings
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
get the weekly high of the last three weeks
Collapse
X
-
get the weekly high of the last three weeks
Good morning to everybody, My idea is to obtain the weekly high of the last three weeks and the weekly low of the last three weeks to average them. I've read quite a bit on the matter, but haven't found a valid answer to what I need and that apparently shouldn't be too complicated, although it finally seems so. I have seen that there are several indicators, for example ana, but what I want is not to paint the signals, but to obtain the values to use them mathematically. I have tried to add a weekly data series, but including the strategy in the chart gives an error, which I am not able to solve, so I would like to know if there is a simpler way, which does not require adding additional data series . Thank you very much and greetingsTags: None
-
Hello danakede,
Thank you for your post.
It would be simplest to do with an added weekly data series. The trick with that is, you need to check to make sure enough weekly bars are available for it to calculate.
Here's a quick example script that will plot the weekly high and weekly low (It must have a minimum of 21 days loaded on the chart to work):
Code:public class Example3WeekHighLowAvg : Indicator { protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "Example3WeekHighLowAvg"; Calculate = Calculate.OnBarClose; IsOverlay = true; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; AddPlot(Brushes.OrangeRed, "AverageHigh"); AddPlot(Brushes.DodgerBlue, "AverageLow"); } else if (State == State.Configure) { AddDataSeries(Data.BarsPeriodType.Week, 1); } } protected override void OnBarUpdate() { if (CurrentBars[1] < 3) return; Values[0][0] = (Highs[1][0]+ Highs[1][1] + Highs[1][2])/3; Values[1][0] = (Lows[1][0] + Lows[1][1] + Lows[1][2])/3; } #region Properties [Browsable(false)] [XmlIgnore] public Series<double> AverageHigh { get { return Values[0]; } } [Browsable(false)] [XmlIgnore] public Series<double> AverageLow { get { return Values[1]; } } #endregion }
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
-
Good morning Kate, your information has been of great help. I have managed to make the code you sent me work as an indicator by itself. On the other hand, I have verified that when adding an additional data series to my strategy, it cannot be executed on every tick, it does not work with Resolution: "High", only an additional data series can be added to a strategy and it will have to run Resolution: "Standard". My strategy is designed to only work with Resolution: "High, tick, 1", so I cannot incorporate additional data set into my strategy. The indicator that you have provided is perfect for me, so my question is ... can I take the values of the indicator "AverageHigh" and "AverageLow" to use in my strategy? If possible, what is the method to call them from the strategy? Thank you
Comment
-
Hello danakede,
Thank you for your reply.
You wouldn't be able to use it without adding the additional data series in the strategy as well.
To maximize data loading performance, any NinjaScript object (indicator or strategy as host) which references a multi-series indicator which calls AddDataSeries must include it's own calls to AddDataSeries(). For example, if the code below was included in an indicator, and that indicator was referenced in a NinjaScript strategy, then the hosting strategy will need to include the same calls to AddDataSeries().
When the strategy adds the additional Bars objects, the calls to AddDataSeries() within the indicator will be ignored. If the Bars objects are not added by the strategy in such cases, and error will be thrown in the Log tab of the Control Center that would read - "A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state."
So you would need to add the additional data series, which would preclude you from running the strategy on high resolution. You would need to manually add that secondary data series and code in the more granular resolution into the strategy with a single tick series as well.
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
-
Buenos dias Kate No entiendo lo que quieres decir con esta frase: " Debería agregar manualmente esa serie de datos secundarios y el código en la resolución más granular en la estrategia con una sola serie de ticks".
¿Esta solución que me brinda me permite operar con mi estrategia en alta resolución? and at the same time be able to take the data from the indicator? ¿Me podría explicar mejor lo que quiere decir? Muchas gracias y un saludo.
Comment
-
Good morning Kate I don't understand what you mean by this sentence: "You should manually add that secondary data set and the code in the most granular resolution in the strategy with a single set of ticks".
Does this solution allow me to operate with my strategy in high resolution? and at the same time be able to take the data from the indicator? Could you explain to me better what you mean? Thank you very much and a greeting
Translated with www.DeepL.com/Translator (free version)
Thank you for your note.
I've translated your previous post above. You would not use high resolution when using a single tick series to manually add the high resolution. You would need to add both a weekly series just like in the indicator so you can then successfully call the indicator as well as a 1 tick series. You would then use the single tick series to provide the higher resolution.
This example from the help guide goes into how you can use a more granular series to provide intrabar actions so you don't need to use high order resolution:
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bortz, 11-06-2023, 08:04 AM
|
47 responses
1,610 views
0 likes
|
Last Post
by aligator
Today, 07:22 PM
|
||
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
9 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
19 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
6 views
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
21 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
Comment