Welcome! Log In Create A New Profile

Get Earnings and Seasonal Trends - Subscribe Today!

Advanced

MACD signals in the Watch List (help)‏ confused smiley

Posted by optiontrader101 
MACD signals in the Watch List (help)‏ confused smiley
May 10, 2014 11:34AM
Good morning Swimmers ,, smiling smiley



I want to put this script of MACD on the WATCH LIST as a signal BUY (green) or SELL (red) with the same value:

for example:




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



# MACD Dots on Price Chart
# Shows Primary Signals only. Once a BuyAlert is issued another BuyAlert cannot be issued until after a SellAlert has been issued, etc.
# Change Displace value below to adjust where Dots are placed on the Price Chart

input displace = .001;

input fastLength = 2;
input slowLength = 3;
input MACDLength = 2;
input AverageType = {default EMA};

def Value = MACD(fastLength, slowLength, MACDLength, AverageType).Value;
def Avg = MACD(fastLength, slowLength, MACDLength, AverageType).Avg;

def BuyAlert = Value > Avg;
def SellAlert = Value <= Avg;

rec count=if BuyAlert==1 and count[1]==0 then 1 else if SellAlert==0 and count[1]>=1 then count[1]+1 else 0;

rec count1=if SellAlert==1 and count1[1]==0 then 1 else if BuyAlert==0 and count1[1]>=1 then count1[1]+1 else 0;

def PrimaryBuyAlert = BuyAlert==1 and count==1;
def PrimarySellAlert = SellAlert==1 and count1==1;

plot DotUp = if PrimaryBuyAlert then Low * (1 - displace) else double.nan;
DotUp.SetPaintingStrategy(PaintingStrategy.POINTS);
DotUp.SetDefaultColor(Color.BLUE);
DotUp.SetLineWeight(5);
DotUp.HideBubble();
DotUp.HideTitle();

plot DotDn = if PrimarySellAlert then High * (1 + displace) else double.nan;
DotDn.SetPaintingStrategy(PaintingStrategy.POINTS);
DotDn.SetDefaultColor(Color.YELLOW);
DotDn.SetLineWeight(5);
DotDn.HideBubble();
DotDn.HideTitle();

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


thanks ,,
Re: MACD signals in the Watch List (help)‏ confused smiley
May 11, 2014 06:05AM
The code you posted uses recursive variables which are not allowed in to be used in a watchlist column. However, this will provide similar functionality.

def Value = MACD(2, 3, 2, "EMA" ).Value;
def Avg = MACD(2, 3, 2, "EMA" ).Avg;
def BuyAlert = Value > Avg; 
def SellAlert = Value <= Avg; 
addlabel(BuyAlert and !BuyAlert[1], "Buy  " );
addlabel(SellAlert and !SellAlert[1], "Sell  " );
assignbackgroundcolor(if BuyAlert then color.dark_green else if SellAlert then color.dark_red else color.current);



Edited 1 time(s). Last edit at 05/11/2014 06:05AM by robert.
Re: MACD signals in the Watch List (help)‏ confused smiley
May 11, 2014 08:41AM


YOU R THE BEST
Sorry, only registered users may post in this forum.

Click here to login