Experiments in Technical Analysis

small news for share markets

rakesh.j. is active in ifci
funds r active in mirc
punters r active in teledata / shiva cement / mngf / garnet const
B F Utilities has the largest Land Bank 20 000 acres amoung all
bldrs of ndia
 
Thank you Asish for your information on hindsight indicators. Do you have any clue as to what indicator could be used instead of hindsight indicators such as Zig Zag/Peak in order to establish the trend? I've found that the system (K1) will work well in trending periods, but not in ranging periods.

Karthik, I'd love to hear your thoughts on this.

Regards,
Jrgen T.
 
U

uasish

Guest
Jorgen T,
Exact replica of Peak function is not available in public domain,however many use HHV function instead.

Asish
 
CONTINUING WITH MACD


Code:
("Moving Average Cross-over Trading System");

MACDswitch = ParamToggle("Use MACD?", "No | Yes", 0); 
ShortEMA   = EMA(C, 5);
LongEMA    = EMA(O, 6);

 M = MACD();
 S = Signal();

 Buy  = Cross(ShortEMA, LongEMA);
 Sell = Cross(LongEMA, ShortEMA);

if (MACDswitch)
	{
		Buy  = Cross(ShortEMA, LongEMA) AND M > S;
		Sell = Cross(LongEMA, ShortEMA) AND M < S;
	}

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

Marker = Buy * shapeUpArrow + Sell * shapeDownArrow;
MarkerColor = IIf(Buy, colorBrightGreen, colorRed);
MarkerDist = IIf(Buy, L, H);
//You can uncomment next two lines if you want to plot the EMAs also

//Plot(ShortEMA, "EMA5 Close", colorGreen);
//Plot(LongEMA, "EMA6 Open", colorRed);

PlotShapes(Marker, MarkerColor, 0, MarkerDist);
Dear Mr.Anant
It seems working nice. I would like to back test it using amibroker but when i scanned, it shows all trades of EMA cross. If i try for back test with shorts and longs it gives error message "Missing short/cover variable assingnment".

I would like to test only for the trades of EMA cross overs, with MACD as u have given in AFL.

I am new to backtesting can u guide me with settings to be made in backtester. I am testing with Nifty charts.

Can u add the display of rates in the chart whenever buy / sell arrow is triggered.

Raj
 

asnavale

Well-Known Member
Dear Mr.Anant
It seems working nice. I would like to back test it using amibroker but when i scanned, it shows all trades of EMA cross. If i try for back test with shorts and longs it gives error message "Missing short/cover variable assingnment".

I would like to test only for the trades of EMA cross overs, with MACD as u have given in AFL.

I am new to backtesting can u guide me with settings to be made in backtester. I am testing with Nifty charts.

Can u add the display of rates in the chart whenever buy / sell arrow is triggered.

Raj
Hi Raj,

The AFL I had attached was for using as an indicator. For Exploring and backtesting you have to change it slightly. I don't know whether you have made the necessary changes. I am attaching the AFL required for Exploring/backtesting with this message. Try this AFL and give your feedback. This AFL has only Buy and Sell codes. There are no separate Short/Cover codes. Short is same as Sell and Cover is same as Buy.

Note that the attached file has .txt extension which should be changed to .afl before using in AmiBroker.

To use the AFL to include MACD also, set the MACD selection switch appropriately in Exploration window parameters before running Exploration/Back testing.

It is possible to add The price to the charts but it works only in AmiBroker version 4.8 and higher. Therefore I did not add the code so that users with lower versions can also use it. I can give you the additional code also but please let me know which price you want to display? Is it Open or Close or any other?
Regards

-Anant
 
Last edited:

Similar threads