© Andrew Coles       Terms & Conditions | Privacy

MIDAS MARKET ANALYSIS
Modified VWAP Methodologies
Share on Facebook
Share on Twitter
Share via e-mail
Share on Delicious
Share on Digg
Share on Google Bookmarks
Share on LiveJournal
Share on Newsvine
Share on Reddit
Share on Stumble Upon

MIDAS indicator code

Note to book purchasers


At the time of the book’s publication, the publisher and I agreed that additional Metastock code would be made available for two other indicators discussed in the book, namely my MIDAS Displacement Channel (Chapter 14) and the MIDAS version of the Standard Deviation Bands (Chapter 15).


I also agreed to provide the code for one example of a fourth generation curve (see Essay Two) which was discussed in Chapter 16, namely the On Balance Volume Curve. Other fourth generation curves applied to economic indicators (the Baltic Dry Index), volatility (the VIX), and momentum (Relative Strength Index and the MACD) was published a month after the book in Active Trader magazine (issues June and July 2011). To apply the curves to datasets other than OBV, simply replace the bolded OBV code below with the code of whatever independent dataset is of interest. For example, the MACD is MACD(). Again second generation curves can also be created of fourth generation curves (see the table at the end of Essay Two here).


On the site news page here, I mentioned that the previous website had probably been first compromised at the time of the book’s publication, resulting amongst other issues in large numbers of emails never reaching us. Consequently there were probably a number of book purchasers trying to forward their book receipts while requesting the additional code. If you are one of those people who never received a response I apologise.


Below you will find the additional MIDAS code that was offered at the time.


Terms & Conditions


In several places on this website, including the full Terms & Conditions at the bottom of each page, I have stressed that David Hawkins and I have no interest in coding other indicators and that emails dealing with this subject to either of us will be deleted. Here is the relevant text from the full Terms & Conditions:


The sole purpose of this website is to discuss MIDAS approaches to the financial markets, including MIDAS techniques and indicators discussed in the book. Andrew Coles and David Hawkins are not computer programmers and they will not code indicators belonging to other traders or other technical analysis systems. They have no interest in other indicators or other technical systems beyond MIDAS. You are visiting this site on condition that you understand this commitment and that you do not contact Andrew Coles or David Hawkins requesting indicator code. Emails received by either of us that ignore these Terms & Conditions will be ignored in turn and deleted. We will not enter into any correspondence with parties visiting this site who do not take this warning seriously.


Code available in the book


Appendix C contained Bob English’s TradeStation code for the Topfinder/Bottomfinder because it’s a well-known fact that the indicator cannot be coded in Metastock. In Appendix B I supplied the code for first generation (see Essay Two) MIDAS S/R curves for higher trameframe and intraday charts. In the same Appendix, I also explained how to transform first generation curves into second generation curves (see Essay Two) by replacing market volume with “nominal” or “constant” volume. The code in this Appendix also allowed users to adjust the curves to fit the Open, High, Low and Close, as well as the Average Price. I will not duplicate Appendix B here because I assume that most people reading this will have access to the book.


____________________________________________________________________________________________________________________________________





