[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] divergence



PureBytes Links

Trading Reference Links




<FONT face="Times New Roman" 
color=#000000>Hi 
Dimitris,
 
I am developing a trading system and 
improving the exit signals.
Looking at divergences I found very 
good exit signals.
I found several divergence 
codes  for IB done by you to backtest. They are really very 
good!!
Do u have any other code about 
divergence? RSI divergence?
Below are the ones I 
found.
Thanks
 
JB
 
 
 
ST33=MACD();
bars=50<FONT face=Verdana 
size=2>;<FONT 
face="Times New Roman">
TR1=LLVBars<FONT 
color=#000000>(ST33,5<FONT 
face=Verdana size=2><FONT face="Times New Roman" 
color=#000000>);
COND1=TR1>0 
AND Ref<FONT 
size=2>(TR1,-1)==<FONT 
size=2>0 AND Ref<FONT 
size=2>(ST33,-1)<<FONT 
size=2>0<FONT 
face="Times New Roman" color=#000000>;<FONT 
face="Times New Roman">
TR2=IIf<FONT 
color=#000000>(COND1,Ref<FONT 
size=2>(ST33,-1),<FONT 
size=2>0<FONT 
face="Times New Roman">);<FONT face=Verdana 
size=2>
Plot<FONT 
size=2>(st33,"MACD",<FONT 
size=2>1,1<FONT 
face=Verdana size=2><FONT face="Times New Roman" 
color=#000000>);
M1=<FONT 
size=2>ValueWhen<FONT 
face="Times New Roman" color=#000000>(COND1,ST33);<FONT 
color=#0000ff>
P1=<FONT 
size=2>ValueWhen<FONT 
size=2>(COND1,LLV(L,<FONT 
size=2>3<FONT 
face="Times New Roman" color=#000000>));<FONT 
face="Times New Roman">
DM1=M1-<FONT 
size=2>Ref<FONT 
size=2>(M1,-1);DP1=P1-<FONT 
size=2>Ref(P1,-<FONT 
size=2>1<FONT 
face="Times New Roman" color=#000000>);<FONT 
face="Times New Roman">
DT=Ref<FONT 
color=#000000>(BarsSince<FONT 
size=2>(COND1),-1<FONT face=Verdana 
size=2>);<FONT 
color=#0000ff>
POSDIV=DM1>0 
AND DP1<0 AND DT<BARS;<FONT 
size=2>Plot(<FONT 
size=2>Ref(POSDIV*Ref<FONT 
size=2>(ST33,-1),<FONT 
size=2>1),""<FONT 
size=2>,5,<FONT 
size=2>2<FONT 
face="Times New Roman" color=#000000>);<FONT 
face="Times New Roman">
TR11=<FONT 
size=2>HHVBars<FONT 
size=2>(ST33,5<FONT face=Verdana 
size=2>);<FONT 
color=#0000ff>
COND11=TR11>0<FONT 
size=2> AND Ref<FONT 
color=#000000>(TR11,-1<FONT 
size=2>)==0 AND <FONT 
size=2>Ref(ST33,-1<FONT 
size=2>)>0<FONT face=Verdana 
size=2>;<FONT 
color=#0000ff>
TR21=IIf<FONT 
color=#000000>(COND11,Ref<FONT 
size=2>(ST33,-1),<FONT 
size=2>0<FONT 
face="Times New Roman" color=#000000>);<FONT 
face="Times New Roman">
M11=<FONT 
size=2>ValueWhen<FONT 
face="Times New Roman" color=#000000>(COND11,ST33);<FONT 
color=#0000ff>
P11=<FONT 
size=2>ValueWhen<FONT 
size=2>(COND11,HHV(H,<FONT 
size=2>3<FONT 
face="Times New Roman" color=#000000>));<FONT 
face="Times New Roman">
DM11=M11-<FONT 
size=2>Ref<FONT 
size=2>(M11,-1);DP11=P11-<FONT 
size=2>Ref(P11,-<FONT 
size=2>1<FONT 
face="Times New Roman" color=#000000>);<FONT 
face="Times New Roman">
DT1=Ref<FONT 
color=#000000>(BarsSince<FONT 
size=2>(COND11),-1<FONT face=Verdana 
size=2>);<FONT 
color=#0000ff>
NEGDIV=DM11<0<FONT 
size=2> AND DP11>0 AND 
DT1<BARS;Plot<FONT 
color=#000000>(NEGDIV*ST33,""<FONT 
size=2>,4,<FONT 
size=2>2<FONT 
face="Times New Roman">);
Filter=posdiv OR 
negdiv;<FONT 
face="Times New Roman">
AddColumn(posdiv,"POSITIVE 
DIV",1.0<FONT face=Verdana 
size=2>);<FONT 
face=Verdana size=2>
AddColumn(NEGDIV,"NEGATIVE 
DIV",1.0<FONT face=Verdana 
size=2>);
 
Paste in indicator 
builder or in AA and explore .
For the N100 
database, 13/100 of the population presented a bullish MACD divergence on 
March13, signaling the recent movement.
Another version of MACD divergence may come through 
trendlines.
There are some code problems, trendlines are based on 
Peak/Trough , which do not function properly with negative arrays.
We may overcome this difficulty using a 1000+MACD() instead of 
MACD() itself [I think the lowest MACD() for the last 10 years
was around -800 for ^N225]. I have to check some details for a 
uniform per= value and post this alternative too. 
 

Description:
A negative Stochastic divergence occurs when the tangent of Stochastic 
oscillator's graph is descending, whereas the tangent of price's graph is 
ascending for the same time interval .The occurrence of a negative 
stochastic divergence in overbought area, usually signals a trend 
reversal,especially if it is confirmed by complementary criteria.
Formula:/*Negative Stochastic divergence for use in 
Indicator Builder and Automatic Analysis (scan mode),
by Dimitris Tsokakis*/

ST33=stochd(14);
TR1=HHVBARS(ST33,4);
TR2=IIF(ST33>70 AND TR1>0 AND REF(TR1,-1)==0,ref(ST33,-1),0);
TRC=IIF(TR2>0,C,0);
vs=valuewhen(tr2, ref(st33,-1), 1);
dvs=vs-ref(vs,-1);
vc=valuewhen(trc, HHV(H,3), 1);
dvc=vc-ref(vc,-1);
diver=iif(dvs<0 and dvc>0,90,0);
DAS=BARSSINCE(REF(TR2,-1)>0);
ddd=IIF(DAS<20 AND C<REF(C,-1),DIVER,0);
GRAPH1=TR2;
graph0=ddd;
graph0barcolor=4;
GRAPH1STYLE=2;
graph1barcolor=1;
SELL=ddd==90;
Description:A positive stochastic divergence occurs when the tangent of Stochastic oscillator's graph is ascending, whereas the tangent of price's graph is descending for the same time interval .The occurrence of a positive stochastic divergence in oversold area, usually signals a trend reversal,especially if it is confirmed by complementary criteria.Formula:/*Positive Stochastic Divergence for use in 
Indicator Builder and Automatic Analysis (scan mode),
by Dimitris Tsokakis*/

ST33=STOCHD(14);
TR1=LLVBARS(ST33,4);
TR2=IIF(ST33<30 AND TR1>0 AND REF(TR1,-1)==0,ref(ST33,-1),0);
TRC=IIF(TR2>0,C,0);
vs=valuewhen(tr2, ref(st33,-1), 1);
dvs=vs-ref(vs,-1);
vc=valuewhen(trc, LLV(c,3), 1);
dvc=vc-ref(vc,-1);
diver=iif(dvs>0 and dvc<0,30,0);
DAS=BARSSINCE(REF(TR2,-1)>0);
DD=IIF(DAS<20 AND C>=REF(C,-1),DIVER,0);
GRAPH0=TR2;
GRAPH0STYLE=2;
graph0barcolor=12;
graph1=dd;
graph1barcolor=5;
BUY=DD>0 ;







Yahoo! Groups Sponsor


  ADVERTISEMENT









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.