Advanced Market Forecast Indicator & Scanner for ThinkorSwim


The Advanced Market Forecast indicator is a powerful tool that offers near term trend, intermediate, and momentum oscillator for ThinkorSwim. Similar to RSI and MFI, there will be levels of overbought and oversold. When the stock reaches these levels with the right confirmation, traders can expect a pullback or reversal.

There will be a scanner at the end of this post to help you scan for bullish and bearish signals produced by the Advanced Market Forecast indicator.


  • Green line = Intermediate Confirmation Signal
  • Dark blue = Near term line
  • Red = Momentum
You can also draw divergences using the blue near term line just like the MACD and RSI indicators.

thinkScript Code

Rich (BB code):
#Name: Dilbert_StanL_MarketForecast_TMF_original
#StudyName: Dilbert_StanL_MarketForecast_TMF_original
#Description: Replica of Investools MarketForecast study
#Author: Dilbert/Stanl/Mobius and assorted others you tried to crack this
#Requested By:
# Ver     Date     Auth      Change
# v2      012817   Dilbert   Finally calculate the momentum line correctly. Scale to 100 instead of 200.
# Link:
# Trading Notes:

# Market Forecast
# StanL
#hint:<b>Market Forecast</b>modified with upper and lower reversal zones and labels. Is a double-scale version of the original. All plots maintain their relation with 2X scale.

declare lower;
input ImedLength = 31; # orig std = 31
input MomentumLength = 5; # orig std = 31
input NearLength = 3; # orig std = 3

  def c1I = close - lowest(low,ImedLength);
   def c2I = highest(high,ImedLength) - lowest(low,ImedLength);
   def FastK_I = c1I / c2I * 100;
   def c1N = close - lowest(low,NearLength);
   def c2N = highest(high,NearLength) - lowest(low,NearLength);
   def FastK_N = c1N / c2N * 100;

   def c1M = close - lowest(low,MomentumLength);
   def c2M = highest(high,MomentumLength) - lowest(low,MomentumLength);
   def FastK_M = c1M / c2M * 100;
  Plot Intermediate = Average(FastK_I, 5); #  = TMF's GreenLine
   Plot NearTerm = Average(FastK_N, 2);     #  = TMF's BlueLine

def Min1 = Min(low, low[1]);
def Min2 = Min(min1, Min(low[2], low[3]));
def Max1 = Max(high, Max(high[1], Max(high[2], high[3])));

plot momentum = ((close - Min1) / (Max1 - Min2)) * 100;

plot bottomline = 0;

plot topLine = 100;

plot UpperRevZone = 80;

plot LowerRevZone = 20;
plot UpLimit = 120;

