Stocks To Keep A Close Eye On - Chapter II

Status
Not open for further replies.

asnavale

Well-Known Member
Hello Friends,

New Triggers for trading on 07-09-2009 and update summary of earlier triggers are given below:

Code:
SYMBOL           CMP        TARGET     STOPLOSS
_________________________________________________
AMBUJACEM       100.00       106.75      95.05
DENABANK         51.85        55.25      49.15
TORNTPOWER       236.3       267.10     222.50
UCOBANK          43.85        46.90      41.40
_________________________________________________

BEML, GVKPIL, KFA, LITL, NTPC, TULIP and WOCKPHARMA
have triggered SELL today.

CMC, HINDZINC and IOC have achieved their targets today.
_________________________________________________
TRADE THESE SIGNALS AT YOUR OWN RISK

Regards

-Anant
 

asnavale

Well-Known Member
Hi Friends,

Today there are no Sell Triggers

The following have reached targets:

CMC, HINDZINC and IOC. New Targets and SL will be set tomorrow.

The following are today's (07-09-2009) BUY Triggers for trading tomorrow (08-09-2009):

IDFC, CMP=147.05, Target=165.90, SL=129.10
JINDALSAW, CMP=569.10, Target=625.30, SL=510.20

JSWSTEEL, CMP=725.30, Target=847.00, SL=653.00

LUPIN, CMP=1013.45, Target=1156.95, SL=903.05

TATAELXSI, CMP=180.90, Target=207.10, SL=160.50

The following also have given BUY signals but require confirmation tomorrow:

ACC, CMP=800.00, Target=842.75, SL=765.05

HCC, CMP=110.40, Target=119.70, SL=103.30

KFA, CMP=47.25, Target=50.15, SL=45.45

KOTAKBANK, CMP=725.50, Target=767.00, SL=690.80

KTKBANK, CMP=126.40, Target=135.80, SL=122.00

LITL, CMP=420.10, Target=451.50, SL=395.50

NEYVELILIG, CMP=134.25, Target=144.15, SL=125.75

SAIL, CMP=166.70, Target=186.25, SL=150.25

SUNPHARMA, CMP=1229.10, Target=1319.70, SL=115.00

TATACHEM, CMP=254.00, Target=271.40, SL=240.00

The complete updated file can be downloaded from here

Regards

-Anant
 

SavantGarde

Well-Known Member
Hi Talisman,

Thanks A Ton....You Also Have Become A Night Bird Like Me...:)


Savant Ji,

By the time Uma ji comes up with his updates, Following stocks have attained the targets.

Jindal Steel - (Next Target 4046.60 S/L 3011.05)
GNFC - (Next Target 120.70 S/L 92.25)
Unitech - (Next Target 131.05 S/L 100.80)
ICSA - (Next Target 227.95 S/L 196.10)
Sun Tv - (Next Target 327.15 S/L 269.50)
Maruti - (Next Target 1723.90 S/L 1445.65)
OFSS - (Next Target 1943.85 S/L 1726.00)
IOC - (Next Target 794.05 S/L 582.00)
Chennai Petro - (Next Target 249.00 S/L 195.05)
BRFL - (Next Target 237.55 S/L 200.00)
GDL - (Next Target 128.55 S/L 108.00)
EKC - (Next Target 227.75 S/L 179.10)
Sintex - (Next Target 286.50 S/L 201.55)

Regards,
Happy & Safer Investing

SavantGarde
 

asnavale

Well-Known Member
Hi Friends,

New BUY Triggers of 08-09-2009 for Trading on 09-09-2009 are given below:


SESAGOA, CMP=223.95, Target=247.00, SL=208.00

TATASTEEL, CMP=456.50, Target=522.50, SL=407.50

The following also have given BUY signals but need confirmation

BEML, CMP=1180.3, Target=1411.40, SL=1028.00

INDIACEM, CMP=131.45, Target=144.5, SL=127.10

ONGC, CMP=1185.80, Target=1261.00, SL=1135.00

TRADE THESE SIGNALS AT YOUR OWN RISK

The followihg have achieved their targets on 08-09-2009:

ABGSHIP, GDL, SREINTFIN, STER


The complete updated Excel Sheet can be downloaded from here


Regards

-Anant

P.S. : Due to net failure from my end, there was delay in posting.
 

asnavale

Well-Known Member
Hi Friends,

No BUY SIGNALS Today

TATACOMM has triggered SELL.

