indiTraders - Forum for the Active Indian Trader  

Go Back   indiTraders - Forum for the Active Indian Trader > Tools > Software > Amibroker

Composite Edge
Reply
 
Bookmark and Share LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-08-2009, 04:42 AM
sanjay_arora sanjay_arora is offline
Addicted
 
Join Date: Apr 2009
Location: Amritsar
Posts: 174
Thanks: 244
Thanked 149 Times in 71 Posts
sanjay_arora will become famous soon enoughsanjay_arora will become famous soon enoughsanjay_arora will become famous soon enough
Question (Req) 3-15 EMA Swing System AFL Coding

Hello All

I am a new Amibroker user and am trying to learn trading strategy & Amibroker Coding (suck at coding till date). I wanted to try my paces with building an easy strategy (EMA), that is SWING trading so not too fast a time frame, and can be the basis of improvement as I learn and is profitable enuff to be traded to build confidence & really know it, by its kicks...though I intend to trade it very small.

I found the strategy at a board, not naming it as many ppl seem to frown at linking to other forums etc., but since the strategy is posted & therefore public, I am posting the rules here.

I checked this on as many charts as I could and I find that this should be acceptable profitable for someone who trades it small & knows enough to trade in markets that are reasonably trending and not too range bound. It seems to kick your butt in tightly range bound markets.

Hope someone experienced at this board will post the AFL to this, so that I can backtest it really well, rather than just check some charts of trending or range bound periods. And of course, if the back-testing goes well, I will be trading it with real money and post the trades, in this thread.

In simple terms, if our immediate average price is higher than the medium term average price that means we are entering in a bull swing ... and visa versa. Hence the strategy entries are:

1 Enter Long when 3 EMA goes above 15 EMA
2 Enter Short when 3 EMA goes below 15 EMA

Some People use 3/12, some use 5/15 combos on their favourite scrips and all seem ok in trending markets.

Entries

Entries are simple, you wait for a candle to close above 15 EMA, next candle to open and see if 3 EMA is above 15 EMA or not. If the answer is 'Yes' you go long. For shorts you need an exact opposite setup.

Position Sizing

Since in this system SL cannot be defined as a 'level' your initial position sizing has to be small. Depending on the trading capital, you dont want to put more than 25% capital which you want to put in this trade in as the first trade i.e assume if you can trade a total of 4 lots max, you will start with 1 lot. Rest 3 lots we will add later as our position moves into profit.

In the AFL, Set a Variable for Trading Capital for Scrip and a variable for Initial Position Sizing Percentage (By Default Set it to 25% and it can be changed) and do not enter a trade if the trade amount is higher than the position size. And, do highlight it on the chart with, with a Red Remark and a loud audible Alarm to tell you that you are on a losing spree.

Pyramiding

Pyramiding or 'adds' are obviosly done once our position has 'swung' into profits. The rule is we add when the markets correct after a swing, price comes and touched 15 EMA again (but 3 EMA hasnt crossed over). This means that we add very close to our SAR hence keeps the risk small and also ensures that even if SAR is triggered we still end up in net profits (since our initial position is in profits hopefully now).

Add only if below 2 conditions are fulfilled:

1. 3 EMA is still below 15 EMA for shorts and visa versa AND
2. The current candle breaches previous day's lows for shorts (previous days highs for longs)

This means that I add longs when i see fresh buying has started after the correction. This is slightly high probability add though it means I dont add exactly at 15 EMA but slightly away from it.

Also, move the Trailing Stop to couple of points below where you add to the position and upon the price moving upwards from the price where you add to the position, move the trailing stop of the combined position to the candle's low.

Exits

Yes, we do exit at certain points even when our SAR is not hit. These exit points are obviously when our position is suddenly in deep profits becuase of an extreme rally or crash in our favour. The exit points are where you find our 'current' EOD candle is not touching 3 EMA at all. On this candle, we book profits and wait for markets to correct back and touch 3 EMA again. As soon as 3 EMA is touched we jump back into our initial position. So in a way we stay with our position, we just exit it once and get back in after a small correction.

Stop Loss

Use entry point as SL. Trail it up, if you can for the cost of two way brokerage & taxes, as soon as market moves a bit in your way. This way, you may get out of the trade early, but you will have minimized your trading cost losses, in whipsaws, that you do encounter. Though you will get lesser profit as a result of trailing stop loss, as you could lose the earliest trends.

