Hi
I'm beginning to learn programming with AFL.
I tried to code a basic stop-and-reverse system which buys and sells on price crossing over SAR. I think I may have done some error in the coding, because instead of Buying and Selling on the crossover of the price on the SAR 'dot', the system buys and sells on the closing price of that bar.
The following is the AFL code I wrote -
-------------------------------------------------------------------
AF=0.02;
AF=Optimize("OAF",0.02,0.01,0.2,0.01);
VSARValue=SAR(AF,0.2);
Buy=Cross(H,VSARValue);
Sell=Cross(VSARValue,L);
Short=Sell;
Cover=Buy;
AddColumn(SAR(0.02),"SAR",1.2);
----------------------------------------------------------------------
I have gone through the book by Howard Bandy - Introduction to Amibroker. I'm trying to code some simple AFLs to begin with. Any help with this code, and suggestions on how to get better at AFL programming will be of great help.
Thanks.
I'm beginning to learn programming with AFL.
I tried to code a basic stop-and-reverse system which buys and sells on price crossing over SAR. I think I may have done some error in the coding, because instead of Buying and Selling on the crossover of the price on the SAR 'dot', the system buys and sells on the closing price of that bar.
The following is the AFL code I wrote -
-------------------------------------------------------------------
AF=0.02;
AF=Optimize("OAF",0.02,0.01,0.2,0.01);
VSARValue=SAR(AF,0.2);
Buy=Cross(H,VSARValue);
Sell=Cross(VSARValue,L);
Short=Sell;
Cover=Buy;
AddColumn(SAR(0.02),"SAR",1.2);
----------------------------------------------------------------------
I have gone through the book by Howard Bandy - Introduction to Amibroker. I'm trying to code some simple AFLs to begin with. Any help with this code, and suggestions on how to get better at AFL programming will be of great help.
Thanks.