hi friends
can somebody convert this trade station code into afl please
-------------
can somebody convert this trade station code into afl please
-------------
HTML:
//TradeStation (EasyLanguage) code for "Moving beyond the closing price" by Thomas Stridsman, starting on p. 60
//http://www.activetradermag.com/index.php/c/Strategy_code
Inputs: LookBack(20);
Variable: PercChange(0),
NewLevel(0),
AvgPercChange(0);
PercChange = (Close -Close[1])/Close[1];
AvgPercChange =Average(PercChange,20);
NewLevel = Close *(1 + AvgPercChange);
Plot1[1](NewLevel,);
**
Inputs: StDevs(1);
Variable:StdDevChange(0),
UpLevel(0), DownLevel(0);
StdDevChange =StdDev(PercChange, 20);
UpLevel = Close *(1 + AvgPercChange +StDevs * StdDevChange);
DownLevel = Close *(1 + AvgPercChange -StDevs * StdDevChange);
Plot2[-1](UpLevel,);
Plot3[-1](DownLevel,);
**
HighPercChange = (High - Close[1])/Close[1];
**
Input: VSStd(1);
Vars: SumVS(0), AvgVS(0), DiffVS(0), StdVS(0), SetArr(0),SumArr(0), DiffArr(0), VSLow(0), VSMid(0), VSHigh(0);
{First we define the array}
Array: VS[20](0);
{Then we‰re using a loop function to fill it with the different price changes}
for SetArr = 0 To 4 Begin
VS[SetArr * 4 + 0] = (O[SetArr] - C[SetArr + 1]) / C[SetArr + 1];
VS[SetArr * 4 + 1] = (H[SetArr] - C[SetArr + 1]) / C[SetArr + 1];
VS[SetArr * 4 + 2] = (L[SetArr] - C[SetArr + 1]) / C[SetArr + 1];
VS[SetArr * 4 + 3] = (C[SetArr] - C[SetArr + 1]) / C[SetArr + 1];
End;
for SumArr = 0 To 19 Begin
if SumArr = 0 Then
SumVS = 0;
SumVS = SumVS + VS[SumArr];
if SumArr = 19 Then
{Here we calculate the average price change over the period}
AvgVS = SumVS / 20;
for DiffArr = 0 To 19 Begin
if DiffArr = 0 Then
DiffVS = 0;
{Then we calculate the standard deviation}
DiffVS = DiffVS + Square(VS[DiffArr] - AvgVS);
if DiffArr = 19 Then
StdVS = SquareRoot(DiffVS / 20);
End;
End;
{Finally, we add the moving average (AND the standard deviations) to the latest Close
for an indication of tomorrow‰s trading range}
VSLow = C * (1 + (AvgVS - StdVS * VSStd));
VSMid = C * (1 + AvgVS);
VSHigh = C * (1 + (AvgVS + StdVS * VSStd));
Plot1[-1](VSLow, ‹VS Low);
Plot2[-1](VSMid, ‹VS Mid);
Plot3[-1](VSHigh, ‹VS High);
Last edited: