View Full Version : bollinger percent up/down arrow plotting
acura92
12-23-2011, 05:04 PM
Is there someone here that could program this indicator to plot a arrow on the chart when bollingerpercet histogram passes 20% & down arrow when falls below 80%(or even bar changes color when these conditions meet). I have looked all over to code but can't seem to figure this out.I know alot of traders are here to help & I would really appreciate any sort of help, or even how i could do it myself. I have zero programing experience, but i can follow instructions if i had to do it myself.
Thanks in advance
Acura
NinjaTrader_AdamP
12-24-2011, 01:57 PM
acura,
The methods you are looking for are below.
http://www.ninjatrader.com/support/helpGuides/nt7/index.html?drawarrowdown.htm
http://www.ninjatrader.com/support/helpGuides/nt7/index.html?drawarrowup.htm
You can simply use if( ) statements to test when a condition is true then use the aforementioned methods.
Here is a link to our help guide educational resources :
http://www.ninjatrader.com/support/helpGuides/nt7/index.html?educational_resources.htm
You can also contact a NinjaScript consultant and see if they can help you.
http://www.ninjatrader.com/partners#NinjaScript-Consultants
acura92
12-25-2011, 11:09 PM
Ninja Crashes after this code. I know im wrong but dunno where?
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
PctB.Set(((Input[0] - Bollinger(StandardDev, Period).Lower[0]) / (Bollinger(StandardDev, Period).Upper[0] - Bollinger(StandardDev, Period).Lower[0])) * 100);
if (CrossAbove(BollingerPercentB(20, 2).PctB, BollingerPercentB(20, 2).PctB, 1))
{
DrawArrowUp("UpArrow" + CurrentBar, false, 0, 0, Color.Blue);
}
NinjaTrader_Brett
12-27-2011, 07:35 AM
Hello,
You do not want to have an indicator call itself to rerun itself and put itself into and endless loop.
You would want to access the local variable since the indicator is already running.
if (CrossAbove(BollingerPercentB(20, 2).PctB, BollingerPercentB(20, 2).PctB, 1))
Change to
if (CrossAbove(PctB[0], PctB[0], 1))
acura92
12-27-2011, 08:24 PM
this is the error msg i get when i try to compile
NinjaTrader_Brett
12-28-2011, 07:10 AM
Hello,
Can you attach the full .cs file on here so I can take a quick look at it. I dont see anything off hand but I suspect PctB and how it is declared earlier in the code.
-Brett
acura92
12-28-2011, 11:27 AM
Thanks Brett
Ive attached the .cs file.
NinjaTrader_Brett
12-28-2011, 12:27 PM
Hello,
Thanks for that.
The reason why it is doing this is the first data series is the same for the secondand series and I guess it checks for this. It needed another data series for the second one.
What two values are you trying to have cross over. Right now your code is trying to check againt PctB and PctB which will never occur because they both have the same values and as such you have the compile error.
-Brett
acura92
12-28-2011, 12:30 PM
to plot a arrow on the chart when bollingerpercet histogram passes 20 & down arrow when falls below 80(or even bar changes color when these conditions meet).
Thanks
Acura
NinjaTrader_Brett
12-28-2011, 12:34 PM
In this case
if (CrossAbove(20, PctB[0], 1))
Will do the trick for the 20 cross, do the same for the 80 cross if statement.
-Brett
acura92
12-28-2011, 12:48 PM
I really dumb when it comes to all this, I appreciate all your time & effort with this.
Thanks
Acura
NinjaTrader_Brett
12-28-2011, 12:55 PM
Hello,
I did mine with SMA() in my test and did not notice apologize about that.
When I used yours I then needed to use it as such:
if (CrossAbove(20, PctB, 1))
Let me know if I can be of further assistance.
acura92
12-28-2011, 01:20 PM
Brett im sorry i keep bugging you with this.
ive attached a chart with manually drawn arrows on the chart. This is the way I would like the Bollinger to plot arrows on the Chart.
thanks
Acura
NinjaTrader_Brett
12-28-2011, 01:54 PM
Hello,
You would change your draw arrow line to the following:
DrawArrowUp("UpArrow" + CurrentBar, false, 0, Low[0], Color.Blue);
Then you will want to add a second indicator to your chart and set it to Panel 0 the primary bars panel and then set the plots colors to be transparent so that it does not plot anything and only draws the arrows in the primary series.
-Brett
NinjaTrader_Brett
12-28-2011, 01:55 PM
Make sure the plot panel is same as input series and the scale justification is set to right.
-Brett
acura92
12-28-2011, 02:13 PM
Thanks it is working but it is plotting an arrow when the histogram goes below 20 & Im looking the other way around. when it passes above 20 to plot an up arrow.
Brett youve really helped me get this far, just a few more steps, you dunno how much time you have saved me by giving your time to this project.
Thanks
Acura
NinjaTrader_RyanM
12-28-2011, 02:22 PM
Hi Acura,
Thanks it is working but it is plotting an arrow when the histogram goes below 20 & Im looking the other way around. when it passes above 20 to plot an up arrow.
It sounds like you're looking for CrossAbove() instead of CrossBelow()
acura92
12-28-2011, 02:26 PM
Thanks Ryan
Im actually looking for both, if it crosses below 80 to generate a down arrow & crosses above 20 to generate an up arrow on the chart. so far the code that Brett provided me did work but was plotting an up arrow when the histogram was crossing below 20.
I wish i knew how to reverse this but have zero ninja programming knowledge.
Thanks
acura
NinjaTrader_RyanM
12-28-2011, 02:35 PM
If you are new to this it may be worthwhile to start with the condition builder. You can build crossing expressions there with your mouse and then view the resulting code. You can build both CrossAbove and CrossBelow conditions there.
See the following link:
http://www.ninjatrader.com/support/helpGuides/nt7/condition_builder.htm
Then expand the section: How to create a cross over condition
acura92
12-28-2011, 02:37 PM
Thanks Ryan
Ill look into that.
Acura
thankyou brett to get me in the right direction. you were great help