Welcome Guest! To enable all features please try to register or login.
Options
View
Go to last post Go to first unread
JOHAN_S  
#1 Posted : Thursday, December 8, 2011 11:20:20 AM(UTC)
JOHAN_S

Posts: 3

Thanks: 1 times

I need the script to draw buy and sell lables on the price.   
SELL -  when the price close and the stockastic is above 80 the sell label must be drawn on the first red bar that apeer,
BUY  -   when the price close and the stockastic is below 20 the buy label must be drawn on the first green bar that apeer

Can anyone help me here.

Thanks

estuary  
#2 Posted : Friday, December 9, 2011 6:59:17 PM(UTC)
estuary

Posts: 298

Thanks: 1 times
Was thanked: 19 time(s) in 17 post(s)

Hi Johan

You can use the following script to do something similar. This is just an example of creating "buy" and "sell" signals when the Relative Strength Index (RSI) breaches a certain level. Note that it is designed so that you can't have more than one consecutive "buy" or "sell" signal.

LC := REF(CLOSE,1);
RSI:SMA(MAX(CLOSE-LC,0),N1,1)/SMA(ABS(CLOSE-LC),N1,1)*100;

UpperLevel:70;
LowerLevel:30;

SELL:=CROSS(RSI,UpperLevel);
BUY:=CROSS(LowerLevel,RSI);

BarsSinceLastBuy:=REF(HHVBARS(BUY==1,100000),1);
BarsSinceLastSell:=REF(HHVBARS(SELL==1,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;

This should give you the following output:





If you want to display the labels on the candlestick graph rather than on the indicator, then use the following script:

LC := REF(CLOSE,1);
RSI:=SMA(MAX(CLOSE-LC,0),N1,1)/SMA(ABS(CLOSE-LC),N1,1)*100;

UpperLevel:=70;
LowerLevel:=30;

SELL:=CROSS(RSI,UpperLevel);
BUY:=CROSS(LowerLevel,RSI);

BarsSinceLastBuy:=REF(HHVBARS(BUY==1,100000),1);
BarsSinceLastSell:=REF(HHVBARS(SELL==1,100000),1);
CanSell:=IF(BarsSinceLastBuy>BarsSinceLastSell,0,1);
CanBuy:=IF(BarsSinceLastSell>BarsSinceLastBuy,0,1);
SELL2 := SELL * CanSell;
BUY2 := BUY * CanBuy;

STOCK;
DRAWTEXT(BUY2==1,C,'BUY',1),Label2,VCenter,Bottom;
DRAWTEXT(SELL2==1,C,'SELL',2),Label1,VCenter,Top;


This should give you the following output:



Hope this helps!
Regards
Estuary Solutions

 

Edited by user Friday, December 9, 2011 7:01:38 PM(UTC)  | Reason: Not specified

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.

Notification

Icon
Error