CAIRN, ESCORTS and JINDALSAW have achieved their targets

Complete updated Excel file can be downloaded from here

Regards

-Anant
 

asnavale

Well-Known Member
Hi Friends,

Today's Triggers:

Buy Triggers:

DRREDDY, CMP=821.05, Target=914.50, SL=787.50

GVKPIL, CMP=48.30, Target=55.60, SL=44.30

Buy Triggered But need confirmation for following:

BHEL and ICRA

PIRHEALTH also gave Buy trigger but it gave SELL trigger yesterday. Therefore, it is a whipsaw. Not considered for listing here.

SELL triggered: FINANTECH

Target achieved:

INFOSYSTCH, MINDTREE, SCI

Stop Loss Hit:

DISHTV, GITANJALI, TECHM, TRIVENI

TRADE THESE SIGNALS AT YOUR OWN RISK

Regards

-Anant
 

asnavale

Well-Known Member
Hi Friends,

Updated Excel File for 10-09-2009 is available here

As tomorrow is holiday, i will update the file with today's EOD Data and post it tomorrow.

Regards

-Anant
 

asnavale

Well-Known Member
Hi Friends,

Updates based on EOD of 11-09-2009 are as follows:

BUY Signal:

NO TRIGGERS

SELL TRIGGERED:

FSL, IBREALEST, IDEA, MCDOWELL-N, PATNI, TATAPOWER, TRIVENI

Note: IBREALEST has given SELL Trigger but is very close to its previous support. Therefore, it may recover and SELL can be put on hold for another day.

PATNI is not included in the uploaded Excel file as it had given BUY trigger on March 9 (on that day Close=106.35) and after almost reaching its 6th Target (reached 464.70 against the target of 466.95) it has now given SELL signal.


Targets Achieved:

ALBK, DENABANK, GUJNRECOKE, IOB, PATELENG, RAJESH EXPO

STOP LOSS BREACHED:

GSPL, INDIACEM, RECLTD, TATATEA

Complete details are in the updated EXCEL file which can be downloaded from here.

Regards

-Anant
 

asnavale

Well-Known Member
Hi Friends,

You have been following with interest the Triggers posted by me since 01 July 2009 and also the Daily updates. From September I have started uploading the Excel File also so that you can have a complete picture of the working of the system I am developing. During the period from July till today I have been fine tuning the system to get better results and minimise losses. I was not posting the strategy and the AFL because I wanted to be sure that the system works well and reasonably good profits can be made. I have now got the confidence and want to share the AFL with you so that you can also contribute by putting in your own modifications and tweaks to make the strategy still more robust and more fail-safe. From the Excel file I have been posting, you can see that in the beginning there were more failures compared to recent results. Till August end I was simply following the triggers as they appeared without verifying whether the trigger can be accepted. The strtegy has no built-in mechanism to check this aspect. It is necessary to check it manually by lookig at the charts. But the task is made easy by the AFL as it gives us only the probable candidates and we can check a few charts instead of a few hundred. Some of these points I will cover later.

The strategy has been coded into an AFL (AmiBroker Formula Language) and used with AmiBroker software. If you use some other charting software, you have to translate the AFL into the code that your program understands. I have tested the system with about 200 stocks. If you apply to all the NSE stocks you will get a large number of signals many of them being useless. Therefore, it is necessary to shortlist the stocks which you want to follow and put this list in a Watch list. Then update the prices of these shortlisted stocks daily with EOD data and run the AFL on the watchlist to get the triggers.

I have used a single Moving Average strategy. Single Moving Average includes SMA (Simple Moving Average), EMA(Exponential Moving Average) and Linear Regression (LinReg). I found SMA to be as effective as EMA and therefore use it now. Linear Regression was quite powerful in giving triggers earlier in some cases but too late some times. Therefore, I have selected only SMA. The advantage of SMA is that even without using the software you can get the triggers by manual calculation when you have only a few stocks (10 to 20) to monitor. I have done this when I am travelling. You just need the EOD data for 3-4 months and you can work on it, especially if you carry your data in a laptop and process in Excel.

I had planned to post this discussion in the mother thread so that this Chapter-II remains for triggers only. But Savant suggested to discuss the AFL here in this thread. Therefore, I am posting the write-up here. I also felt later that he was right in suggesting this as the mother thread is having a wider range of topics being discussed and this discussion may get partitioned into smaller bits and continuity would be affected. All discussions related to this AFL can be posted here itself and follow up is more coherrent.

