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
Fire Event to call OnBarUpdate manually
Collapse
X
-
Fire Event to call OnBarUpdate manually
Hi, I am trying to implement my own data series, and i guess OnBarUpdate won't be called without firing an event. There's no instrument set, because I want to calculate values for higher time frames. Most certainly it won't work, but i'll give it a try. ThanksTags: None
-
Sorry to mislead you. The method is invoked by the event of incoming data whether the data is historical or real-time data.
If you could please elaborate more on what you mean by "no instrument set" perhaps I can help think about possible workarounds to achieve what exactly you are trying to accomplish.Josh P.NinjaTrader Customer Service
Comment
-
The problem is that i have an indicator which uses several time frames. If i'd use a normal DataSeries the count would be as much as the chosen time frame. That's why i constructed my own DataSeries with a null indicator and the data stored in a list, and update them with a new value when n-bars have been printed. So far the indicators aren't complaining but since there is no data and get/set can't be overriden, it's just hidden, they will sooner or later. I think it simply can't be done with a DataSeries, so i am intending to writing methods instead of using pre-defined indicators and feeding them the data manually. My C# and NT experience is pretty limited, any suggestions would be appreciated. Thanks
Comment
-
Mm. Perhaps you could just use a NinjaScript strategy instead? You could just load up a strategy onto your chart and in your strategy just code it like an indicator instead of a strategy. In a strategy you can sync the DataSeries to whatever time frame you need the data from. Please see this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=3572
Alternatively, have you considered writing out the data/calculations to a txt file and then just reading the data and using various time frames in that fashion? You might have issues with read/write operating on the same file object at the same time though so your mileage may vary with this approach. Here are reference samples related to this endeavor:
Perhaps you could mess around with how Gumphrie did multi-timed framed indicators on this one here:
Hope that gives you some ideas.Josh P.NinjaTrader Customer Service
Comment
-
Unfortunately the strategy doesn't allow me to draw anything on the chart(maybe it does, but that is what i think ).
Gumphrie didn't use NT indicators in his multi time frame approach, so he didn't have to deal with the DataSeries problem.
I opted for reimplementing the indicators MIN, MAX, SUM, EMA, SMA, RSI, CCI, MACD and Stochastics so they could work without the DataSeries.
The results have been barely tested but the values matched the ones of the original.
The whole indicator can be found here.
Comment
-
Update() Description in Help
Is that a typo in the Update() help description?
It currently says,
Code:tripleValue = 0; private double protected override void OnBarUpdate()
Code:private double tripleValue = 0; protected override void OnBarUpdate()
Comment
-
If we code a strategy like an indicator, how do we get it to plot the indicator on the chart?
I tried using the indicator code to create the plot:
Add(new Plot(penMotionLine,PlotStyle.Line, "tradingML")); but it would not compile. I assume it is because the strategy does not inherit any of the indicator methods. If this is so, is there a way to plot the indicator from within the strategy?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by johnnymustard, Today, 09:52 AM
|
0 responses
1 view
0 likes
|
Last Post Today, 09:52 AM | ||
Started by SnailHorn, 03-27-2024, 09:54 AM
|
4 responses
17 views
0 likes
|
Last Post
by SnailHorn
Today, 09:19 AM
|
||
Started by ninza33, Today, 07:16 AM
|
3 responses
18 views
0 likes
|
Last Post
by ninza33
Today, 09:01 AM
|
||
Started by foxtrott21, Today, 08:27 AM
|
0 responses
4 views
0 likes
|
Last Post
by foxtrott21
Today, 08:27 AM
|
||
Started by jaypelle3, Today, 08:26 AM
|
0 responses
3 views
0 likes
|
Last Post
by jaypelle3
Today, 08:26 AM
|
Comment