G&M
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
Need help with an indicator I want
Collapse
X
-
Need help with an indicator I want
I want an indicator that is an average of 3 moving averages. I am not a programmer so I don't know how to go about developing this. I would then like to be able to add/subtract the ATR from the average creating a channel filter for entry. I also would like to constrain the min and the max SMA to less than 1 ATR as an additional entry filter. If someone helps with the coding I would like to make the entire entry available to the community. After all, entries aren't suppose to be that important, right?
G&MTags: None
-
G&M, hopefully someone steps in to help you getting started create this - if you decide to give a go yourself, those tutorials here are very helpful getting started -
If you for example create a new indicator with our wizard and then enter this as Plot0 value, it would give you the avg of the SMA, EMA and WMA calculated on 20 bars.
Code:Plot0.Set((SMA(20)[0] + EMA(20)[0] + WMA(20)[0]) / 3);
BertrandNinjaTrader Customer Service
-
One bar at a time
Bertrand,
Is there a way to have a trading strategy only look at an indicator for one bar and then disregard it for the other bars?
G&M
Comment
-
Thanks Josh, I figured there was a way. I'm not a programmer: would you have sample code of what this would look like?
Comment
-
So if it is an Indicator inside a strategy it might look like:
if (CurrentBar.SMA(20)[0] == 100)
// do something
Comment
-
If SMA(20)[ of CurrentBar] > 45
//do something
but really I'd like to only have it look at this indicator on the 20th bar since entry, for instance. Then the next bar would look only at SMA(21) So the entire strategy would be related to the entry bar (or actually the bar prior).
Comment
-
-
Not sure what you mean. You can't just say "of the current bar". Every time you process the strategy logic it is always "of the current bar". You are always processing the latest bar at that point in time of processing.
if (SMA(20)[0] > 40)
[0] represents most recent bar
[1] represents the previous bar
The strategy processes its logic from left to right going across the chart. Every single bar it processes is index [0]. Then as each bar you go forward, you get an additional bar that can go back in the [] indexing. On the first bar of the chart you are on [0]. You have no [1]. On the 2nd bar of the chart you are on [0] and now you also have [1]. On the 3rd bar you have [0], [1], and [2]. etc.Josh P.NinjaTrader Customer Service
Comment
-
Original question: Is there a way to have a trading strategy only look at an indicator for one bar and then disregard it for the other bars?
In other words, the strategy looks at an indicator on current bar (Bar-0 we'll call it) and executes a trade on open of next bar (Bar-1), on Bar-1 it looks at an indicator comparing Bar-0 to Bar-1 (like SMA(1)[0]). The next bar it looks at another indicator comparing Bar-0 to Bar-2 like SMA(2)[0] but not SMA(1) at all) and so on. In other words, an indicator always referenced to Bar-0; the original piece of trigger data.
Any ideas?
Comment
-
gunsmoney,
That doesn't conceptually work. SMA(2) is never SMA(1). You need to decide for yourself exactly which bar you want to check. Then simply run SMA(Period) on whatever bar you want that to be. An SMA period of 1 is meaningless. Moving averages requires several bars to calculate its value.Josh P.NinjaTrader Customer Service
Comment
-
Josh, SMA is just a throw away indicator. You don't think I'd reveal the real indicator I'm using?
And yes, conceptually it does work for what I want to do. I just need to figure out how.
Can I specify use indicator x on y bars from entry and exclude indicators a-w, and then on the next bar use indicator z on y+1 bars from entry excluding indicators a-x (which may be used elsewhere in the strategy)?
And how?
Comment
-
gunsnmoney,
Unfortunately there is nothing I can comment on from a theoretical standpoint. Without knowing exactly how the indicators are built I will not be able to speak to them.
As mentioned before, if you just want to run indicator a on bar 100, just call indicator A on that specific bar. If you don't want to call the indicator anymore, don't call it in the code. It is really that simple. As far as how the indicator choose which bars it will calculate is not something you can choose. It runs on the bar series or whatever Input series you set it to. Whether it uses 1 bar ago, 2 bars ago, or 50 bars ago is dependent on the indicator logic.
I suggest you contact a 3rd party NinjaScript consultant to discuss your exact requirements confidentially. http://www.ninjatrader.com/webnew/pa...injaScript.htmJosh P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by elirion, Today, 01:36 AM
|
0 responses
3 views
0 likes
|
Last Post
by elirion
Today, 01:36 AM
|
||
Is it possible to have a drawing, such as a line, cycle through different colors?
by gentlebenthebear
Started by gentlebenthebear, Today, 01:30 AM
|
0 responses
4 views
0 likes
|
Last Post Today, 01:30 AM | ||
Started by samish18, Yesterday, 08:31 AM
|
2 responses
9 views
0 likes
|
Last Post
by elirion
Today, 01:28 AM
|
||
Started by Mestor, 03-10-2023, 01:50 AM
|
16 responses
391 views
0 likes
|
Last Post
by z.franck
Today, 01:04 AM
|
||
Started by rtwave, 04-12-2024, 09:30 AM
|
4 responses
34 views
0 likes
|
Last Post
by rtwave
Today, 12:50 AM
|
Comment