With this preface I stop here and describe the system in the next post which will follow in a short while..

Regards

-Anant
 

asnavale

Well-Known Member

*********************************************************
Latest Update:

AFL modified

Last update on: 01 Jan 2010
*********************************************************
The modified portion is in MAGENTA Color




Hi Friends,

Now let us go into the details of system and the AFL. Here instead of just posting the AFL, I will describe the step-by-step development of the AFL based on the idea in our mind. This may be unnecessary for experts but will be useful for those who are new to AFL writing and want to learn to write their own AFL for their own trading ideas. It also helps in understanding the AFL in complete detail so that the experts can understand my logic and do their own tweaking and modifications. So, Let us start.

As I have already written in the earlier post, the strategy is based on Moving Average. The core of the strategy is, therefore, Buy when Price goes above the Moving Average and Sell when it goes below. Appears too simple but more refinement is required. We will represent the Moving Average by a variable ‘A’. The period of averaging is ‘P’. So, Buy = Close > A and Sell = Close < A, A = Moving Avg(Close, P).

Before Writing the AFL let us list what we want out of the AFL. My expectations from the AFL are:

1. It should give me Buy and Sell Signals and show these signals on chart
2. It should indicate on chart on which candle the Buy/Sell trigger is generated and print the message also indicating the trigger and the action to be taken next day.
3. It should show the present status whether the stock is in Buy-Hold or in Sell-Hold condition
4. In Buy-Hold condition it show on the chart the current profit/Loss at each candle
5. In Buy-Hold condition it should show the next Target expected and the stop loss
6. In Sell-Hold condition it should show the profit/loss made in the previous trade.
7. On the chart it should show the Target and Stop Loss as straight lines between which the price is moving
8. When target is reached, announce it on the chart and automatically calculate the next Target and Stop Loss and show on the chart.
9. For any selected day Generate reports giving the Buy-Sell triggers generated, the targets/Stop Loss reached and daily update of the stocks which have already given Buy Trigger.
10. Add Bollinger Bands to chart optionally, default no BB added. BB period and Width should be changeable without affecting Averaging period.

Quite a long list of expectations? Then the AFL should be very long and complicated. Is it so?

No, it is not that difficult to code these and the AFL will not be very long and complicated.

Now let us develop the AFL and incorporate our expectations into it.

You may later use this AFL as part of another strategy. For this purpose we will confine this AFL code in a separate Section. This can be done in AMiBroker AFL by enclosing the code between two statements:
*************************************
_SECTION_BEGIN(“SingleMA”);

(All of the AFL code here)

_SECTION_END();


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

I have tested four types of Moving Averages: Simple, Exponential, Wilders and Linear Regression. Linear regression gives some very good triggers but it changes depending on future prices. Therefore I have eliminated it. We will have remaining three of them available in the same AFL and select whichever we want. I have put Wilders MA as default and the other two as options. I have found 20-day period of averaging good enough but we will have option of changing this also as required. We will also specify the type of report we would like to get: Triggers report, Update Report, Target / SL reached report. As we want charts also display the information, we define some options for charts also. The code for these is as follows:

************************************************
_SECTION_BEGIN(“SingleMA”);

SetChartOptions(0, chartShowDates | chartWrapTitle);

Type = ParamList(“Average Type”, “Wilders,SMA,EMA”);
P = Param(“Averaging Period”, 20, 3, 100);
Report = ParamList(“Trigs or Update or Tgt-SL”, “Triggers,Update,Tgt-SL”);
Q = Param(“%Change”, 1, 0.1, 10, 0.1);
BP = Param("BB period", 20, 3, 100);
BW = Param("BB Width", 2, 0.5, 10, 0.5);
BBOption = ParamToggle("Plot BB?", "NO | YES");

If(Type == “SMA”) A = MA(C, P);
If(Type == “EMA”) A = EMA(C, P);

If(Type == “Wilders”) A = Wilders(C, P);

************************************************
Note the double ‘=’ signs in the above ‘if’ statements. Q is a number we use to define the percent change in price to determine Peaks and troghs in the prices. The default is 1.

Now define top and bottom Bollinger Bands. BB period is BP, BB width is BW and BB is based on Closing Price:

************************************************
BBTop = BBandTop(C, BP, BW);
BBBot = BBandBot(C, BP, BW);

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


