NexusFi: Find Your Edge


Home Menu

 





Multicharts Code - Outside Bollinger Bands


Discussion in MultiCharts

Updated
    1. trending_up 1,956 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Multicharts Code - Outside Bollinger Bands

  #1 (permalink)
 venatrix 
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

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
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

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
 venatrix 
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

Started this thread Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
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

Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
 venatrix 
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

Started this thread Reply With Quote
  #6 (permalink)
 venatrix 
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

Started this thread Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
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 View Post
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


Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
 venatrix 
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

Started this thread Reply With Quote




Last Updated on November 30, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts