Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Multicharts Code - Outside Bollinger Bands
Updated November 30, 2015
trending_up
1,956 views
thumb_up
3 thanks given
group
2 followers
forum
7 posts
attach_file
0 attachments
Multicharts Code - Outside Bollinger Bands
November 27th, 2015, 06:47 AM
Aschaffenburg
Experience: Beginner
Platform: NinjaTrader, Multicharts
Trading: ES
Posts: 15 since Feb 2012
Thanks Given: 4
Thanks Received: 1
Hello,
I am having a problem with my Multicharts Code, maybe somebody can give me advice please.
The "Squeeze" is working, but I would like to print a "!" over the bar, when the price closes 2 times over/under
the upper/lower Bollinger Band.
I created the Input "OutOfBands ( 2 )" and some variables, but I don´t see the "!" on the chart.
Here is my Code:
Code
{
November 2015
BBSqueeze Indicator
}
inputs:
BollingerPrice ( close),
Length ( 10 ),
NumDevsUp ( 1 ),
NumDevsDn ( -1 ),
NumBars ( 90 ),
OutOfBands ( 2 ),
SqueezeColor ( Yellow ),
TextSize ( 16 );
Variables:
Av ( 0 ),
SDev ( 0 ),
LowerBand ( 0 ),
UpperBand ( 0 ),
FixBollPrice ( 0 ),
Diff ( 0 ),
OutUpBand ( 0 ),
OutDnBand ( 0 ),
SignalUpBand ( 0 ),
SignalDnBand ( 0 ),
VertTxtP1 ( 2 ), // 0 - below the specified price value
// 1 - above the specified price value
// 2 - centered on the specified price value
HorizTxtP1 ( 2 ), // 0 - to the right of the specified bar
// 1 - to the left of the specified bar
// 2 - centered on the specified bar
HiTxt (-1),
LoTxt (-1);
Av = AverageFC ( Bollingerprice, Length );
SDev = StandardDev ( BollingerPrice, Length, 1 );
UpperBand = Av + NumDevsUp * SDev;
LowerBand = Av + NumDevsDn * SDev;
Diff = UpperBand - LowerBand;
if Close > UpperBand then
OutUpBand = OutUpBand +1
else
OutUpBand = 0;
if close < LowerBand then
OutDnBand = OutDnBand +1
else
OutDnBand = 0;
if OutUpBand = OutOfBands then
HiTxt = text_new(date,time,high +1 ,"!");
text_setcolor(HiTxt,white);
text_setsize(HiTxt,TextSize);
text_setstyle(HiTxt, HorizTxtP1,VertTxtP1);
if OutDnBand = OutOfBands then
LoTxt = text_new(date,time,high +1 ,"!");
text_setcolor(LoTxt,white);
text_setsize(LoTxt,TextSize);
text_setstyle(LoTxt, HorizTxtP1,VertTxtP1);
Plot1 ( UpperBand, "Upperband");
Plot2 ( LowerBand, "Lowerband");
Plot3 ( Av, "Av");
If Diff <= Lowest ( Diff, NumBars ) then
begin
SetPlotColor ( 1, Squeezecolor );
SetPlotWidth ( 1, 3);
SetPlotColor ( 2, Squeezecolor );
SetPlotWidth ( 2, 3);
Alert (Getsymbolname + "Squeeze" );
End;
Any idea what is wrong or missing?
Thank you.
Best regards,
Tim
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
November 27th, 2015, 09:58 AM
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627
Hi Tim,
I just tested your code and I get quite a lot "!" symbols on a 5 min @ES#. There are two potential issues that I can think of at the moment: 1. you are using a symbol where 1 point represents a large move (like a Forex symbol for example). 2. Your background color for the chart happens to be white which would be the same color as the exclamation marks.
When you right click on the chart and go to "Format Drawings" you should see several text objects in the list.
Regards,
ABCTG
November 27th, 2015, 10:24 AM
Aschaffenburg
Experience: Beginner
Platform: NinjaTrader, Multicharts
Trading: ES
Posts: 15 since Feb 2012
Thanks Given: 4
Thanks Received: 1
Hi ABCTG,
thank you, the white color was the problem! Sometimes it is so easy....
I have found another Problem. When I plot the Bollinger Bands with my Indicator and add another Bollinger Band
Indicator from Multicharts I have 2 different plots in the Chart window. But in the Data Window I have the same correct numbers.
Whats wrong here?
Thanks.
Best regards,
Tim
November 27th, 2015, 11:54 AM
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627
Tim,
that's most likely a scaling issue. When you check the Scaling tab under Format Study for each indicator both should be set to "Same as Instrument".
Regards,
ABCTG
November 27th, 2015, 03:22 PM
Aschaffenburg
Experience: Beginner
Platform: NinjaTrader, Multicharts
Trading: ES
Posts: 15 since Feb 2012
Thanks Given: 4
Thanks Received: 1
Hi ABCTG,
thank you very much, that is the solution!
Best regards,
Tim
November 30th, 2015, 04:03 AM
Aschaffenburg
Experience: Beginner
Platform: NinjaTrader, Multicharts
Trading: ES
Posts: 15 since Feb 2012
Thanks Given: 4
Thanks Received: 1
Good morning ABCTG,
I tried over the weekend to change my code, but unfortunately I don't found a solution.
I plot "!" on the chart when the variable OutUpBand = OutOfBands:
Code
if OutUpBand = OutOfBands then
HiTxt = text_new(date,time,high +1 ,"!");
text_setcolor(HiTxt,white);
text_setsize(HiTxt,TextSize);
text_setstyle(HiTxt, HorizTxtP1,VertTxtP1);
Now I would like to print instead the "!" the value of the variable "OutUpBand".
Is this possible? How can I realize that?
Thank you.
Best regards,
Tim
November 30th, 2015, 04:13 AM
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627
Hi Tim,
you need to convert a numerical variable to a string using the reserved word NumToStr. Then you can draw this string on the chart.
Code
if OutUpBand = OutOfBands then
begin //using the begin here to include all text related reserved words in the check
HiTxt = text_new(date,time,high +1 , NumToStr( OutUpBand, 0 ) ) ;
text_setcolor(HiTxt,white);
text_setsize(HiTxt,TextSize);
text_setstyle(HiTxt, HorizTxtP1,VertTxtP1);
end ;
Regards,
ABCTG
venatrix
Good morning ABCTG,
I tried over the weekend to change my code, but unfortunately I don't found a solution.
I plot "!" on the chart when the variable OutUpBand = OutOfBands:
Code
if OutUpBand = OutOfBands then
HiTxt = text_new(date,time,high +1 ,"!");
text_setcolor(HiTxt,white);
text_setsize(HiTxt,TextSize);
text_setstyle(HiTxt, HorizTxtP1,VertTxtP1);
Now I would like to print instead the "!" the value of the variable "OutUpBand".
Is this possible? How can I realize that?
Thank you.
Best regards,
Tim
November 30th, 2015, 04:44 AM
Aschaffenburg
Experience: Beginner
Platform: NinjaTrader, Multicharts
Trading: ES
Posts: 15 since Feb 2012
Thanks Given: 4
Thanks Received: 1
Hello ABCTG,
thank you so much for your help! That looks great now!
Best regards,
Tim
Last Updated on November 30, 2015