three EMAs in trading system

#1
Hello!

I have tested several trading systems found in the web and those were not so good. So I decided to create my own system in AmiBroker.

I found such a description: "We can use combination of moving averages: 4-, 9- and 18-days. If 9-days average is above 18-days but 4-days came below 9-days, we can state that there is no trend on the market. We can say the same if 9-days will be below 18-days and 4-days will cross 9-days from the bottom. We have got increasing trend if 4-days would be above 9-days, and this one above 18-days. The opposite moving averages indicate decreasing trend".

However this description is somehow unclear for me because it says which moving average is above which but not which one crosses which (with one exception). Because of this I made little research in the internet and the only one useful what I found was this http://theforexarticles.com/2008/08/27/heres-a-solid-ema-trading-strategy/ , which unfortunately says only little about this topic. I created this http://images45.fotosik.pl/312/5b27004f8de01c07.jpg . There are eight little pictures, first four are for the above description, next four for the website. First two are about situation when there is no trend, third for increasing, fourth for decreasing, fifth and sixth for opening long position, last two for closing long position. I also created the code shown below but I'm not satisfied with this code. I also wonder if I should move to the bottom, leave or delete the part about clearing (making 'zero'). I used in code below 'no trend' part from the description above and buy/sell from the website.

Code:
//I make buy and sell zero if there is no trend

buy = IIf(
  (((ema(C,9) > ema(C,4)) AND (ema(C,4) > ema(C,18))) OR ((ema(C,18) > ema(C,4)) AND (cross(ema(C,4),ema(C,9)))))
,0,buy)

sell = IIf(
  (((ema(C,9) > ema(C,4)) AND (ema(C,4) > ema(C,18))) OR ((ema(C,18) > ema(C,4)) AND (cross(ema(C,4),ema(C,9)))))
,0,sell)

//I buy for increasing trend

buy = IIf(
  cross(ema(9),ema(18))
  //AND (ema(4) > ema(9)) AND (ema(4) > ema(18))
,1,0)

//I sell for decreasing trend

sell = IIf(
  cross(ema(9),ema(4))
  //AND (ema(18) > ema(4)) AND (ema(18) > ema(9))
,1,0)
I also thought about adding the other condition, i.e. to wait for increasing the price above price maximum of the day, in which there is crossing of moving averages. It should be at the end of the code and additional condition.

Code:
was_there_highest_price = IIf(C > Ref(H,-1),1,0)

buy = IIf(was_there_highest_price, buy, 0)
However this additional condition won't work because it should work one day later. For example:
Wednesday - crossing of averages shows to buy
Thursday - price above yesterday's high so both conditions are fulfilled and I buy

Regards!
 

Similar threads