We define Stop Loss as the higher of lowest low in last 5 days or the previous trough and Target as two times the High on the day of Buy Trigger minus the Stop Loss. The code follows:

**************************************
SL = Max(Trough(Low, Q, 1), LLV(L, 5));
Tgt = 2 * High – SL;
MeanPrice = (Open + Close) / 2;


****************************************
Mean price is average of Open and Close for the day. This is used to calculate buy and sell prices and profit/loss made. As we can not enter the actual buy/sell prices we use these figures. The calculated profit/loss will slightly differ from actual but it is sufficient to get an idea of our portfolio value.

A Buy or Sell condition when price (Closing price of the day) goes above or below the average A will lead to many false signals. Therefore, we take a Buy condition only if the whole candle is above the Moving Average and Sell when it is completely below. I found that the Sell condition is okay but if we wait till the whole candle goes above the average it will have some delay. By experimenting with different values I found that if about 70% of candle is above the Average is good enough and acceptable. Therefore, we should determine the part of the candle which is above the Average.

When the low of the candle is just touching the average (Low = Average) the candle is 100% above. When the High is just touching the Average (High = Average) the candle is 0% above Average. The average line cutting across the candle means a part of the candle is above. So (High – Average) divided by (High – Low) and then multiplied by 100 gives the part of candle above the average in percentage. We code this as follows:

**********************************
Part = 100 * (H – A) / (H – L);

Buy = (C > A) AND (Part > 70);
Sell = H < A;


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

This will give Buy for every candle which is 70% or more above A and Sell for every candle below A. We want only the first candle which is a Buy and only the first candle which is Sell. So, we remove all subsequent Buy/Sell signals till an opposite signal is found. So, the code is:

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


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

In between the Buy and next Sell signal the stock is in ‘BOUGHT’ condition or Buy-Hold (BH) as Savant calls it. Similarly between Sell and next Buy signal the stock is in ‘SOLD’ condition (or Sell-Hold). We code this as:

********************************
Bought = Flip(Buy, Sell);
Sold = Flip(Sell, Buy);


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

The Target Price calculation code is:

****************************************
NextTgt = ValueWhen(Buy, Tgt, 1);

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

When the Stock reaches its Target we should shift the Target price to the next value. This happens only when the stock is in Bought condition and not when the Buy trigger is generated. Similarly, the Stop Loss also is raised when a higher low is made after buying (Bought condition). This we code as follows:

************************************
For(i = 1; i < BarCount; i++)
{
If(Bought AND NOT Buy)
{
SL = Max(SL, SL[i – 1]);
If(C[i – 1] >= NextTgt[i – 1]) NextTgt = Tgt[i – 1];
NextTgt = Max(NextTgt, NextTgt[i – 1]);
}
}

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

For reporting the current status of the stock and profit/loss made we should know when the stock was bought, at what price it was bought and at what price it was sold. Similarly we should know whether the stock reached target or hit the stop loss. These are coded as follows:

***********************************************
BuyDate = ValueWhen(Buy, Ref(DateTime(), 1), 1);
BuyPrice = ValueWhen(Buy, Ref(MeanPrice, 1), 1);
SellPrice = ValueWhen(Sell, Ref(MeanPrice, 1), 1);
TgtReached = IIf(Bought AND NOT Buy AND C>= NextTgt, True, False);
SLHit = IIF(Bought AND NOT BUY AND C < SL, True, False);
SLHit = ExRem(SLHit, Buy);

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

Now we have all the information computed by the AFL and now we want this to be displayed on the chart or shown in a report. First we take the case of displaying in the chart. The information can be displayed by including it in the chart title. This we do as follows:

