Many thanks.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Bars Type Class Using Indicators Class Data
Collapse
X
-
Originally posted by NinjaTrader_ChelseaB View Post
Many thanks.
-
Hello aligator,
Where you have mentioned:
"Just trying to figure out a way to create a chart style that paints based on a data series resulted from a math function in NinjaTrader"
This sounds like something that would be better accomplished with an indicator that sets the BarBrush.
However, chartStyles do get the bars object.
This means you can get the data of the bar with bars.GetClose(int index) and do any calculations with the data you would like.
For example:
bars.GetClose(bars.Count) - bars.GetOpen(bars.Count - 1)
This would give the difference of the current bars close minus the open of the previous bar.
I wouldn't be able to completely re-write these scripts on your behalf, but I am happy to assist if you decide to re-write these and get stuck.
Leave a comment:
-
Originally posted by NinjaTrader_Jesse View PostHello aligator,
This would be more involved than I could provide a sample for.
The logic in the existing cci is intended to be used going forward in processing, or with OnBarUpdate because it uses a price series and sma indicator in its calculation.
If you wanted to use a ChartStyle for this you would essentially need to work out a way to calculate the value yourself in a different way than using a series and SMA. You will also need to write the SMA logic into this ChartStyle so the cci calculation can access that value
The existing chart styles use loops to iterate over just the visible bars, however if you wanted to calculate something for the whole series like an indicator you would likely need to loop over all bars to do that. This can be a major impact on performance in this context because you would need to recalculate the whole value every time OnRender is called which is frequent. An indicator does not share this trait because it can reference the prior data in its series and avoids recalculating all bars.
To expand on how chart styles work I would suggest looking at how the existing chart styles work to paint bars.
I look forward to being of further assistance.
The CCI is just an example. It can be anything with a simple math expression such as SMA that simply any bar above is green or red if below SMA. Just trying to figure out a way to create a chart style that paints based on a data series resulted from a math function in NinjaTrader.
Thanks.
Leave a comment:
-
Hello aligator,
This would be more involved than I could provide a sample for.
The logic in the existing cci is intended to be used going forward in processing, or with OnBarUpdate because it uses a price series and sma indicator in its calculation.
If you wanted to use a ChartStyle for this you would essentially need to work out a way to calculate the value yourself in a different way than using a series and SMA. You will also need to write the SMA logic into this ChartStyle so the cci calculation can access that value
The existing chart styles use loops to iterate over just the visible bars, however if you wanted to calculate something for the whole series like an indicator you would likely need to loop over all bars to do that. This can be a major impact on performance in this context because you would need to recalculate the whole value every time OnRender is called which is frequent. An indicator does not share this trait because it can reference the prior data in its series and avoids recalculating all bars.
To expand on how chart styles work I would suggest looking at how the existing chart styles work to paint bars.
I look forward to being of further assistance.
Leave a comment:
-
Originally posted by NinjaTrader_Jesse View PostHello aligator,
you would need to make a custom ChartStyle and include a custom calculation in that style. Calling the CCI is not an option, you can however try to recreate the same math it uses in OnRender in the ChartStyle.
I look forward to being of further assistance.
Thanks.
Leave a comment:
-
Hello aligator,
This concept would not be possible, a BarsType cannot call an indicator. Also the BarsType does not control the coloring, that would be the ChartStyle which calling an indicator from is still not possible.
The most simple solution is to use an indicator, otherwise you would need to make a custom ChartStyle and include a custom calculation in that style. Calling the CCI is not an option, you can however try to recreate the same math it uses in OnRender in the ChartStyle. The OnBarUpdate concepts in the indicator will not directly apply in a ChartStyle, this is something you would need to work out with logic if that is something you wanted to do. Otherwise the best solution is to just use an Indicator for this purpose because that can call the CCI and also paint the bars in much more simple ways.
I look forward to being of further assistance.
Leave a comment:
-
Bars Type Class Using Indicators Class Data
Dear Support,
How to use the results of an indicator in a Bars Type class? Any sample scripts is appreciated.
Here is an example:
Modify a Bars Type code (i.e. CandleSticks) so that the bars are painted green if CCI >= 100 or Red if CCI <= -100.
I know that I can add a simple indicator to the chart to accomplish the bar painting, but I want to do this within the Bars Type code.
Many thanksTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by algospoke, Yesterday, 06:40 PM
|
2 responses
22 views
0 likes
|
Last Post
by algospoke
Today, 07:04 PM
|
||
Started by ghoul, Today, 06:02 PM
|
3 responses
14 views
0 likes
|
Last Post Today, 06:43 PM | ||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
45 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
7 responses
21 views
0 likes
|
Last Post Today, 06:16 PM | ||
Started by AttiM, 02-14-2024, 05:20 PM
|
10 responses
181 views
0 likes
|
Last Post
by jeronymite
Today, 06:11 PM
|
Leave a comment: