I would so much appreciate your help! Thanks!!
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
Consecutive red or green bars supply and demand
Collapse
X
-
Consecutive red or green bars supply and demand
I am trying to make a custom indicator for supply and demand based on range bars. If there are 4 consecutive up bars or down bars then I want to draw a rectangle. I have looked at nBarsUp and nBarsDown but that did not help me much. The rectangle for a supply would be drawn based on the high of the bar before the 3 consecutive bars down until the low of the first bar after the green candle. It would be the opposite for Demand.
I would so much appreciate your help! Thanks!!
Tags: None
-
Hello Graci117,
Thanks for your post.
To check if a bar is an up bar you could create a condition that checks if the Close price (Close[0]) is greater than the Open price (Open[0]).
Checking for consecutive up bars would require creating multiple price comparisons and supplying a BarsAgo value to check previous bars.
For example, Close[0] and Open[0] have a BarsAgo value of 0 so this would check if the current bar is an up bar. Close[1] and Open[1] have a BarsAgo value of 1 so this would check if the previous bar is an up bar. Close[2] and Open[2] have a BarsAgo value of 2 so this would check if the bar 2 bars prior from the current bar is an up bar, and so on.
To check if there are 4 consecutive up bars, the code might look something like this:
if (Close[0] > Open[0] && Close[1] > Open[1] && Close[2] > Open[2] && Close[3] > Open[3])
{
//do something.
}
Note to check if a bar is a down bar you would compare if the Close price (Close[0]) is less than the Open price (Open[0]).
PriceSeries: https://ninjatrader.com/support/help...riceseries.htmBrandon H.NinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by jxs_xrj, 01-12-2020, 09:49 AM
|
6 responses
3,290 views
1 like
|
Last Post
by jgualdronc
Today, 10:56 AM
|
||
Started by Touch-Ups, Today, 10:36 AM
|
0 responses
7 views
0 likes
|
Last Post
by Touch-Ups
Today, 10:36 AM
|
||
Started by geddyisodin, 04-25-2024, 05:20 AM
|
8 responses
61 views
0 likes
|
Last Post Yesterday, 10:45 AM | ||
Can someone turn this thinkscript into a ninjascript. 5PM CST OHL and Previous Day
by Option Whisperer
Started by Option Whisperer, Today, 09:55 AM
|
0 responses
8 views
0 likes
|
Last Post Today, 09:55 AM | ||
Started by halgo_boulder, 04-20-2024, 08:44 AM
|
2 responses
24 views
0 likes
|
Last Post Today, 09:41 AM |
Comment