System Implementation Exercise

karthikmarar

Well-Known Member
#31
Hi rpc

Looks like there some mistake in your adding murthy's stock selection formulas.
Try the attached afl. Run it as a scan and it will give only the stocks with buy and sell conditions, For today about 10 stocks selected.

regards

karthik
 
Last edited:

murthymsr

Well-Known Member
#32
dear friends & fellow members,

as part of the 'System Implementation Exercise', i am posting a brief descriptive of the system MABIUTS - K1 and also attaching the system AFL code that will be used for this testing. also a sample Price & K1 indicator chart. feel free to give your feedback and you too can run this code on your AB data and test for yourself to get the feel of the selections.

MABIUTS K1 basically uses adaptive moving average (AMA) with other improvisations. AMA was originally provided by Kaufman and works on the volatility. when the stock is volatile the the ema calculation periosd is shortened and the AMA follows the price cloosely. but when the stock is less volatile like in sideways movement, the period is lengtened so that AMA moves slowly. AMA thus helps us to indentify the stocks moving sideways.

but here we are going a step further... we are using the ADX or RAVI to further control the AMA. in a sideways market the ADX & RAVI have low values. normally ADX > 20 or RAVI > 4 is considered trending market. for values of ADX < 20 (or RAVI < 4), we will clamp the AMA so that it becomes
almost a straight line. so when the ADX is less than 20 indicating a sideways market we get almost a horizontal line AMA. so if AMA is horizontal, we avoid geting into any trades to avoid whipsaws.

for more detailed explantion on the system, please refer to the post by karthik:

http://www.traderji.com/57647-post176.html

the original AFL provided by karthik and posted in this thread by sanjay was 'changed' by me and attached to this post. the changes will NOT change the basic process of the stock selection. the changes are:

1) a few lines of code added, so that the search will be within about 200 stocks considered by price & volume. also the close, volume in thousands (VK) & the turnover in lakhs are added into the exploration.

2) then to get a full insight into the process of stock selection, some columns are added in the exploration mode. they are like RAVI, ADX, the intermediate variable DIFF, MyConst, NewConst & the ratio of AMA & the EMA of the AMA. also the number of trading days since the 'last' reversal is provided.

3) the AMA & its EMA can be viewed as a chart for ready eye-balling of the trend.

4) some additional information like the changes in volume (VR), MACD (CD), RSI & HL% are added. HL% indicats the position of the last close as a % of the previous highs and the lows.

5) for easy identification of whether the value of any parameter for a stock is of positive (buy) significance or negative (sell) significance, colors are used for the values. in general, GREEN means a positive value, RED means a negative value and BLACK means a transition zone.

6) the BUY / SELL signalled stocks are being added to watchlist no: MyWL, with a default value of 10, set in the first lines of the code. if you already have some other list in this watch list, you may change the default value. otherwise contents of your watchlist no 10 will be deleted.

7) BUY /SELL siganals are shown as B / S in the column 'BS'. Desk Top inventory management :)

8) the system has a capability to select ADX or RAVI to control the AMA, with ADX as the default. i will be using only the ADX option to report my selected stocks. but when i get more selections than i can buy on that day, i will use the value of RAVI and other parameters( particularly VR) to limit my selection to the numbers permitted by the money management guidelines.

this procedure is presented with annoying detail, so that some more members may find is easy to start selection of stocks on their own and post them too.

i welcome any suggestions to make changes to the code as long as it does NOT affect the stock selection.

for sure, i am a bad selector of stocks and for that reason, i do not want the value of karthik's system to be undervalued ! ;)

thanks for your patience in going through this long post.

murthymsr
 
Last edited:

SGM

Active Member
#33
Hello RPC

I will try to answer your queries.

* Cell H2 should contain formula "1%*C3/H3" meaning we are risking max 1% of total trading capital per trade

