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
IsRising/IsFalling from BarsAgo
Collapse
X
-
Hello ezrollin,
IsFalling compares the series with 0 bars ago to 1 bar ago.
if (MySeries[1] < MySeries[0])
{
// series is falling
}
Just replace the bars ago [1] < less than bars ago [0], with bars ago [2] < less than bars ago [1].
To have one action per bar, use a bool. In the action set the bool to true. When IsFirstTickOfBar is true set the bool back to false. Require the bool to be false in the condition.
Chelsea B.NinjaTrader Customer Service
- Likes 1
-
Thanks for your reply Chelsea.
It took me a minute to figure out what you meant but I got it. I'm slow.
I'm trying to create my own deal to see how many bars back an action occured:
So I created a custom series as a double for my barsago[?]
if the condition occured then the action is supposed to set the barsago[] to the series double to show how many bars ago.
however when I select my custom series action it just sets it to 0 and stays at 0 the whole time (yet I'm sure the condition occured).
What am I doing wrong??? Thanks
In easy graphical format:
Comment
-
Hello,
Thank you for your note.
A series has a slot to hold a value for every bar on the chart. If you set a value on a bar and that bar closes, the value is now 1 bar ago and the new bar slot has a value of 0.
If you want to carry the value forward, in Set 1 set the current bars value to the value of the series from 1 bar ago.
This example linked below does this with the current bar number.
with regard to the attached image: Line A is an indicator Line B is the m period MAX of line A Line C is an average of this indicator A Line D is another average of this indicator A is it possible, possibly using the strategy builder, but without adding a temporary variable, to set on the condition: line C crosses below line D
Chelsea B.NinjaTrader Customer Service
Comment
-
Hello ezrollin,
I'm trying to set that if this condition is true then it became true on this bar[0].
I may not be following entirely on how you plan to use this in your Strategy Builder script, (working with bar indexes is more flexible when you work with unlocked code) but if your goal is to detect IsRising after IsFalling, you would essentially be looking at the last 3 bars (including the current bar) that would look for a "V" or a "^" in shape.
For example, Close[2] < Close[1] > Close[0] would mean Falling after Rising
and, Close[2] > Close[1] < Close[0] would mean Rising after FallingJimNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Jim View PostHello ezrollin,
If you have a Series<int> (Series of integer values) and call it "ConditionTrueOnBar" you can assign "ConditionTrueOnBar" the value of Misc > CurrentBar, and this Series would hold the bar index that the condition became true on.
MyTrueBarsago[0] = CurrentBars[Default Input]
That will make it true on that bar even though its not clear in the name (CurrentBars)? Took me a long time to realize this lol thanks
Comment
-
Originally posted by NinjaTrader_Jim View Post
I may not be following entirely on how you plan to use this in your Strategy Builder script, (working with bar indexes is more flexible when you work with unlocked code) but if your goal is to detect IsRising after IsFalling, you would essentially be looking at the last 3 bars (including the current bar) that would look for a "V" or a "^" in shape.
For example, Close[2] < Close[1] > Close[0] would mean Falling after Rising
and, Close[2] > Close[1] < Close[0] would mean Rising after Falling
I dont have the option of working with bars ago on this one so I was trying to make something custom to workaround the limitation thanks
Comment
-
Hello ezrollin,
If you want to carry a value forward, you would be setting this to itself, with BarsAgo set to 1.
MyTrueBarsago[0] = MyTrueBarsago[1];
This sets the current bar value to the previous bar value and 'carries it forward a bar'.
Yes, IsRising IsFalling does not have the bars ago. You will need to compare the current bar to the previous bar as advised in posts #2 and #6.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by GussJ, 03-04-2020, 03:11 PM
|
11 responses
3,221 views
0 likes
|
Last Post Today, 08:07 PM | ||
Started by andrewtrades, Today, 04:57 PM
|
1 response
10 views
0 likes
|
Last Post Today, 05:02 PM | ||
Started by chbruno, Today, 04:10 PM
|
0 responses
7 views
0 likes
|
Last Post
by chbruno
Today, 04:10 PM
|
||
Started by josh18955, 03-25-2023, 11:16 AM
|
6 responses
438 views
0 likes
|
Last Post
by Delerium
Today, 03:42 PM
|
||
Started by FAQtrader, Today, 03:35 PM
|
0 responses
9 views
0 likes
|
Last Post
by FAQtrader
Today, 03:35 PM
|
Comment