If our initial entry point (or SL) is hit, we enter again based on 'effective ADD' rules i.e previous day highs/lows breached and 3 EMA still in favour. This might mean we end up shorting below our earlier entry point but thats fine.

Someone (senior & experienced in the forum) please build AFL for the above strategy, Set Scrip & number to be traded, with Green bars for highs & Red bars for lows, A blue Arrow with price & Number of Securities traded & long or short and an audible alarm at the time of trade. Also, the EMA's plotted on the chart with yellow line for near EMA and blue line for far EMA. If possible, please do connect all trades (both entries and exits) on the chart with straight dotted orange lines.

Please do oblige and I look forward to using it, posting back-tests, paper-trades and real trades and maybe together, we can enhance & use the strategy.

With best regards to all and thanks to the guy who does oblige, in advance. If this does go well, I'll try to keep up with researching strategies on the net, testing them on charts and making similar requests with commitment to post back tests & trades.

Sanjay.

Last edited by sanjay_arora; 02-08-2009 at 06:26 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 6 Users Say Thank You to sanjay_arora For This Useful Post:
  #2 (permalink)  
Old 01-08-2009, 05:16 PM
vinodkiyer vinodkiyer is offline
Regular
 
Join Date: Aug 2009
Posts: 22
Thanks: 4
Thanked 69 Times in 17 Posts
vinodkiyer will become famous soon enoughvinodkiyer will become famous soon enough
Default

Hello Sanjay,

I am a new member in this forum, joined today. I read your post and decided to try an afl as per yr guidlines which is as below. I also added Support/resistance and SAR. This will give you buy-sell and short-cover indication. after seeing its chart on previous days, i feel it exits too early unless even the high and losw of candles are also taken into consideration. at present the afl is made as per your guidlines kindly try it out and post here so that we can make modifications.

Attached is as per your guidlines.

now, down below, is an afl which combines the swing system and heikin ashi pivots with which i have been trading quite successfully intraday. I use the 5 min time frame charts for this afl and once u apply this indicator, you must
adjust the parameters. the parameters i use while trading intraday is as follows:
nick ma swing + heikin K = 0.75, atr 4, ma 8, mid ma =34, long ma=200

