Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (AndrewAMD, fogman, Grant, juanex), 972 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Use of indicator's result #450716
04/21/15 08:07
04/21/15 08:07
Joined: Feb 2015
Posts: 45
Italy
forexcoder Offline OP
Newbie
forexcoder  Offline OP
Newbie

Joined: Feb 2015
Posts: 45
Italy
Hi all. I have the following doubt:
if I use an indicator, for example the BBands, how can I use its resluts? For example, it is correct the following script:
Code:
vars PriceH1 = series(price());
vars TriggerLine = series(LowPass(PriceH1,optimize(7,5,9)));
BBands(PriceH1,20,2,2,MAType_SMA);
	
Stop = optimize(4,2,8) * ATR(60);
TakeProfit = optimize(4,2,8)*ATR(60);
	
if(crossOver(TriggerLine,rRealLowerBand)) 
		enterLong();
else if (crossUnder(TriggerLine,rRealUpperBand)) 
		enterShort();


or is correct this one:
Code:
vars PriceH1 = series(price());
	vars TriggerLine = series(LowPass(PriceH1,optimize(7,5,9)));
BBands(PriceH1,20,2,2,MAType_SMA);
vars upperBand = series(rRealUpperBand);
vars lowerBand = series(rRealLowerBand);
	vars middleBand = series(rRealMiddleBand);
Stop = optimize(4,2,8) * ATR(60);
TakeProfit = optimize(4,2,8)*ATR(60);
	
if(crossOver(TriggerLine,lowerBand )) 
		enterLong();
else if (crossUnder(TriggerLine,upperBand )) 
		enterShort();



in which I use series (lowerBand ecc.) instead of varables (rRealLowerBand ecc.).
Thanks.

Last edited by forexcoder; 04/21/15 08:10.
Re: Use of indicator's result [Re: forexcoder] #450717
04/21/15 09:56
04/21/15 09:56
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
You need series. crossOver/Under works also with a constant threshold, so your first code is also formally correct, but can miss crossovers because the BBand borders are not a constant value.

Re: Use of indicator's result [Re: jcl] #450726
04/21/15 14:04
04/21/15 14:04
Joined: Feb 2015
Posts: 45
Italy
forexcoder Offline OP
Newbie
forexcoder  Offline OP
Newbie

Joined: Feb 2015
Posts: 45
Italy
So the correct version is the second one. Is it right?

Re: Use of indicator's result [Re: forexcoder] #450727
04/21/15 14:21
04/21/15 14:21
Joined: Feb 2015
Posts: 45
Italy
forexcoder Offline OP
Newbie
forexcoder  Offline OP
Newbie

Joined: Feb 2015
Posts: 45
Italy
I tried both verions and both work (no error). But the first one gives a much better result.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1