Mobius (Demarks Pivot and Demarks MA) for ThinkorSwim

mc01439

Well-known member
2019 Donor
VIP
Mobius posted these on "thinkScript Lounge" this morning.

10:17 Mobius: Here are two studies by DeMark I find still useful.
This one I find useful as boundaries for intraday likely moves:

https://tos.mx/pGukThm
https://tos.mx/vBx2ibC
Code:
#Start Code
# Demark's Pivots
# Ported to TOS by Mobius
#

declare hide_on_daily;

def o = open(period = AggregationPeriod.Day)[1];

def h = high(period = AggregationPeriod.Day)[1];

def l = low(period = AggregationPeriod.Day)[1];

def c = close(period = AggregationPeriod.Day)[1];

def x = if c < o

        then h + (2 * l) + c

        else if c > o

             then (2 * h) + l + c

             else if c == o

                  then h + l + (2 * c)

                  else x[1];

plot Pivot_Point = X/4;

     Pivot_Point.SetPaintingStrategy(PaintingStrategy.Horizontal);

plot Support = X/2 - h;

     Support.SetPaintingStrategy(PaintingStrategy.Horizontal);

plot Resistance = X/2 - l;

     Resistance.SetPaintingStrategy(PaintingStrategy.Horizontal);

# End Code

This is still a very good Moving Average

Code:
#Start Code

# Demarks MA

# Mobius

# V01.2.2011

# What makes this MA unique is that it can be run at very low period lengths and still be a smooth indicator. Which makes it very responsive.

script Range{

    input d = close;

    input Min = 0;

    input Max = 10000;

    def hh = HighestAll(d);

    def ll = LowestAll(d);

    plot nr = (((Max - Min) * (d - ll)) /

                (hh - ll)) + Min;

}



input n = 5;

input V = 0.682;





   def newMax = Highest(high, n);

   def newMin = Lowest(low, n);



script BP {

   def bp = (((close - open) / (high - low)) * volume);

  plot data = bp;

}



   def newBP = Range(BP().data, newMin, newMax);

   def StDev = StDev(newBP, n);

   def GDEMA = (ExpAverage(newBP, n)* (1 + V)) -

               (ExpAverage((ExpAverage(newBP, n)), n)* V);



  plot PlotData = if IsNaN(newBP)

                  then Inertia(GDEMA[1], n)

                  else Inertia(GDEMA, n);

       PlotData.SetStyle(Curve.Firm);

       PlotData.SetLineWeight(1);

       plotData.AssignValueColor(if PlotData > PlotData[2]

                                 then Color.Green

                                 else Color.Red);

# End Code

10:18 Mobius: There 2 different studies in the post above.
 
Last edited by a moderator:

markos

Well-known member
VIP
@mc01439 Thanks for grabbing these gems. Mobius said he was on 2 minute charts for /ES.
What are the Ticks you used today for the pic above?
 

korygill

Active member
VIP
Interesting indicators, thx for sharing @mc01439. Looks like you have created some cool studies and ways to track signals with those labels too. Are any of those already on this site?
 
I am checking the script of Demark MA and it works very well. One thinbg I noticed that in Mobious's script, he used volume where as in Jason Perl's book on Demark indicator, TD MA doe snot use volume in calculation.

Here is Amibroker code:
Code:
_SECTION_BEGIN("TD MA I");
/******************************************************************
 * TD Moving Average I:
 * Enter long: if "matrend" > 0
 * Enter short: if "matrend" < 0
 *
 * Notes: Moving average turns green whenever an uptrend trend starts.
 * It turns red whenever a down trend starts.
 *
 * Improvements: Stops are not set up to indicate that an exit was hit.
 *
 *******************************************************************/
TDBullishColor = ParamColor("Bullish Color:", colorGreen);
TDBearishColor = ParamColor("Bearish Color:", colorRed);
TDPlotStyle = ParamStyle("Plot Style", styleLine);
barlows12 = REF(HHV(L, 12),  - 1);
barhighs12 = REF(LLV(H, 12),  - 1);
mabearish5 = MA(h, 5);
mabullish5 = MA(l, 5);
mabullish = L > barlows12;
mabearish = H < barhighs12;
maplotvalue[0] = 0;
matrend[0] = 0; //no trend
nDaysCountDown = 0;
bTrend = 0;
fLastValue = 0;
 
for (x = 0; x < BarCount; x++)
{
  if (mabullish[x] == 1)
  {
    fLastValue = maplotvalue[x] = mabullish5[x];
    nDaysCountDown = 3;
    bTrend = 1;
    matrend[x] = 1;
  }
  else if (mabearish[x] == 1)
  {
    fLastValue = maplotvalue[x] = mabearish5[x];
    nDaysCountDown = 3;
    bTrend = 0-1;
    matrend[x] = 0-1;
  }
  else
  {
    nDaysCountDown = nDaysCountDown - 1;
    if (nDaysCountDown > 0-1)
    {
      matrend[x] = bTrend; //trend extends to the 3 extra bars
      if (bTrend == 1)
      {
        fLastValue = maplotvalue[x] = mabullish5[x];
      }
      else if (bTrend < 0)
      {
        fLastValue = maplotvalue[x] = mabearish5[x];
      }
    }
    else
    {
      maplotvalue[x] = fLastValue;
      matrend[x] = 0; //no trend
    }
  }
}
 
PLOT(maplotvalue, "TDMA I", IIF(mabullish > 0, TDBullishColor, IIF(mabearish > 0, TDBearishColor, colorYellow)), TDPlotStyle | styleNoRescale, null, null, 0);
 
_SECTION_END();
 
Last edited:

Similar threads

Top