********************************************
Ttl = EncodeColor(colorTurquoise) + “Single MA System, AFL by ANANT NAVALE \n”
+ WriteIf(Buy, EncodeColor(colorGreen) + “Buy Triggered Today. Buy this stock tomorrow.”, “”)
+ WriteIf(Sell, EncodeColor(coloRed) + “Sell Triggered Today. Sell this Stock Tomorrow.”, “”)
+ EncodeColor(colorTan) + WriteIf(Bought AND NOT Buy, “Bought @ ” + BuyPrice + “.”
+ “Target Price = “ + NextTgt + “, Stop Loss = “ + SL + “.\n”
+ WriteIf(TgtReached, “Target Reached. Next Target = “+ Ref(NextTgt, 1) + “.\n”, “”)
+ EncodeColor(colorGold) + “Profit / Loss so far = “
+ Prec(100 * (C – BuyPrice) / (BuyPrice, 2) + “%”, “”)
+ WriteIf(Sold AND NOT Sell, “Sold @ “ + SellPrice + “\nProfit / Loss in previous trade = “
+ Prec(100 * (SellPrice – BuyPrice) / BuyPrice, 2) + “%”, “”);


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

In the above code you can replace my name with yours if you want.

Finally the title to display is:

*********************************************
_N(Title = StrFormat(“{{NAME}} ({{INTERVAL}}), {{DATE}} ; O=%g, H=%g, L=%g, L=%g, C=%g, {{VALUES}}\n\n”, O, H, L, C) + Ttl);

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

We will show Arrow marks on the chart at the candles where the Buy/Sell signals are generated.

Now plot the chart with Buy/Sell Arrows

***********************************************
If(Status(“action”) == actionIndicator)
{
PlotOHLC(O, H, L, C, “”, colorLightGrey, styleBar);
Plot(A, Type + “(“ + P +”)”, colorYellow, styleLine | styleThick);
Plot(IIf(Bought, NextTgt, Null), “Target”, colorBlueGrey, styleLine);
Plot(SL, “Trail SL”, colorTeal, styleLine);
Plotshapes(Marker, MarkerColor, 0, MarkerDist);
if(BBOption) Plot(BBTop, "BB-Top", colorPink, styleLine);
if(BBOption) Plot(BBBot, "BB-Bottom", colorPink, styleLine);

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

}

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

To get different reports:

Triggers report

*******************************************
if((Status(“action”) == actionExplore) AND Report == “Triggers”)
{
Filter = Buy OR Sell;
SetOption(“NoDefaultColumns”, True);
AddTextColumn(Name(), “Symbol”, 77, colorDefault, colorDefault, 120);
AddColumn(DateTime(), “Trigger Date”, formatDateTime);
AddColumn(IIf(Buy, 66, 83), “Signal”, formatChar, colorYellow, IIf(Buy, colorGreen, colorRed);
AddColumn(C, “C. M. P.”, 6.2);
AddColumn(IIf(Buy OR bought, NextTgt, Null), “Target”, 6.2);
AddColumn(IIf(Buy OR Bought, SL, Null), “Stop Loss”, 6.2);
}

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

For updating:

****************************************
If((Status(“action”) == actioExplore) AND Report == “Update”)
{
Filter = True;
SetOption(“NoDefaultColumns”, True);
ADDColumn(DateTime(), “Updated on”, formatDateTime);
AddTextColumn(Name(), “Symbol”, 77, colorDefault, colorDefault, 120);
AddColumn(BuyDate, “Buy Date”, formatDateTime);
AddColumn(BuyPrice, “Buy Price”, 6.2);
AddColumn(NextTgt, “Target”, 6.2);
AddColumn(SL, “StopLoss”, 6.2);
AddColumn(C, “C. M. P.”, 6.2);
}

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

For Target/Stoploss Hit Report:

******************************************
if(Status(“action”) == actionExplore AND Report == “Tgt-SL”

{
Filter = TgtReached OR SLHit;
SetOption(“NoDefaultColumns”, True);
AddColumn(DateTime(), “Updated on”, formatDateTime);
AddTextColumn(Name(), “Symbol”, 77, colorDefault, colorDefault, 120);
AddColumn(BuyDate, “Buy Date”, formatDateTime);
AddColumn(BuyPrice, “Buy Price”, 6.2);
AddColumn(NextTgt, “Target”, 6.2);
AddColumn(SL, “StopLoss”, 6.2);
AddColumn(C, “C. M. P.”, 6.2);
AddColumn(IIf(TgtReached, 89, 32), “Tgt Hit?”, formatChar, colorYellow, IIf(TgtReached, colorGreen, colorDefault));
AddColumn(IIf(SLHit, 89, 32), “SL Hit?”, formatChar, colorYellow, IIF(SLHit, colorRed, colorDefault));
}

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

The complete modified AFL file is available here. You can download it and save in your Formulas/Custom folder. To plot the chart double click on it and to get reports run it in Analysis.

You may post all your queries, comments and suggestions and I will try to answer them as much as possible.

I am using a list if about 300 stocks to track trading signals using the AFL. The list can be obtained from the following link.

Stocks List


Regards

-Anant
 
Last edited:
Status
Not open for further replies.

Similar threads