Gamestudio Links
Zorro Links
Newest Posts
retrain - data?
by danatrader. 09/20/20 05:27
Single advise model for portfolio
by jmlocatelli. 09/19/20 22:24
New Zorro version 2.30
by danatrader. 09/19/20 08:25
Special Bars Script
by danatrader. 09/19/20 00:41
NeoDumont's open world treadmill project
by NeoDumont. 09/19/20 00:30
Key_Pressed Variable
by Dooley. 09/18/20 22:46
lock profit without trail
by Grat. 09/18/20 14:30
how to use BrokerHistory2
by Grat. 09/18/20 14:29
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
5 registered members (danatrader, NewBorn, Grat, AndrewAMD, 1 invisible), 429 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
NewBorn, 3dvg, secretagentman, distribution, EditeY
18515 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Bollinger Band - Multi Timeframe #479052
02/10/20 09:17
02/10/20 09:17
Joined: Nov 2018
Posts: 4
M
migo Offline OP
Guest
migo  Offline OP
Guest
M

Joined: Nov 2018
Posts: 4
Hello every one,
I've been trying to get BB to work on multiple time frames but failed miserabily, I read the manual but still something is missing:
I want to have Bar Period of 5 and then M15 M30 H1 H4 H24 timeframe each with its own BB.
My end result is that I want to make a decision on the 5 minutes period, but need to access BB from other timeframes

The code below doesn't seem work:


Code
	StartDate = 2018;
	EndDate = 2019;
	BarPeriod = 5;
	LookBack = 80*4*24; // ~ 4 months
	MaxBars = 2000;

//series for different bands defined using global variables

	while(asset(loop("EUR/USD", "USD/JPY")))
	while(algo(loop("M5", "M15", "H1","H4", "H24")))
	{
		TimeFrame = 1;
			vars Close = series(priceClose());
			vars priceLows = series(priceLow());
			vars priceHighs = series(priceHigh());
			
			BBands((series(10*priceClose())),signal,NbDevUp,NbDevDn,MAType_SMA);
				upperBandM5 = series(rRealUpperBand/10);
				lowerBandM5 = series(rRealLowerBand/10);
				middleBandM5 = series(rRealMiddleBand/10);
				widthM5 = (upperBandM5[1] - lowerBandM5[1])/middleBandM5[0];
		if(Algo == "M15")
		{
				
			// BBands((series(10*priceClose())),signal,NbDevUp,NbDevDn,MAType_SMA);
				// upperBandM15 = series(rRealUpperBand/10);
				// lowerBandM15 = series(rRealLowerBand/10);
				// middleBandM15 = series(rRealMiddleBand/10);
				// widthM15 = (upperBandM15[1] - lowerBandM15[1])/middleBandM15[0];

		}
		else if(Algo == "H1")
		{
			TimeFrame = H1;	
			BBands((series(10*priceClose())),signal,NbDevUp,NbDevDn,MAType_SMA);
			 upperBandH1 = series(rRealUpperBand/10);
			 lowerBandH1 = series(rRealLowerBand/10);
			 middleBandH1 = series(rRealMiddleBand/10);
			 widthH1 = (upperBandH1[1] - lowerBandH1[1])/middleBandH1[0];
		}
		else if(Algo == "H4")
		{
			TimeFrame = H4; //4*4;		
			BBands((series(10*priceClose())),signal,NbDevUp,NbDevDn,MAType_SMA);
			 upperBandH4 = series(rRealUpperBand/10);
			 lowerBandH4 = series(rRealLowerBand/10);
			 middleBandH4 = series(rRealMiddleBand/10);
			 widthH4 = (upperBandH4[1] - lowerBandH4[1])/middleBandH4[0];
			
		}
		
		else if(Algo == "H24")
		{
			TimeFrame = H4;		
			BBands((series(10*priceClose())),signal,NbDevUp,NbDevDn,MAType_SMA);
			 upperBandH24 = series(rRealUpperBand/10);
			 lowerBandH24 = series(rRealLowerBand/10);
			 middleBandH24 = series(rRealMiddleBand/10);
			widthH24 = (upperBandH24[1] - lowerBandH24[1])/middleBandH24[0];

		}
		
				if (crossOver(Close, upperBandH4)) //This causes Zorro to crash
				{
					LifeTime = 1;
					enterShort();
				}
}


Appreciate your inputs.

Re: Bollinger Band - Multi Timeframe [Re: migo] #479059
02/11/20 11:32
02/11/20 11:32
Joined: Jul 2000
Posts: 27,341
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,341
Frankfurt
You're crossing over an uninitialized variable, so I would expect your code not to work. But it won't cause a "crash".

Re: Bollinger Band - Multi Timeframe [Re: migo] #479082
02/13/20 07:33
02/13/20 07:33
Joined: Nov 2018
Posts: 4
M
migo Offline OP
Guest
migo  Offline OP
Guest
M

Joined: Nov 2018
Posts: 4
Thanks for your answer!
By crash I mean Zorro unexpectedly exit, it just prematurely terminate without any error message, I'm using the latest build.

I tried to to fix all the variables and tried different techniques but still failing to multi BB timeframe to work, if there is a small example of couple of time frame that will be really helpful.
Thanks.

Re: Bollinger Band - Multi Timeframe [Re: migo] #479085
02/13/20 18:13
02/13/20 18:13
Joined: Mar 2019
Posts: 248
D
danatrader Online
Member
danatrader  Online
Member
D

Joined: Mar 2019
Posts: 248
I think it goes into the else if(Algo == "H24") so it ommits the else if(Algo == "H4"), therefore in the H24 the "upperBandH4" is not initialized.
Maybe to verify, let Zorro return the value of "upperBandH4" instead of the "crossover" statement.

Re: Bollinger Band - Multi Timeframe [Re: migo] #479089
02/15/20 06:50
02/15/20 06:50
Joined: Nov 2018
Posts: 4
M
migo Offline OP
Guest
migo  Offline OP
Guest
M

Joined: Nov 2018
Posts: 4
if (!is(LOOKBACK))
That seem to do the trick!

Thanks everyone for helping out!


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1