Excess signals in spite of exrem

lvgandhi

Well-Known Member
#1
_SECTION_BEGIN("Trades");
SetPositionSize( 50, spsShares);

B1=Cross(K,75);
B2=KH>DH OR KH<25;
B3=Cross(K,D) AND K>75;
Buy=B2 AND (B1 OR B3);
Sell=Cross(D,K);
S1=Cross(25,K);
S2=KH<DH OR DH>75;
S3=Cross(D,K) AND D<25;
Short=S2 AND ( S1 OR S3);
Cover=Cross(K,D);
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorOrange ),0, IIf( Buy, K, D ), IIf( Buy, -5, -15 ) );
shape1 = Cover * shapeUpArrow + Short * shapeDownArrow;
PlotShapes( shape1, IIf( Cover, colorPaleGreen, colorRed ),0, IIf( Cover, D, K ), IIf( Cover, -15, -5 ) );
Buy=ExRem(Buy,Sell);
Sell= ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);

_SECTION_END();

k, D, KH, Dh are already defined and is working. I get excess signals for sell and cover in spite of exrem. How to remove them.
pic is below
http://imageshack.us/photo/my-images/12/mwsnap042.jpg
 
#3
Hi,

Your Exrem() statements has to be BEFORE you plot signals - like this :

SetPositionSize( 50, spsShares);

B1=Cross(K,75);
B2=KH>DH OR KH<25;
B3=Cross(K,D) AND K>75;
Buy=B2 AND (B1 OR B3);
Sell=Cross(D,K);
S1=Cross(25,K);
S2=KH<DH OR DH>75;
S3=Cross(D,K) AND D<25;
Short=S2 AND ( S1 OR S3);
Cover=Cross(K,D);

//You have to remove excess signals BEFORE they are being plotted
Buy=ExRem(Buy,Sell);
Sell= ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);

// Now since excess signals are removed, you can plot them as below
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorOrange ),0, IIf( Buy, K, D ), IIf( Buy, -5, -15 ) );
shape1 = Cover * shapeUpArrow + Short * shapeDownArrow;
PlotShapes( shape1, IIf( Cover, colorPaleGreen, colorRed ),0, IIf( Cover, D, K ), IIf( Cover, -15, -5 ) );

_SECTION_END();

Hope this helps.

Thanks,
CA



_SECTION_BEGIN("Trades");
SetPositionSize( 50, spsShares);

B1=Cross(K,75);
B2=KH>DH OR KH<25;
B3=Cross(K,D) AND K>75;
Buy=B2 AND (B1 OR B3);
Sell=Cross(D,K);
S1=Cross(25,K);
S2=KH<DH OR DH>75;
S3=Cross(D,K) AND D<25;
Short=S2 AND ( S1 OR S3);
Cover=Cross(K,D);
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorOrange ),0, IIf( Buy, K, D ), IIf( Buy, -5, -15 ) );
shape1 = Cover * shapeUpArrow + Short * shapeDownArrow;
PlotShapes( shape1, IIf( Cover, colorPaleGreen, colorRed ),0, IIf( Cover, D, K ), IIf( Cover, -15, -5 ) );
Buy=ExRem(Buy,Sell);
Sell= ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);

_SECTION_END();

k, D, KH, Dh are already defined and is working. I get excess signals for sell and cover in spite of exrem. How to remove them.
pic is below
http://imageshack.us/photo/my-images/12/mwsnap042.jpg
 
#4
Try this.
Turn on activate stops in settings (nothing else)

Replace buy/sell etc. on your code with this
PlotShapes( Buy * shapeUpTriangle, colorBrightGreen, 0);
PlotShapes( Short * shapeDownTriangle, colorOrange, 0);

then at the end of your code put this:

e = Equity(1,0);

PlotShapes( Buy* shapeUpArrow , colorDarkGreen, 0);
PlotShapes( Short* shapeDownArrow , colorDarkRed, 0);

In the new amibroker version, you need to run a backtest one-time/and a restart of amibroker to get all the arrows showed on the chart.

Then, in some of those triangles, the arrows are plotted.

goodluck!
 
Last edited:

Similar threads