Professional Documents
Culture Documents
/*
This is an attempt to provide a basic trading system AFL. The system is purely
imaginary
AND NOT provided as one that would make money. This is just to provide a guide to
learners
on the common components of writing AFL.
When you copy/paste ensure the existing continuous lines have not been wrapped.
This wrapping
can create error signals when you try to use the code. Click on the check afl
button in the
editor before trying to apply or scan.
I have used slash-asterisk /* */ /* for my comments to get around the problem of
wrapping,
which could happen if you used double slash //
*/
//Trade system
/*
Buy when exp mov avg crosses and the high is highest for 50 bars
Sell when exp mov avg crosses back
Cross is first variable moves to above the second variable
*/
LongPer = Param("Long Period", 50, 30, 100, 5 ); /* select periods with parameter
window */
ShortPer = Param("Short Period", 5, 3, 10, 1 );
GraphXSpace = 10; /* create empty space of 10% top and bottom of chart */
/* styleNoRescale in the plots stops the added plots from compressing the original
bar chart to the middle of the pane */
Title = Name() +" "+ Date() +" "+ "{{INTERVAL}}"+_DEFAULT_NAME()+" Chart values : "
+
" Close Price = " + C +
" EMA(C,"+WriteVal(LongPer,1)+") = "+WriteVal(LongMA,1.3) +
" EMA(C,"+WriteVal(ShortPer,1)+") = "+WriteVal(ShortMA,1.3) +
" HHV(H,"+WriteVal(LongPer,1)+") = "+WriteVal(Ref(LastHigh,-1),1.3) ;
*/
_SECTION_END();