{Coles' MIDAS Displacement Channel. A nominal version of this indicator can also be created by following the information above: replace V with 1. For daily and higher timeframes. Metastock code for the MIDAS standard S/R curves. Copyright Dr Andrew Coles}


{Note: it is possible to add another two channels to this indicator either side of the MIDAS curve, but the code must be changed and it's beyond this scope of this work. Don’t remove curly brackets.}


{user defined input}

sm:=Input("startng month", 1,12,1);

sd:= Input("starting day of month", 1,31,1);

sy:=Input("starting year", 1980,2100,2011);

start:=sd=DayOfMonth() AND sm=Month() AND sy=Year();

{mid price}

pv:=MP()*V;


{Midas calculation}

denom:=If(Cum(V)-ValueWhen(1,start,Cum(V))=0,1, Cum(V)-ValueWhen(1,start,Cum(V)));

If(BarsSince(start), (Cum(pv)-ValueWhen(1,start,Cum(pv)))/denom,MP());

{Adding percent displacement bands}

M:=If(BarsSince(start), (Cum(pv)-ValueWhen(1,start,Cum(pv)))/denom,MP());


Q1:=Input("percentage-upper",1,50,1);

M * (1+(Q1/100));

Q2:=Input("percentage-lower",1,50,1);

M * (1-(Q2/100))


Back to top





Metastock code for Coles’ MIDAS Displacement Channel - intraday

{For intraday. Metastock code for the MIDAS standard S/R curves. Copyright Dr Andrew Coles}


{Note: it is possible to add another two channels to this indicator either side of the MIDAS curve, but the code must be changed and it's beyond this scope of this work}


{user defined input}

sm:=Input("startng month", 1,12,1);

sd:= Input("starting day of month", 1,31,1);

sh:=Input("hour",1,24,1);

se:=Input("minute",0,60,0);

start:=sd=DayOfMonth() AND sm=Month() AND 2011 AND sh=Hour() AND se=Minute();

{mid price}

pv:=MP()*V;

{Midas calculation}

denom:=If(Cum(V)-ValueWhen(1,start,Cum(V))=0,1,Cum(V)-ValueWhen(1,start,Cum(V)));

If(BarsSince(start),(Cum(pv)-ValueWhen(1,start,Cum(pv)))/denom,MP());

{Adding percent displacement bands}

M:=If(BarsSince(start),(Cum(pv)-ValueWhen(1,start,Cum(pv)))/denom,MP());


Q1:=Input("percentage-upper",0.0100,4,0.0100);

M * (1+(Q1/100));

Q2:=Input("percentage-lower",0.0100,4,0.0100);

M * (1-(Q2/100))


Back to top


Metastock code for MIDAS Standard Deviation Bands - daily and higher timeframe charts

MIDAS Standard deviation bands. Coles' code: this is the first time this indicator has been coded in Metastock. Again nominal versions can also be created.

For daily and higher timeframe charts:}


{Metastock code for the MIDAS standard S/R curves. Copyright Dr Andrew Coles}


{Note: the increments below can be altered to create wider/narrower standard deviation settings}


sm:=Input("starting month",1,12,1);

sd:=Input("starting day of month",1,31,1);

sy:=Input("starting year",1980,2100,2011);

start:= sd=DayOfMonth() AND sm=Month() AND sy=Year();

pv:=MP()*V;

denom:= If(Cum(V)-ValueWhen(1,start,Cum(V))=0,1,Cum(V)-ValueWhen(1,start,Cum(V)));

Midas:=If(BarsSince(start),(Cum(pv)-ValueWhen(1,start,Cum(pv)))/ denom,MP());

Midas;

Basis:=Stdev(C-Midas,2);

CB:=Cum(Basis);

Midas+CB*4;

Midas+CB*3;

Midas+CB*2.2;

Midas+CB*1.8;

Midas+CB*1.2;


Midas-CB*1.2;

Midas-CB*1.8;

Midas-CB*2.2;

Midas-CB*3;

Midas-CB*4;


Back to top


Metastock code for MIDAS Standard Deviation Bands - intraday

{For intraday charts:}


{Metastock code for the MIDAS standard S/R curves

}


{Note: the increments below can be altered at any time to create wider/narrower standard deviation settings. Copyright Dr Andrew Coles}


sm:=Input("starting month",1,12,1);

sd:=Input("starting day of month",1,31,1);

sy:=Input("starting year",1980,2100,2011);

sh:=Input("hour", 1,24,1);

se:=Input("minute",0,60,0);

start:= sd=DayOfMonth() AND sm=Month() AND sy=Year() AND sh=Hour() AND se=Minute();

pv:=MP()*V;

denom:= If(Cum(V)-ValueWhen(1,start,Cum(V))=0,1,Cum(V)-ValueWhen(1,start,Cum(V)));

Midas:=If(BarsSince(start),(Cum(pv)-ValueWhen(1,start,Cum(pv)))/ denom,MP());

Midas;

Basis:=Stdev(C-Midas,2);

CB:=Cum(Basis);

Midas+CB*1.2;

Midas+CB*0.8;

Midas+CB*0.5;

Midas+CB*0.2;

Midas-CB*0.5;

Midas-CB*0.2;

Midas-CB*0.8;

Midas-CB*1.2


Back to top


Metastock code for MIDAS On Balance Curves - daily and higher timeframe charts

{MIDAS On-Balance Curves


I call these MIDAS OBV curves, though in effect the curves can be applied to any dataset that has fractal trend characteristics. For example, see my Active Trader articles (June and July 2011) where I apply them to the VIX, Baltic Dry Index, Relative Strength lines, and momentum indicators such as the MACD.

To apply the curves to datasets other than OBV, simply replace the bolded OBV code below with the code of whatever independent dataset interests your. For example, the MACD is MACD(). Again, nominal versions of these curves can also be created. For daily charts:}


{Metastock code for the MIDAS standard S/R curves. Copyright Dr Andrew Coles

}


sm:=Input("starting month",1,12,1);

sd:=Input("starting day of month",1,31,1);

sy:=Input("starting year",1925,2100,2011);

start:= sd=DayOfMonth() AND sm=Month() AND sy=Year();


pv:=OBV()*V; {For other datasets, replace OBV() with the code for other indicators or datastets - a nominal version can be created by replacing V with 1, as above}


denom:= If(Cum(V)-ValueWhen(1,start,Cum(V))=0,1,Cum(V)-ValueWhen(1,start,Cum(V))); {For other datasets, replace OBV() with the code for other indicators or datastets - a nominal version can be created by replacing V with 1, as above}


If(BarsSince(start),(Cum(pv)-ValueWhen(1,start,Cum(pv)))/ denom,OBV())


Back to top


Metastock code for MIDAS On Balance Curves - intraday

{For intraday charts:}


{Metastock code for the MIDAS standard S/R curves. Copyright Dr Andrew Coles

}


sm:=Input("starting month",1,12,1);

sd:=Input("starting day of month",1,31,1);

sy:=Input("starting year",1925,2100,2011);

sh:=Input("hour", 1,24,1);

se:=Input("minute",0,60,0);

start:= sd=DayOfMonth() AND sm=Month() AND sy=Year() AND sh=Hour() AND se=Minute();


pv:=OBV()*V; {For other datasets, see above}


denom:= If(Cum(V)-ValueWhen(1,start,Cum(V))=0,1,Cum(V)-ValueWhen(1,start,Cum(V))); {For other datasets, see above}


If(BarsSince(start),(Cum(pv)-ValueWhen(1,start,Cum(pv)))/ denom,OBV())


Back to top


Metastock code for Coles’ MIDAS Displacement Channel - daily and higher timeframe charts