- Cell H2 has to be input by us. It is the value for the amout of risk we are taking for that trade. For e.g if you are going long on a share priced 660 with a stop loss of 610 then the risk is Rs 50 per share, similarly if one is shorting the share at 1100 with a stop loss of 1120, the the vallue will be 20. In this case the excel sheet calculates the max no of shares you can buy/sell, the formula is the same one that you have provided (H5 = "1%*C3/H2")


* If it is so then what happens to shares which cost less than 100.What should be SL ? see next point

- The money management rules do not put any limit on the SL value, your SL can be more than 5% of the Entry Price, but in this case your position size will be smaller, so as in case of the SL being hit, the maximum drawdown per trade is 1% of the total equity (10000, in this case)


* how does max drawdown figure in this ? Will not SL take care of it ? Or Risk(cell H2) should be less than 5% of cell H3, If so then formula in H2 should be modified accordingly.

- You are right when you say the SL (along with proper position size) will take care of the Maximum Drawdown. If you are not able to pin point the exact or even approx stop loss value, use 5% which is a guideline. This figure was arrived at as an optimum value for the systems being tested, after all the backtesting we have done. The 5% value is not hardcoded in the excel sheet.

The sheet calculates 2 values for Position Size
1. By using the risk value provided by the trader
2. By limiting the risk to capital (1%)

We have to use the smaller of the two Values.(H7)



* If less than 5 signals then we stay with cash ? If more than 5 signals generated then which stocks to select ?

- We will be limited by the capital at our disposal, here is where we deviate from back testing / paper trading, we might miss better opportunities as we have already used up the capital. We will review this situation, currently go for the first available trades.(As Murthy has pointed out we should be able to take 3 - 8, avg 5 trades)


* For every Buy signal we would input Open Price of next day of share in cell H3 to get no of shares.

- Not the open price, as published by the exchange. The actual price at which the trade can go thru. If the share gaps up/down, we will take the price that is easily tradable. If we are not able to monitor the opening prices, other members can help us out here. Also intraday charts can help us to know rates @ 10:00 to 10:15 AM


* Any Profits/Losses will be reinvested so Starting Equity figure will change with every sell. Is my interpretation correct ?

- Currently the starting equity will not change, pending review after a month. In case of profit we will use the same equity. Similarly in case of a loss/drawdowm the folio owner (trader) will have to work out the details, the excel sheet does not take it into account, maybe it calls for the trade log to be upgraded to version 2 :)


* Add one more row in Position Sizing showing Stop Loss Price to facilitate its entry in "Stop"(Col I23)

- Col H2 to H7 are to used as simple calculator to calculate position size. Col I, 23-98 is to record the value of initial Stop Loss Price for every trade executed, it will be useful in calculating the ratios at a later date (Risk/reward, etc).


* Brokerage and other expences should be how much ? I feel it should be same for all.

- 0.35% one side i.e 0.7% for cash and 0.10% for FnO is what was decided, the excel sheet is hard coded with 0.7% value (J14, K14 etc), for FnO trades we will have to change it to 0.1%,(making it selectable:- another enhancement for version 2)


* what does "VK","TL" and "TLM" stand for in murthymsr's 200 stk selection afl ?

Refer to Murthys post above.

* when I ran Mabiuts AMA(after including murthy's afl) even shares with Close < 10 got selected.
I got total 24 buy signals.which are attached.How do we ensure the exploration is run on stocks
given out by murthymsr's 200 stocks list ?

Karthik has already answered your above query. I hope it clears some of your doubts.

Regards
Sanjay
 
Last edited:

rpc

Active Member
#34
Hi Karthik
Thanks for the afl.I had included murthy's afl using #include statement.I have now copied your afl.
Thanks
with best wishes
rpc
 

rpc

Active Member
#35
Hi SGM
Thanks for detailed explanation.Pls readon
* You have said we have to put value in cell H2.eg if buy price is 660 and my SL is 610.SL will be 50 this is the basic
thing I am trying to understand how do I decide my SL price is 610 or 620 or any other figure.What I understood
was my SL would be minimum of 1) 1% of total capital and 2) 5 % of investment per trade.I think to my
answer regarding DrawDn you have mentiond these two basis only for arriving at Position Size.I am aware we can use
ATR or last pivot low etc for determining SL but I feel the simplest is the one mentioned above.Can I contnue with it ?
* Regarding Starting Equity remaing same as I understand from your explanation in case of profits we
wll remove the profits from Trading System and in case of loss nothing is decided as yet.
* Since we are not implementing trailing SL the figure of SL once decided will remain same till position is closed
on hitting SL or SELL signal is generated.
* I did not check Brokerage col where you have already entered formula for it.My mistake.
Thanks
with best wishes
rpc
 

