wayneL
VIVA LA LIBERTAD, CARAJO!
- Joined
- 9 July 2004
- Posts
- 25,747
- Reactions
- 12,930
Re: Daytrading- How to make a profit
Hmmm I typed out a long reply and somehow deleted it I'll have to come back to this, but here is the code
/* wayneL's Daytrading Template - To be plotted on intraday charts */
GraphXSpace = 1;
/* This plots the price bars. Select whether you want candlesticks or ordinary bars via th "view" menu */
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
/* The following three codes are the exponential moving average flippers. These can be deleted or modified to suit */
_SECTION_BEGIN("10EMA Flipper");
mov = 10;
hi = EMA(H,mov);
lo = EMA(L,mov) ;
x1 = IIf(C>Ref(hi,-1),1,IIf(C<Ref(lo,-1),-1,0));
x2 = ValueWhen(x1!=0,x1,1);
st = IIf(x2==-1,Hi,Lo);
Plot(Ref(st,-1),"",colorYellow,styleNoLine|styleBar|styleNoLabel);
_SECTION_END();
_SECTION_BEGIN("20EMA Flipper");
mov = 20;
hi = EMA(H,mov);
lo = EMA(L,mov) ;
x1 = IIf(C>Ref(hi,-1),1,IIf(C<Ref(lo,-1),-1,0));
x2 = ValueWhen(x1!=0,x1,1);
st = IIf(x2==-1,Hi,Lo);
Plot(Ref(st,-1),"",colorWhite,styleNoLine|styleBar|styleNoLabel);
_SECTION_END();
_SECTION_BEGIN("34EMA Flipper");
mov = 34;
hi = EMA(H,mov);
lo = EMA(L,mov) ;
x1 = IIf(C>Ref(hi,-1),1,IIf(C<Ref(lo,-1),-1,0));
x2 = ValueWhen(x1!=0,x1,1);
st = IIf(x2==-1,Hi,Lo);
Plot(Ref(st,-1),"",colorRed,styleNoLine|styleBar|styleNoLabel);
_SECTION_END();
/* The next section calculates and plots the dynamic 3 day pivots */
_SECTION_BEGIN("3 Day Pivots");
Hi1 = IIf(Day()!=Ref(Day(),-1),Ref(HighestSince(Day()!=Ref(Day(),-1),H,3),-1),0);
Hi = ValueWhen(Day()!=Ref(Day(),-1),Hi1,1);
Lo1 = IIf(Day()!=Ref(Day(),-1),Ref(LowestSince(Day()!=Ref(Day(),-1),L,3),-1),0);
Lo = ValueWhen(Day()!=Ref(Day(),-1),Lo1,1);
Cl1 = IIf(Day()!=Ref(Day(),-1),Ref(C,-1),0);
Cl = ValueWhen(Day()!=Ref(Day(),-1),Cl1,1);
rg = (Hi - Lo);
bp = (Hi + Lo + Cl)/3;
r1 = (bp*2)-Lo;
s1 = (bp*2)-Hi;
r2 = bp + r1 - s1;
s2 = bp - r1 + s1;
Plot(s2,"",colorRed,styleBar|styleNoRescale|styleNoLabel);
Plot(r2,"",colorRed,styleBar|styleNoRescale|styleNoLabel);
Plot(s1,"",colorBlue,styleBar|styleNoRescale|styleNoLabel);
Plot(r1,"",colorBlue,styleBar|styleNoRescale|styleNoLabel);
_SECTION_END();
/* This next section calculates and plots the daily pivots using fibonacci ranges */
_SECTION_BEGIN("Daily Fib Pivots");
Hi1 = IIf(Day()!=Ref(Day(),-1),Ref(HighestSince(Day()!=Ref(Day(),-1),H,1),-1),0);
Hi = ValueWhen(Day()!=Ref(Day(),-1),Hi1,1);
Lo1 = IIf(Day()!=Ref(Day(),-1),Ref(LowestSince(Day()!=Ref(Day(),-1),L,1),-1),0);
Lo = ValueWhen(Day()!=Ref(Day(),-1),Lo1,1);
Cl1 = IIf(Day()!=Ref(Day(),-1),Ref(C,-1),0);
Cl = ValueWhen(Day()!=Ref(Day(),-1),Cl1,1);
rg = (Hi - Lo);
bp = (Hi + Lo + Cl)/3;
r1 = (bp*2)-Lo;
s1 = (bp*2)-Hi;
r2 = bp + rg;
s2 = bp - rg;
r2o = bp + (1.272*rg);
s2o = bp - (1.272*rg);
rh = bp + (0.5*rg);
rl = bp - (0.5*rg);
rh6 = bp + (0.618*rg);
rl6 = bp - (0.618*rg);
Plot(s2,"",colorCustom12,styleBar|styleNoRescale|styleNoLabel);
Plot(r2,"",colorCustom12,styleBar|styleNoRescale|styleNoLabel);
Plot(rh,"",colorCustom12,styleBar|styleNoRescale|styleNoLabel);
Plot(rl,"",colorCustom12,styleBar|styleNoRescale|styleNoLabel);
Plot(bp,"",colorYellow,styleThick|styleNoRescale|styleNoLabel);
Plot(rh6,"",colorWhite,styleBar|styleNoRescale|styleNoLabel);
Plot(rl6,"",colorWhite,styleBar|styleNoRescale|styleNoLabel);
Plot(r2o,"",colorWhite,styleBar|styleNoRescale|styleNoLabel);
Plot(s2o,"",colorWhite,styleBar|styleNoRescale|styleNoLabel);
Plot(s2o,"",colorBlack,styleArea|styleNoRescale|styleNoLabel);
Plot(s2,"",colorPlum,styleArea|styleNoRescale|styleNoLabel);
Plot(rl6,"",colorBlack,styleArea|styleNoRescale|styleNoLabel);
Plot(rl,"",colorDarkOliveGreen,styleArea|styleNoRescale|styleNoLabel);
Plot(rh,"",colorBlack,styleArea|styleNoRescale|styleNoLabel);
Plot(rh6,"",colorDarkOliveGreen,styleArea|styleNoRescale|styleNoLabel);
Plot(r2,"",colorBlack,styleArea|styleNoRescale|styleNoLabel);
Plot(r2o,"",colorPlum,styleArea|styleNoRescale|styleNoLabel);
_SECTION_END();
//--end----------------------------------------------------------------------------
pski said:Hi Wayne,
I have read some of Frank's posts on Reef and have just started AFL with Amibroker.
If the offer to provide the code still stands, I would be grateful so I may 1/ understand how you are working with Frank's theories and 2/ see how you have put it together to plot the chart in AFL.
Many thanks,
Peter
Hmmm I typed out a long reply and somehow deleted it I'll have to come back to this, but here is the code
/* wayneL's Daytrading Template - To be plotted on intraday charts */
GraphXSpace = 1;
/* This plots the price bars. Select whether you want candlesticks or ordinary bars via th "view" menu */
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
/* The following three codes are the exponential moving average flippers. These can be deleted or modified to suit */
_SECTION_BEGIN("10EMA Flipper");
mov = 10;
hi = EMA(H,mov);
lo = EMA(L,mov) ;
x1 = IIf(C>Ref(hi,-1),1,IIf(C<Ref(lo,-1),-1,0));
x2 = ValueWhen(x1!=0,x1,1);
st = IIf(x2==-1,Hi,Lo);
Plot(Ref(st,-1),"",colorYellow,styleNoLine|styleBar|styleNoLabel);
_SECTION_END();
_SECTION_BEGIN("20EMA Flipper");
mov = 20;
hi = EMA(H,mov);
lo = EMA(L,mov) ;
x1 = IIf(C>Ref(hi,-1),1,IIf(C<Ref(lo,-1),-1,0));
x2 = ValueWhen(x1!=0,x1,1);
st = IIf(x2==-1,Hi,Lo);
Plot(Ref(st,-1),"",colorWhite,styleNoLine|styleBar|styleNoLabel);
_SECTION_END();
_SECTION_BEGIN("34EMA Flipper");
mov = 34;
hi = EMA(H,mov);
lo = EMA(L,mov) ;
x1 = IIf(C>Ref(hi,-1),1,IIf(C<Ref(lo,-1),-1,0));
x2 = ValueWhen(x1!=0,x1,1);
st = IIf(x2==-1,Hi,Lo);
Plot(Ref(st,-1),"",colorRed,styleNoLine|styleBar|styleNoLabel);
_SECTION_END();
/* The next section calculates and plots the dynamic 3 day pivots */
_SECTION_BEGIN("3 Day Pivots");
Hi1 = IIf(Day()!=Ref(Day(),-1),Ref(HighestSince(Day()!=Ref(Day(),-1),H,3),-1),0);
Hi = ValueWhen(Day()!=Ref(Day(),-1),Hi1,1);
Lo1 = IIf(Day()!=Ref(Day(),-1),Ref(LowestSince(Day()!=Ref(Day(),-1),L,3),-1),0);
Lo = ValueWhen(Day()!=Ref(Day(),-1),Lo1,1);
Cl1 = IIf(Day()!=Ref(Day(),-1),Ref(C,-1),0);
Cl = ValueWhen(Day()!=Ref(Day(),-1),Cl1,1);
rg = (Hi - Lo);
bp = (Hi + Lo + Cl)/3;
r1 = (bp*2)-Lo;
s1 = (bp*2)-Hi;
r2 = bp + r1 - s1;
s2 = bp - r1 + s1;
Plot(s2,"",colorRed,styleBar|styleNoRescale|styleNoLabel);
Plot(r2,"",colorRed,styleBar|styleNoRescale|styleNoLabel);
Plot(s1,"",colorBlue,styleBar|styleNoRescale|styleNoLabel);
Plot(r1,"",colorBlue,styleBar|styleNoRescale|styleNoLabel);
_SECTION_END();
/* This next section calculates and plots the daily pivots using fibonacci ranges */
_SECTION_BEGIN("Daily Fib Pivots");
Hi1 = IIf(Day()!=Ref(Day(),-1),Ref(HighestSince(Day()!=Ref(Day(),-1),H,1),-1),0);
Hi = ValueWhen(Day()!=Ref(Day(),-1),Hi1,1);
Lo1 = IIf(Day()!=Ref(Day(),-1),Ref(LowestSince(Day()!=Ref(Day(),-1),L,1),-1),0);
Lo = ValueWhen(Day()!=Ref(Day(),-1),Lo1,1);
Cl1 = IIf(Day()!=Ref(Day(),-1),Ref(C,-1),0);
Cl = ValueWhen(Day()!=Ref(Day(),-1),Cl1,1);
rg = (Hi - Lo);
bp = (Hi + Lo + Cl)/3;
r1 = (bp*2)-Lo;
s1 = (bp*2)-Hi;
r2 = bp + rg;
s2 = bp - rg;
r2o = bp + (1.272*rg);
s2o = bp - (1.272*rg);
rh = bp + (0.5*rg);
rl = bp - (0.5*rg);
rh6 = bp + (0.618*rg);
rl6 = bp - (0.618*rg);
Plot(s2,"",colorCustom12,styleBar|styleNoRescale|styleNoLabel);
Plot(r2,"",colorCustom12,styleBar|styleNoRescale|styleNoLabel);
Plot(rh,"",colorCustom12,styleBar|styleNoRescale|styleNoLabel);
Plot(rl,"",colorCustom12,styleBar|styleNoRescale|styleNoLabel);
Plot(bp,"",colorYellow,styleThick|styleNoRescale|styleNoLabel);
Plot(rh6,"",colorWhite,styleBar|styleNoRescale|styleNoLabel);
Plot(rl6,"",colorWhite,styleBar|styleNoRescale|styleNoLabel);
Plot(r2o,"",colorWhite,styleBar|styleNoRescale|styleNoLabel);
Plot(s2o,"",colorWhite,styleBar|styleNoRescale|styleNoLabel);
Plot(s2o,"",colorBlack,styleArea|styleNoRescale|styleNoLabel);
Plot(s2,"",colorPlum,styleArea|styleNoRescale|styleNoLabel);
Plot(rl6,"",colorBlack,styleArea|styleNoRescale|styleNoLabel);
Plot(rl,"",colorDarkOliveGreen,styleArea|styleNoRescale|styleNoLabel);
Plot(rh,"",colorBlack,styleArea|styleNoRescale|styleNoLabel);
Plot(rh6,"",colorDarkOliveGreen,styleArea|styleNoRescale|styleNoLabel);
Plot(r2,"",colorBlack,styleArea|styleNoRescale|styleNoLabel);
Plot(r2o,"",colorPlum,styleArea|styleNoRescale|styleNoLabel);
_SECTION_END();
//--end----------------------------------------------------------------------------