AddCloud(bottomline, LowerRevZone,,;
AddCloud(topLine, UpperRevZone, color.RED,;
AddLabel (yes, "Mom(short)", Color.yellow);
AddLabel (yes, "Near term",;
AddLabel (yes, "Med term",;

# Below lines are related to a scan
#   def ClusterHigh = Intermediate >= 80 && NearTerm >= 80 && Momentum >= 80 ;
#   def ClusterLow = Intermediate <= 20 && NearTerm <= 20 && Momentum <= 20;
#   plot cluster = if clusterhigh or clusterlow then 1 else 0;
#---------- End Of Code ---------------

Shareable Link:

Market Forecast Bullish Scanner
Rich (BB code):
MarketForecast()."Momentum" crosses above MarketForecast()."NearTerm" and MarketForecast()."NearTerm" crosses above MarketForecast()."Intermediate"

Market Forecast Bearish Scanner
Rich (BB code):
MarketForecast()."Momentum" crosses below MarketForecast()."NearTerm" and MarketForecast()."NearTerm" crosses below MarketForecast()."Intermediate"

Don't forget to replace MarketForecast with the name of your indicator.
Last edited:


New member
2019 Donor
HI, The two magenta colored lines in the chart, does it mean anything?

Last edited:


New member
2019 Donor
Hi, is there a way to add signal to indicate all three lines are in either oversold or overbought zone?

Last edited:


New member
2019 Donor
I added the following lines and it serve my need: though it is not very nice

Rich (BB code):
def BullCluster = momentum <=20 and intermediate <=20 and nearterm <=20;
def BearCluster = momentum >=80 and intermediate >=80 and nearterm >=80;
AddVerticalLine(Bullcluster , "Up", Color.UPTICK);
AddVerticalLine(BearCluster , "Down", Color.LIGHT_RED);
Last edited by a moderator:


@GeneHo Oh, the two lines on the upper chart were my Support and Resistance lines, drawn manually.

Last edited:


could you please explain the difference between the three momentum oscillators and why isn't the coding of the momentum
def c1M = close - lowest(low,MomentumLength);
def c2M = highest(high,MomentumLength) - lowest(low,MomentumLength);
def FastK_M = c1M / c2M * 100;
is used to plot the momentum?
thank you


Can you elaborate on how you use this please?

Is it as simple as if all three lines are in the overbought or oversold zone the probability of a reversal increases?


New member
I use the Market Forecast Daily, as a Main study for my success in trading. But I dont use the same way it is listed here. I have addition levels that are more Important. the 80 and 20 lines are just a Visual warning for me and dont provide great importance over all. I use a 30 50 70 Line as these are very Important to trend and taking trades. I use a two time frame approach, a daily chart, with a 5minute chart combination. Lets say I see that NG is either close to, or showing a setup on the daily. This Daily setup would be currently, Green Intermediate Line is above the 30 50 70, I then look at the Blue Near line and Red Momo Line, with the Inter Line High which is Bullish, I wait for the red momo and Blue Near to get Oversold under 20 and come back up to break 30 line this is when, I then start looking at the 5min for trade entries, using a REDSAR .01.05 breakout, and 30High/Low Breaking the High. and staying above it till a GoldSAR .02 .20 is Broken, Once the Daily setup starts I keep taken trades based on the 5min till it no longer breaks out, and or the Daily Red& Blue Lines get up to the 70 to 80 line, then I wait for another daily setup. I trade all Futures this way, and stocks. I have been doing it this way for years. I would Like to see if I can get it a Little more automated though.

I have some code I found a while back that uses the MF Info and provide Vertical lines for it, it is Not exactly how I want it but it is close.
# aaa_BVZ_MFC_Clusters_on_Chart - 8/21/2018 Developed by G. Horschman ([email protected])
# This script will work on any chart.  However, it was designed to work in conjunction
# with the Market Scholars Mkt Forecast Posture Script. It can be used to display
# and identify the following signals on the chart:
# a) Mkt Forecast Bullish and Bearish Clusters
# b) Mkt Forecast Intermediate Confirmation Signals
# c) Stochastic overbought and oversold signals - K=7,D=3 periods work really well.
# A bullish oversold up-arrow will appear when the "K" line crosses up through the
# "D" line and the "K" line is below the oversold level (25). A bearish overbought
# down-arrow will appear when the "K" line crossed down through the "D" line and
# the "K" line is above the overbought level.
# d) Mkt Forecast Posture in a chart label.
# e) 10 day EMA trend changes
# The script can also be used with alert signals to look for conditional setups. All
# indicators can easily be turned or off at will, as what may be appropriate for one symbol
# may not be suitable for others.

DefineGlobalColor("UpArrow", CreateColor(35, 255, 106));
DefineGlobalColor("DownArrow", CreateColor(255, 14, 20));
input ShowIntermediateConfirms = yes;
input ShowMfcClusters = yes;
input ShowStoArrows = yes;
input ShowIntermediateLabel = no;
input Show10DayMovingAvg = no;
def price = close;
def MA30 = SimpleMovingAvg(price = close, length = 30);
def EMA_10day = ExpAverage(close, length = 10);
def MFC = reference MarketForecast.intermediate;
def MFCRising = if MFC >= MFC[1] then 1 else 0;
def MFCPosture = if (MFC > 80) or (MFC > 20 and MFCRising) then 1 else 0;
def MFCURZ = if MFC > 80 then 1 else 0;
def mfcNearTerm = reference MarketForecast.nearterm;
def mfcMomentum = reference MarketForecast.momentum;
def BullishCluster = if MFC < 20 and mfcNearTerm < 20 and mfcMomentum < 20 then 1 else 0;
def BearishCluster = if MFC > 80 and mfcNearTerm > 80 and mfcMomentum > 80 then 1 else 0;
# Plot Clusters on the chart
plot bullDot = if BullishCluster and ShowMfcClusters then low * .996 else Double.NaN;
plot bearDot = if BearishCluster and ShowMfcClusters then high * 1.004 else Double.NaN;
# Bullish Intermediate Confirmation
def IntermediateConfirmation_Major = if MFCURZ
and mfcMomentum < 20 and mfcMomentum > 5
       and mfcNearTerm > 20 and mfcNearTerm < 50 then 1 else 0;
plot IC_major = if ShowIntermediateConfirms and IntermediateConfirmation_Major then MA30 * .99 else Double.NaN;
def IntermediateConfirmation_Minor = if MFCURZ
and mfcMomentum < 20 and mfcMomentum > 5
and !(mfcNearTerm > 20 and mfcNearTerm < 50) then 1 else 0;
plot IC_minor = if ShowIntermediateConfirms and IntermediateConfirmation_Minor then MA30 * .99 else Double.NaN;
AddLabel (ShowIntermediateLabel, "MFC " + Round(MFC) + " " + if MFCRising then "rising" else "falling", if MFCPosture then Color.GREEN else GlobalColor("DownArrow"));
# +++++++ Show Stochastic Reversals on Chart +++++++++++
def over_bought = 75;
def over_sold = 25;
def KPeriod = 7;
def DPeriod = 3;
def priceH = high;
def priceL = low;
def priceC = close;
def average = AverageType.SIMPLE;

def SlowK = reference StochasticSlow(over_bought,
                                      priceC, AverageType.SIMPLE).SlowK;
def SlowD = reference  StochasticSlow(over_bought, 
                                      priceC, AverageType.SIMPLE).SlowD;
plot stoUp = if (ShowStoArrows and
SlowK >= SlowD and
SlowK[1] < SlowD[1]) and
                 SlowK[1] < over_sold then low * .8 else Double.NaN;
plot stoDn = if (ShowStoArrows and
SlowK <= SlowD and
SlowK[1] > SlowD[1]) and
                 SlowK[1] > over_bought then high * 1.2 else Double.NaN;

# Plot 10-day EMA Trend Changes
def v_EMA10_up = if EMA_10day > EMA_10day[1] and EMA_10day[1] < EMA_10day[2] then 1 else 0;
def v_EMA10_down = if  EMA_10day < EMA_10day[1] and EMA_10day[1] > EMA_10day[2] then 1 else 0;

plot EMA10_up = if v_EMA10_up and Show10DayMovingAvg then EMA_10day else double.Nan;
plot EMA10_down = if v_EMA10_down and Show10DayMovingAvg then EMA_10day else double.Nan;

I would Like to see the above script draw a Vertical Line it already does this I would like it a little different, based off of the MF Blue Near and RED momo Lines breaking the 30 displaying a Green Vertical Line and or the Blue Near and Red momo breaking down through the 70 to produce a Red Vertical line. It would be Much better if it could display these or separate lines that could be turned on/off when Green Intermediate Line was either in a Positive trend (above 30 50 70 from a Below 20 condition) or a Negative trend (Below 70 50 30 off of a above 80 condition) alerts would also be Great.
Last edited by a moderator:


New member
@westgl Very interesting strategy. So the daily setup is to confirm an ideal trading day, while the SARs confirm exits and entries.
I have a couple questions.
So the daily setup is always when the green intermediate line is above the 70 and the red and blue come up to the 30s from a dip from the 20s?
Do you enter only long trades during this time or short ones as well?
Do you have a daily setup for long term short trend?
What do you mean when you said "GoldSAR .02 .20 is Broken"? If the price is already trending up a break of the SAR would indicate a bearish reversal right?
What is the reason for the 30-50-70 lines?

Thanks in advance.


New member
I use the Longer time frames to tell me where the Trend starts and finishes, or continues, Coming Out of a timing Low can usually have a Velocity up move, going into a Timing Low can have a Velocity move Down into the timing Low. The SAR Breaks tell me when a Support and resistance is broken, with the Candle immediately after a RedSar Break, is an Important Level, price needs to get past that level, Cycle timing tell me where the changes are, If there is No real pull down into a Low, and you get a Higher low then next high will be a Higher high, and that tells me where the Lows will be this tells me where the Velocity down into the next timing low will occur, and the New timing start will occur for up Velocity will start. I look for timing starts and finishes, Based on cycle timing, I use the SARs based on my SAR timing to tell me when a SAR (SAR + Support and Resistance) is Important to the next trend. So lest say we see a timing Low based on a cycle band occurs and price crosses to the cycle start, you have a Potential setup occurring, then I would look at the Market Forecast or MF to show me what to do next. Lets say you missed Most of the last trend up for what ever reason, When the Price Breaks the GoldSar, this is a Early Warning of either a Trend Change, or a Choppy condition is about to occur. When I Look for these moves on a Daily chart, I will take the trades on a 5 Minute chart, using same sequences. But I now have the trend timing and important support and resistance levels. I chart picture would be important for me to explain the Market Forecast 20-30-50-70-80 Lines


New member
Looking for a New Trend on Daily chart or Weekly Chart, to establish the Longer trend is Important, as this will tell you What side of the trades will have the Largest Moves, so if the trend is UP on the weekly and daily, then I want to only be looking for Up moves on the Shorter intraday charts, Unless you have a unlaying that is very good at provide two sided trading, into Cycle timing Lows on a Up trend. The Market Forecast, Lets say the MF Green Inter Line is was Below the 20 line and Now has Moved Above 50 line, this is a Bullish Trend, with the Green line High (>50) I would be Looking at the Blue Near Line and the Red Momentum or Momo Line to get back down to 20 as this is a Oversold condition with a Green line above 50 for Trend UP this would be a Good Entry Tell With Green line High, and Blue and Red Getting Oversold at 30 or 20 or lower, when the red and blue come back up to above 20 or 30 line that is the Entry. I tried to paste a chart picture for you that I marked up, But it wont let me paste it. It keeps saying stop correcting. Sorry


New member
I have a watch list that I have made for my style of trading, that shows the Daily Green in one column breaks 50 line and Blue Breaks in one Column the 50 line, and Intraday columns with a short side and a Long side, My watchlist tells when the setup is close to or has occured.


New member
I am looking to Automate this strategy a Little more. Right now I put a Alert at where the REDSAR Breaks, and Post Candle High/Low depending on trend direction gets taken out, and GoldSAR Breaks, so I know when the Longer term trend has either started or has Finished. As this tells me when I should be taking trades, or Not taking trades, when a Trend is established, or coming to an end, or when it is Choppy, and to stay out.


New member
When I say Velocity, Into and Out of a cycle. I am referring to How much Movement Velocity of move or speed of Move Down into a Cycle Timing Low. Or the Velocity speed Moving Up Out of a New Cycle Start. When I look at cycle timing, lets use a New Cycle start, for instance, if I get a Good Move up out of a New timing cycle, and it shows it has good velocity right from the start this tells me that I have a Good trend that is strong or good velocity. But If I take the same cycle Timing start, and it does Not move up Out of a Brand new cycle start with Any velocity, but in fact each consecutive candles is the same for a couple/ few candles this tells me we may be in a Choppy sideways condition. I would be looking for something that is performing better off of a New cycle. I watch Most all Futures on my watchlist. I am also watching all FAANNG stocks + MSFT Plus Gold stocks and Gold Miners, Silver Miners, Drillers, and all Currencies. I watch these daily, I do this for a Living everyday, as it is my job/career, I Must have an edge to be able to see what is Hot or near Hot, and What Is Not worth Looking at, as my time is very valuable and it must be used Very wisely.


I am looking to Automate this strategy a Little more. Right now I put a Alert at where the REDSAR Breaks, and Post Candle High/Low depending on trend direction gets taken out, and GoldSAR Breaks, so I know when the Longer term trend has either started or has Finished. As this tells me when I should be taking trades, or Not taking trades, when a Trend is established, or coming to an end, or when it is Choppy, and to stay out.

Could you provide or share a link? the script is only showing arrows and dots. Thank you.



Declare Lower;

input OverBought = 70;
input OverSold = 30;
input Middle = 50;

plot Momentum = marketForecast();
AddLabel(yes, "Momentum: " + AsText(Momentum, NumberFormat.TWO_DECIMAL_PLACES) + (if marketForecast() > marketForecast()[1] then "  rising" else if marketForecast() < marketForecast()[1] then "  falling" else ""), color.RED);

plot NearTerm = MarketForecast().NearTerm;
AddLabel(yes, "Near Term: " + AsText(NearTerm, NumberFormat.TWO_DECIMAL_PLACES) + (if marketForecast().NearTerm > marketForecast().NearTerm[1] then "  rising" else if marketForecast().NearTerm < marketForecast().NearTerm[1] then "  falling" else ""), color.BLUE);

plot IntTerm = MarketForecast().Intermediate;
IntTerm.setDefaultColor(createColor(51, 204, 0));
AddLabel(yes, "(IT)-Intermediate Term: " + AsText(IntTerm, NumberFormat.TWO_DECIMAL_PLACES) + (if marketForecast().Intermediate > marketForecast().Intermediate[1] then "  rising" else if marketForecast().Intermediate < marketForecast().Intermediate[1] then "  falling" else ""),(createColor(51,204,0)));

plot OB_line = OverBought;

plot OS_line = OverSold;

plot Middle_Line = Middle;

plot cluster2=if momentum>overbought && NearTerm>overbought then 100 else if momentum<oversold && NearTerm<oversold then 0 else double.nan;
cluster2.defineColor("bearish", color.yellow);
cluster2.assignValueColor(if !isnaN(cluster2) && cluster2==100 then cluster2.color("bearish")else cluster2.color("bullish"));
def formingBar2=!isnaN(close)&&isnan(close[-1]);
plot zed2=if barNumber()%10 == 0 && !formingBar2 then 0 else double.NaN;
plot uno2=if barNumber()%10 ==0 && !formingBar2 then 105 else double.nan;

AddCloud(0, OS_line, color.Yellow, Color.YELLOW);
AddCloud(100, OB_line, color.Green, color.Green);
AddCloud(30, Middle_line, color.Red, color.Red);


input OverBought1 = 80;
input OverSold1 = 20;
input Middle1 = 50;

plot OB_line1 = OverBought1;

plot OS_line1 = OverSold1;

plot Middle_Line1 = Middle1;

plot cluster=if momentum>overbought1 && NearTerm>overbought1 && intTerm> overbought1 then 100 else if momentum<oversold1 && NearTerm<oversold1 && intTerm<oversold1 then 0 else double.nan;
cluster.assignValueColor(if !isnaN(cluster) && cluster==100 then cluster.color("bearish")else cluster.color("bullish"));
def formingBar=!isnaN(close)&&isnan(close[-1]);
plot zed=if barNumber()%10 == 0 && !formingBar then 0 else double.NaN;
plot uno=if barNumber()%10 ==0 && !formingBar then 105 else double.nan;

def BullCluster = momentum <=20 and intTerm <=20 and Nearterm <=20;
def BearCluster = momentum >=80 and intTerm >=80 and Nearterm >=80;

#addlabel(yes, "IT*Above 80 - Intrmdt Trade",color.DARK_Green);
#addlabel(yes, "IT*Below 80 - Defensive",color.YELLOW);
#addlabel(yes, "IT*Below 50 - BEARISH",color.DARK_RED);
#addlabel(yes, "IT*Below 20 Then Crosses above 20 - Bullish",Color.UPTICK);

Similar threads