rpc

Active Member
#36
hi Karthik
In your afl for AMA you have follo condition

include = C> MyCL AND V/1000> MyVK AND C*V/100000 > MyTL AND TLM > 0.333 * MyTL ;

I have not understood the last part ie "TLM > 0.333 * MyTLM" . Why do we want to have EMA of 100 periods TLM above 1/3rd of current TLM ? Pls explain what does it mean.
Thanks
with best wishes
rpc
 

murthymsr

Well-Known Member
#37
hi Karthik
In your afl for AMA you have follo condition

include = C> MyCL AND V/1000> MyVK AND C*V/100000 > MyTL AND TLM > 0.333 * MyTL ;

I have not understood the last part ie "TLM > 0.333 * MyTLM" . Why do we want to have EMA of 100 periods TLM above 1/3rd of current TLM ? Pls explain what does it mean.
Thanks
with best wishes
rpc
hi rpc,

the objective of this code is to avoid the low value, low volume and low turnover stocks and to have a common set of around 200 stocks for all systems to trade with.

EMA100 of TL (turnover in lakhs) is ensured to be at least a third of the current turnover. the reason is that some of the systems are using EMA's of even 65 periods. thus we will ensure that the selected stocks are TRADED with reasonable volume for a period of 100 days and EMA(C,65) is also meaningful.

the objective of this exercise is to ensure that different systems are tested with the same set of around 200 stocks so that their performance can be compared.

hope this answers your query.
murthymsr
 

karthikmarar

Well-Known Member
#38
Murthy, Sanjay

Siva has raised a genuine problem with the stock scan. If the volume goes down the set level afer a buy signal and a entry is made, then the sell signal is not generated as the stock is excluded from scan. Any solutions ??

regards

Karthik
 

murthymsr

Well-Known Member
#39
Murthy, Sanjay

Siva has raised a genuine problem with the stock scan. If the volume goes down the set level afer a buy signal and a entry is made, then the sell signal is not generated as the stock is excluded from scan. Any solutions ??

regards

Karthik
dear karthik,

siva is right. it's a bug. to overcome this, one way is to add all such held portfolio stocks in a WatchList say 11 and apply the filter like:

************************************
//Select Tradeable stocks
WL_BS = 10 ;
WL_Hold = 11 ;

MyC = Param( "CLOSE", 50, 10, 100, 10 );
MyVK = Param( "VOLK", 50, 10, 100, 10 );
MyTL = Param( "Rs LAKHS", 300, 100, 1000, 100 );

include = (C> MyC AND V/1000> MyVK AND C*V/100000> MyTL) OR InWatchList( WL_Hold) ;

************************************

if any better idea does not emerge, we may go by this logic. each implemetor may choose a watchlist no that does not foul with his other watchlists and code accordingly. he has to manually 'maintain' such a watchlist. as the no of stocks are a max of 10, it may not be difficult. such watchlist helps in watching the portfolio performance in EOD / Intraday mode.

i thank siva for pointing out the bug. he is a profesional programmer and that is the difference.

when the implementors are ready with their systems and just before posting the first day's reports, i propose that the FIVE may meet over a chat for a general review of the selections and other system related matters.

sanjay may please look into and arrange.

thanks to all for the wonderful experience the exercise is contributing for the collective efforts for a common goal.

murthymsr
 
Last edited:

Similar threads