now u can try out various settings for the above and give feedback.
in the above afl i do not jump into a position unless both the systems give me the same entry signal, also again before entering I check out the 5 mins, 15 mins and 30 mins stochastic before deciding to enter. I also check the sar crossovers especially for exits instead of the pivot system giving the signal and i maintain the sar stops. therefore the below afl must be used in conjuction with the stochastics 5, 15 and 30 mins the afl for which is also given below. both the afls are used in the same chart pane for easy tracking: here follows:
Attached Files
File Type: txt EMA 3,15.txt (3.7 KB, 795 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 7 Users Say Thank You to vinodkiyer For This Useful Post:
  #3 (permalink)  
Old 01-08-2009, 05:22 PM
vinodkiyer vinodkiyer is offline
Regular
 
Join Date: Aug 2009
Posts: 22
Thanks: 4
Thanked 69 Times in 17 Posts
vinodkiyer will become famous soon enoughvinodkiyer will become famous soon enough
Default

[Moderated Message: Please attach the afl with a text file instead of posting the code in the forum. Thank you]
Attached Files
File Type: rar NICK MA Swing + heikin pivots.rar (1.4 KB, 920 views)
File Type: rar Attachment 3.rar (3.0 KB, 788 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 4 Users Say Thank You to vinodkiyer For This Useful Post:
  #4 (permalink)  
Old 01-08-2009, 05:30 PM
vinodkiyer vinodkiyer is offline
Regular
 
Join Date: Aug 2009
Posts: 22
Thanks: 4
Thanked 69 Times in 17 Posts
vinodkiyer will become famous soon enoughvinodkiyer will become famous soon enough
Default

Although the above are in 2 posts they must go into one formula editor sheet. and the following afl for stochs is to be copied into another afl sheet but inserted into the same chart pane so that u can track both without switching panes.

Now all the attached afl formulas have been sourced in bits from various publically available sources and have been modified and patched in order to get the result by me.

all members of this forum kindly try it out intraday 5 min chart and we can all collectively work to improve the afl. awaiting your posts in this regard

kind regards
vinod
Attached Files
File Type: rar Attachment 4.rar (622 Bytes, 786 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 9 Users Say Thank You to vinodkiyer For This Useful Post:
  #5 (permalink)  
Old 01-08-2009, 06:38 PM
vinodkiyer vinodkiyer is offline
Regular
 
Join Date: Aug 2009
Posts: 22
Thanks: 4
Thanked 69 Times in 17 Posts
vinodkiyer will become famous soon enoughvinodkiyer will become famous soon enough
Default

dear all,

here is the screen shot of hero honda using the above afl on amibroker. pls find attached
Attached Images
File Type: png screen shot.png (29.1 KB, 1056 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 5 Users Say Thank You to vinodkiyer For This Useful Post:
  #6 (permalink)  
Old 01-08-2009, 07:30 PM
vikkas's Avatar
vikkas vikkas is offline
Regulars
 
Join Date: Mar 2009
Posts: 662
Thanks: 1,794
Thanked 1,306 Times in 534 Posts
vikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to behold
Default

how u use this stch part...
__________________
First they ignore you, then they ridicule you, then they fight you, then you win -
Mahatma Gandhi
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-08-2009, 07:53 PM
vinodkiyer vinodkiyer is offline
Regular
 
Join Date: Aug 2009
Posts: 22
Thanks: 4
Thanked 69 Times in 17 Posts
vinodkiyer will become famous soon enoughvinodkiyer will become famous soon enough
Default

there are three tf stochs in one chart pane ie 5 15 and 30 mins the 5 mins stoch
is the red and green line (green over red bullish), while 15 min stoch is light blue cloud (bullish and orange (bearish). and 30 mins blue (bullish) and red bearish. when i am in profit, I observe theses to see which all r in the oversold/overbought region or approaching thereabouts and decide whether to wait or close position. on of the things to remember is that stochs can go only from zero to 100 but prices can go without top or bottom. another thing is that if the longer tf stochs stay above 20/80 for more than 15 to 30 minutes, then the chances of breakouts are possible. the advantage of these stochs are that u can plot a 30 min or 15 min stoch on a 5 minute chart without changing the entire tf for the whole chart.

anyways thats the way i understand and trade it. kindly give your opinion. i have been trading this strategy for last one month with success.

regards
vinod
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to vinodkiyer For This Useful Post:
  #8 (permalink)  
Old 01-08-2009, 08:06 PM
vinodkiyer vinodkiyer is offline
Regular
 
Join Date: Aug 2009
Posts: 22
Thanks: 4
Thanked 69 Times in 17 Posts
vinodkiyer will become famous soon enoughvinodkiyer will become famous soon enough
Default

dear all the heikin period settings i use is ma period 4, lookback 90 and number of bars 11, sar acceleration 0.02 and max.acc. 0.2. i missed that out in the parameters
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to vinodkiyer For This Useful Post:
  #9 (permalink)  
Old 01-08-2009, 09:30 PM
vikkas's Avatar
vikkas vikkas is offline
Regulars
 
Join Date: Mar 2009
Posts: 662
Thanks: 1,794
Thanked 1,306 Times in 534 Posts
vikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to beholdvikkas is a splendid one to behold
Default

Originally Posted by vinodkiyer View Post
there are three tf stochs in one chart pane ie 5 15 and 30 mins the 5 mins stoch
is the red and green line (green over red bullish), while 15 min stoch is light blue cloud (bullish and orange (bearish). and 30 mins blue (bullish) and red bearish. when i am in profit, I observe theses to see which all r in the oversold/overbought region or approaching thereabouts and decide whether to wait or close position. on of the things to remember is that stochs can go only from zero to 100 but prices can go without top or bottom. another thing is that if the longer tf stochs stay above 20/80 for more than 15 to 30 minutes, then the chances of breakouts are possible. the advantage of these stochs are that u can plot a 30 min or 15 min stoch on a 5 minute chart without changing the entire tf for the whole chart.

anyways thats the way i understand and trade it. kindly give your opinion. i have been trading this strategy for last one month with success.

regards
vinod

If I am not wrong then this is Pride's method on Traderji..anyways nice to have u on IT...Welcome Vinod

for stochs.. i can only say tht... it looks complicated and so its way of use..its just wht my obervation.....don't take it personlly..

Warm regards,

Vikkas
__________________
First they ignore you, then they ridicule you, then they fight you, then you win -
Mahatma Gandhi
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to vikkas For This Useful Post:
  #10 (permalink)  
Old 02-08-2009, 07:57 AM
vinodkiyer vinodkiyer is offline
Regular
 
Join Date: Aug 2009
Posts: 22
Thanks: 4
Thanked 69 Times in 17 Posts
vinodkiyer will become famous soon enoughvinodkiyer will become famous soon enough
Default

hi vikkas,

as a clarification, i am repeating the post here, which i did on another forum. I had actually traded pride for two days and found that the pride system was taking exits early and entries late. I had made a modification on the compiled afl below in order to correct the problem with pride after the posting, but i didnt publish it as I still felt it was lacking.
The above afl which i had been using for last one month is again a combination of afls available freeely in various bits and pieces, but I had made modifications in such a way that it tries to serve the purpose of making profits. the above system has no similarity in the method of entries and exits whatsoever with pride system where the thing is based on ema only. if u observe the formula above it is based on heikin pivots and nma swing and not ema. and I had plotted the ema on the chart only for additional info while trading. As I said the method I employ for trading is my own way which also has been explained above. Like if the system gives me entry arrow when the stochs are in overbought/oversold region, then I dont enter. I just explained all this so that we can collectively work towards a trading system which is dependable. here follows repetation of my posting on another forum, quote:

Dear all,

First of all I would like to Thank Pride for the excellant and simple method of scalping the market. I have been day trading in Stock markets and Currency crosses for the last four years and have tried various methods etc. I always had the gut feeling that a successful trading system will be sweet and simple, and Pride has shown us that system. In view of the fact that future cannot be predicted accurately, we must expect some ups and downs in any system. I went through every page of this thread and want to thank everyone who have contributed with their observations however minor it may be. I also thank Rajadhiraj for his afl on 30min stoch on 5 min chart which is very useful. I have been using Spider Iris for some time and a month back had switched to amibroker professional with RT data from TDI as I find the PIB is very slow in Updating. Although TDI does not supply futures data, I hear they are to provide same from 1st week August. Meantime I have been trading on heavy weight Nifty stocks like reliance and also Nifty futures But using Nifty spot chart quite successfully> i find if we follow the system strictly, the losses are very minimal compared to the gains. Losses mostly restricted to brokerage and slippage. I sholud also state that Although I follow the entry signal given by the system, I sometimes do not exit hastiliy the moment the 5 min stoch crossover so long as the gap between the emas are medium to large. i sometimes wait for it to narrow. I dont mean to say that i always do this, I use my short trading experiance and take decision accordingly. I have made an AFL for use with Amibroker which I made by modifying various afls like that of Rajadhiraj and use same for trading. This afl strictly follows the guidelines put down by Pride. according to my understanding, as follows:

for long
1. 30 min stoch to be bullish, doesnt matter if in overbought zone.
2. 5 mins stoch should be bullish but less than 80 (actually I haver set it as 75 in the afl)
3. Crossover of 5 ema above 13 ema.
when the above conditions are met will give a buy green upward arrow.

4. take profit when 5 mins stoch crossover to bearish or touches. indicated by a small hollow green circle.

in page 3 of this thread, Pride has clearly indicated the stoch settings as follows:
period: 8
%K 4
%D 3

But I have observed that most of the people are using 8, 3, 4 settings and also observed someone using 3, 8 4 while reading this thread.

In this afl i have used 8, 4, 3 settings.

for short trades the vice versa of above with 25 being the setting limitation on the 5 min stoch (for oversold) with red arrow indicating short and red small circle indicating cover.

As I said I have modified and compiled this afl, I mean to say I didnt write this afl but patched it up to show in a single chart Prides rules of the trade. here follows:


I once again thank pride and each one of you for this lively thread and if someone can improvise on the above afl (i am new to amibroker and am also working towards same) and post it here in this thread.

Best regards

Vinod

unquote

I again insist that i am not a specialist whatsoever but a trader who is always on the lookout for a good trading system

best regards
vinod
Attached Files
File Type: txt code.txt (3.2 KB, 800 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 11 Users Say Thank You to vinodkiyer For This Useful Post:
Reply

indiTraders - Forum for the Active Indian Trader > Tools > Software > Amibroker


Tags
afl request, amibroker, ema strategy, swing trade strategy, trading strategy

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Composite Edge

All times are GMT +5.5. The time now is 09:42 AM.


vBulletin Copyright by vBulletin

Content Relevant URLs by vBSEO 3.3.2