Search
Saturday, May 19, 2012 ..:: Home ::.. Register  Login
Welcome Guest! To enable all features please try to register or login.

Notification

Icon
Error

Remove Excessive Signals/Labels
Monkey
#1 Posted : Tuesday, December 20, 2011 10:38:55 AM(UTC)
Rank: Newbie

Groups: Member, Registered Users, Subscribers
Joined: 2/4/2011(UTC)
Posts: 9
Points: 27
Location: South Africa

One of the things I have been unable to code for SF is functionality to remove the excessive signals/labels generated on a chart. Therefore not to show a Buy signal if there is already an open Buy, not to show a Sell signal unless there is a previous Buy, etc. For busy trading systems this is essential for making the chart readable and executing the right signals. This function is easily handled by the ExRem function in Amibroker.



Coding is hampered by the SF BarsSince function, which gives the bar count since the first signal on the chart instead of the most recent.



Any ideas here? 
estuary
#2 Posted : Thursday, May 03, 2012 12:12:11 PM(UTC)
estuary

Rank: Administration

Groups: Administration, Administrators, Registered Users, Subscribers
Joined: 1/9/2008(UTC)
Posts: 138
Points: 220
Location: South Africa

Was thanked: 5 time(s) in 4 post(s)

Hi Monkey,



The solution is best illustrated by means of an example.  The code below is a simple strategy based on an RSI crossing certain set levels (60 and 40):



-------------------------------------------------------------

RSI:"Momentum.RSI(14)";


UpperLevel:60;

LowerLevel:40;


SELL:=CROSS(RSI,UpperLevel);

BUY:=CROSS(LowerLevel,RSI);


DRAWTEXT(BUY==1,RSI,'BUY',1),Label2,VCenter,Bottom;

DRAWTEXT(SELL==1,RSI,'SELL',2),Label1,VCenter,Top;

-------------------------------------------------------------



The above code will put 'BUY' and 'SELL' labels on the RSI in a manner you describe in your post - i.e. multiple consecutive buys and sells.  Changing the code to the below solves this problem:



-------------------------------------------------------------

RSI:"Momentum.RSI(14)";

UpperLevel:60;

LowerLevel:40;


SELL:=CROSS(RSI,UpperLevel);

BUY:=CROSS(LowerLevel,RSI);


BarsSinceLastBuy:=REF(HHVBARS(BUY,100000),1);

BarsSinceLastSell:=REF(HHVBARS(SELL,100000),1);

CanSell:=IF(BarsSinceLastBuy>BarsSinceLastSell,0,1);

CanBuy:=IF(BarsSinceLastSell>BarsSinceLastBuy,0,1);

SELL2 := SELL * CanSell;

BUY2 := BUY * CanBuy;


DRAWTEXT(BUY2==1,RSI,'BUY',1),Label2,VCenter,Bottom;

DRAWTEXT(SELL2==1,RSI,'SELL',2),Label1,VCenter,Top;

-------------------------------------------------------------



The critical lines are:



BarsSinceLastBuy:=REF(HHVBARS(BUY,100000),1);

BarsSinceLastSell:=REF(HHVBARS(SELL,100000),1);

CanSell:=IF(BarsSinceLastBuy>BarsSinceLastSell,0,1);

CanBuy:=IF(BarsSinceLastSell>BarsSinceLastBuy,0,1);

SELL2 := SELL * CanSell;

BUY2 := BUY * CanBuy;




If you set up a strategy and create your initial buy and sell criteria and call them 'BUY' and 'SELL', you should be able to utilise the lines above - note that the adapted, non-repeating buy and sell signals are then called 'BUY2' and 'SELL2'.



If you have any problems with the above, please call Swordfish support.



Estuary

Monkey
#3 Posted : Monday, May 07, 2012 1:01:27 PM(UTC)
Rank: Newbie

Groups: Member, Registered Users, Subscribers
Joined: 2/4/2011(UTC)
Posts: 9
Points: 27
Location: South Africa

Thanks, that will work!
Appreciated.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Copyright 2007-2009 by Estuary Solutions   Terms Of Use  Privacy Statement