Tuesday, February 7, 2012

ThinkScript Included: MarketForecast With Overbought/Sold Lines

The MarketForecast is a proprietary indicator that many of us Investools and Prophet Chart students/users were eagerly awaiting to arrive in TOS Charts. Well, they are here, in the new MarketForecast study but if you are used to seeing the MFC on prophet charts or on the Investools website there is a glaring omission: no overbought/sold lines. If you want those lines you might attempt to use the price-level drawing tool to add them but you will have to draw them for every equity you chart. The lines need to be part of the study. I could send ThinkOrSwim a feature request email but it is easy enough for me to get the ob, os lines by writing my own study. So here's the image of the study:

SPY, 1 month daily chart with sdi_mfc study.
Here's the code:

revision 1.1 post

#########################
# sdi_mfc
#hint: Displays the same signal lines as the TOS marketForecast study but with the addition of overBought and overSold levels. rev:1.1 http://www.smalldoginvestor.com
# author: allen everhart 2/5/12
# revision 1.1 14jun15 added cluster indicator.
# copylefts reserved. This is free software. That means you are free
# to use or modify it for your own usage but not for resale. 
# Help me get the word out about my blog by keeping this header
# in place.  
input overBought = 80 ;
#hint overBought: oscillator percentage considered overbought. rev:1.1 http://www.smalldoginvestor.com
declare lower;
input overSold = 20;
plot momentum = MarketForecast().momentum;
plot shortTerm = MarketForecast().NearTerm;
plot intermediate = MarketForecast().intermediate;
plot ob = overBought;
plot os = overSold;
momentum.SetDefaultColor(Color.DARK_ORANGE);
shortTerm.SetDefaultColor(Color.RED);
intermediate.SetDefaultColor(Color.BLUE);
ob.SetDefaultColor(Color.DARK_GREEN);
os.SetDefaultColor(Color.DARK_GREEN);

plot cluster=if momentum>ob && shortTerm>ob && intermediate> ob then 100
    else if momentum<os && shortTerm<os && intermediate<os then 0
    else double.nan;
cluster.setpaintingStrategy(paintingStrategy.POINTS);
cluster.defineColor("bearish", color.red);
cluster.defineColor("bullish", color.green);
cluster.assignValueColor(
# copylefts reserved. This is free software. That means you are free
# to use or modify it for your own usage but not for resale. 
# Help me get the word out about my blog by keeping this header
# in place. http://www.smalldoginvestor.com
    if !isnaN(cluster) && cluster==100 then cluster.color("bearish")
    else cluster.color("bullish"));
cluster.setlineWeight(5);
cluster.hideBubble();
def formingBar=!isnaN(close)&&isnan(close[-1]);
plot zed=if barNumber()%10 == 0 && !formingBar then 0 else double.NaN;
zed.setDefaultColor(color.light_GRAY);
zed.hideBubble();
plot uno=if barNumber()%10 ==0 && !formingBar then 105 else double.nan;
uno.setdefaultColor(color.light_gray);
uno.hidebubble();
########################## 

No comments:

Post a Comment