Use of indicator's result

Posted By: forexcoder

Use of indicator's result - 04/21/15 08:07

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.
Posted By: jcl

Re: Use of indicator's result - 04/21/15 09:56

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.
Posted By: forexcoder

Re: Use of indicator's result - 04/21/15 14:04

So the correct version is the second one. Is it right?
Posted By: forexcoder

Re: Use of indicator's result - 04/21/15 14:21

I tried both verions and both work (no error). But the first one gives a much better result.
© 2024 lite-C Forums