
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Inputs : ARPeriod(9), Factor(1);
var:X(0), AvgRange(0), prevbars(0), first(True), shift(0), loopbegin(0);
SetLoopCount(0);
If ARPeriod < 1 Then Exit;
If Bars < prevbars Or Bars-prevbars>1 Then first = True;
prevbars = Bars;
If first Then Begin
loopbegin = Bars-ARPeriod-1;
If loopbegin < 0 Then Exit;
first = False;
End;
loopbegin = loopbegin+1;
For shift = loopbegin Downto 0 Begin
AvgRange = 0;
for X = 0 to(ARPeriod-1) Begin
AvgRange = AvgRange + High[X] - Low[X];
End;
AvgRange = AvgRange/ARPeriod;
SetIndexValue(shift,iMA(ARPeriod,MODE_SMA,shift)+AvgRange*Factor);
SetIndexValue2(shift,iMA(ARPeriod,MODE_SMA,shift)-AvgRange*Factor);
loopbegin = loopbegin-1;
End;
Unfortunately, I don't really know what half of this code really does. It looked pretty close, but I spotchecked a point on the graph and it was slightly off. Can anyone help me correct this code to compute the average range correctly? Thanks, J