Sunday, October 7, 2012

PHP Curl UserAgent.

I had a unique problem this weekend, while working on my pet project. I had a URL which when pasted in the browser, i got the data. However, when I provided the same URL in PHP and tried to pull the data through CURL I was unable to get any data. 

First thing that came to my mind was to set the "useragent" i.e to fool the webserver that the request is through a browser. And it worked like a charm.

Following is the curl option that i had to set:

    curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.7) Gecko/20100101 Firefox/10.0.7');

Regards,
Sri

Sunday, November 28, 2010

Prediction time - Option Chain

Predicting the unpredictable - This was one of the main reasons I got hooked to stock Markets. Inspite of spending more than 1/4th of the day on phone I somehow manage to squeeze out time to analyze the markets.  I am not sure, why I love such things [markets not talking over phone ;-)]. In this post I will be covering my analysis on the "Option Chain" of Nifty Futures for the current month provided by NSE-India. 

From the Option Chain table I look for the following:
1. Maximum "Open Interest"[OI] for a "Call" - For the current series[December] I see the maximum OI for 6000 Call. 
2. Maximum OI for a "Put" - For the current series I see the maximum OI for 5600 Put. 

What are the possibilities of the markets direction?
-It is very likely that 5600 Put is being written. If the market movers have to benefit, Nifty has to fall close to 5600 or below 5600. This is logical because 5600 Put will have maximum value around this region.
If we consider 5600 region to be the base for this series, it is very likely that Nifty might close above 6000, because of the huge OI in 6000 Call.

 I feel people are buying 6000 Call as the market is falling and writing 5600 Put. Time will tell the future :-)

Happy Trading
-Sri

Sunday, November 21, 2010

Is it the best time to invest?

Finally, the world markets decided to take a plunge from their new highs of the year 2010. I strongly believe this is a short term correction. After a sustained move-up it makes a lot of sense for a decent correction - nothing wrong with it :-).

From the Minifty Futures chart below: I see it is very unlikely that Nifty would fall below the 5730 level. A breach of the 61.8% retracement level would imply a change in the main trend that is UP [in a longer time frame]. Also the fact that there is a window around the 5650 ish level will act as a strong support. Even if these levels are breached, I would expect "very strong" pullbacks. Effectively providing you an oppurtunity to go long and again short.



For BNF, I am not sure what to consider as a base, so not using Fibonacci retracements. I hope the window again might act as a strong support. 


On the other hand, both NF and BNF are currently sitting at crucial support levels. Following are things that might pan out. 

1. Markets end the correction here and start the next leg of rally fuelled with the shorts closing for F&O closing on Thursday.
2. Markets continue to go down until the F&O closing this Thursday. 
3. EUR/USD seems to have had a pull back implying that USD is getting weaker, which further implies equities might bounce back. 
3. Next 4 days of trade will decide the market direction for the last month of the most spectacular year for the world equity markets. 

For investors, I would say this is a golden oppurtunity to invest in bluechip companies. I am of the opinion that we might never see the current stock prices until we hit the next global disaster. Be smart don't regret later :-). 

-Sri

Thursday, November 11, 2010

Importance of USD - G19 + USA

US Fed announces to pump in $600 Billion, and all we get is just a day of rally. Every rise in the market is negated with enormous selling pressure. What's happening?

I thought of sharing the EUR/USD chart that I have been following for quite some time :-).

Chart of EUR/USD:


As you see in the chart, USD is having a rally [or the EUR is retracing]. With the Fed's move, wasn't USD supposed to get weaker?

My take on the events happening:

1. G20 [or rather G19 + USA] summit is pushing US to stop devaluing USD further. USD, is not just another currency. All the commodities [oil/gold/silver/metals etc] are traded in USD. With USD getting devalued, the commodities will get costlier, impacting export oriented countries. And the extra USD would also flow into these countries as investments and further increase the inflation. And yes there are a lot more problems :-).

2. The weakness in the market could be due to ongoing G20 Summit - No one's sure what will happen to USD :D.

3. If EUR/USD takes support at the 23.6% retracement level, and starts the rally again, we should expect the Stock markets around world to follow suit [Hopefully EUR doesn't get weaker due to some Euro Nation/Bank going bust ;-)].

4. If EUR/USD falls further, we should see a deeper correction in world markets. Another point from my experience is that "FII's" never invest when the markets are at highs, they pull it down [by inducing fresh shorts/ or exiting from ETFs] and then rally. If this were to happen, we could easily see 5800-6000 on Nifty very soon. 6000 puts have the highest OI[open interest] suggesting there is significant support through put writing that has happened.

5. However, the excess USD induced by Fed will definitely enter the emerging markets and we are sure of a rally. But, with the current situation not sure whether we will have a correction before a rally.

-Sri

Sunday, October 3, 2010

An experiment.

I thought of sharing an idea that I got yesterday night - it is about finding the probable target for this ongoing "Sucker Rally". I am not worried about the results as it is just an experiment. 

We use Fibonacci retracements to find the support levels for price, after the market has had a rally. I thought why shouldn't I use the same for finding the target for an ongoing rally. The basis for this is very simple, "Price stops/consolidates at support levels, when in a downtrend". Similarly, "Price also stops/consolidates at resistance levels, when in an uptrend". So based on this fact, if we consider the last weeks consolidation as a 23% retracement from the top, we would have the Nifty top at 6450 [ish], BankNifty at 13300-13500[ish]. I believe its logical to provide a range rather than a fixed target. 

Following are the charts:

BankNifty:



Nifty:



Another interesting aspect I thought of sharing - Using the Elliot wave principle, I believe we are in the last phase of the rally for this intermediate uptrend, and a correction is imminent. Look at the "black zig-zag lines in the chart". 

Will the target be achieved?
1. FIIs are buying relentlessly. I have never seen such momentum in the last 1.75 years [since I started tracking the markets.].
2. Nifty should reach the target of 300 points in the next 2 weeks, if there are no major surprises in the world economy. 
3. The breakout on last Friday, has taken most of the indicators to deep overbought region - a bubble. 
4. Dow Jones, is very likely to hit 10,900 this week and continue to hit 11,250 in the next 2 weeks, before going for a correction. 

Why the target might not be achieved?
1. Nifty has to cross it's all time high of 6357 before reaching this target. A previous high is always a resistance. On the contrary, Nifty did not face any resistance at 5700/5900/6010/6170, so why at 6357 - this is a momentum rally. 

What might happen in October?
I expect Nifty to have a correction of 600-700 points from the highs - If you see the charts above, after "4" there is no price consolidations and hence no support levels [a free fall zone?]. I am assuming this might start just before the Coal India IPO. Correct relentlessly for 2/3 weeks and by Diwali, start the rally again, mimicking the Dow Jones. I will review the situation again next week, whether all the above predictions would still be valid. 

What should Investors do?
Investors should consider a time frame of few years. Nifty in all likelyhood will be much higher in the next 2/3 years. And hence stay away from these bubbles/sucker rallies and enter only after a correction has completed and the uptrend has been resumed. Try to get a Demat account :-) atleast 2 weeks ahead of Diwali and be prepared to invest. 

What should traders do?
Based on your strategy enter long/short, with a stoploss and try to be in the market always. 

Note:
I might be proved completely wrong by the markets, if you lose money following my suggestions - I will laugh at you :-). 

-Sri





Sunday, September 26, 2010

Held at point blank!!!

Yes, pretty much held at point blank for predicting that the markets are to fall. I will give my explanations, why markets might fall - before that an example to prove that people see what they want to see.

Following were my predictions in my previous blogs:
1. Just when everyone was expecting a correction in the Indian/US markets, I told there would be a sucker rally, followed by a correction, which would likely start in the 3rd week or 4th week of September.
2. Just before US markets took off, I posted the charts as to what the US markets might likely do.

Everyone now is asking me why aren't the markets falling - You told markets will fall now!!!! If markets were to listen to what I would say, I would not be working as a software designer. Ohh, b/w I'm OK for constructive criticism but certainly not here for useless taunts :-).

I like to keep things short and to the point:
1. Knowing the direction of the market [the process of predicting the market] is like an "Open book exam". Just by having the text book next to you during the exam does not guarantee you >=95% marks. Just knowing the direction of the market is useless, unless you have a strategy to squeeze the maximum from the markets.

2. If anybody had entered during the sucker rally, they would have made hell lot of profit. When the whole world was worried about US double dip, I said Dow Jones might hit 10900, it is just 40 points away from this target - WHY AREN'T PEOPLE SEEING THESE THINGS :(.

3. A smart person can make money in markets irrespective of the market situation - and so does not have to enter on dips and sell at a higher price. The fact that experienced people in the market are against this is that it is the easiest way to loose money for new comers.

4. And at-last - I would be happy to be wrong a few times, it's a nice humbling experience. If I can learn something from each of my mistakes, I can live with the mistakes and it would be too arrogant of me to expect to be right always with markets.

OK, enough of egoistic talks, now to my reasons for the markets to fall:

1. Whenever the price touches the bollinger bands [I use "21" as the period], it either goes sideways, or hits the other side of the band.

2. Whenever there is a breakout/breakdown, we look for two things for a reversal in the daily charts. Firstly, a Doji and secondly a close below/above the previous bar. This is a signal of reversal. We have had a "Doji" on NF and BNF. Now waiting patiently for a close below any of the previous bars.

3. FIIs have a net buy of  17K+ crores - highest since 2006 [http://www.moneycontrol.com/stocks/marketstats/fii_dii_activity/index.php]. A similar thing happened last year - in september 2009, FIIs had a net buy of 13K+ crores. And the following month there was a fast and deep correction. A very high likelyhood this time. All those people who want to invest - this is the last oppurtunity until next January [2011] or April/May[2011].

4. FIIs are investing in the Exchange Traded Funds, which is usually bought by the hot money. This hot money is extremely liquid. It can go out "ANYTIME".

On the other hand markets might go sideways without correcting, make a new high and then correct sharply. Otherwise in all likelyhood we should resume the uptrend in late October or early November and rally until Jan/Feb before a pause. We have now entered a range of high volatility, an amazing time for intraday traders :-).

-Sri

Saturday, September 11, 2010

Dow Jones keeps everyone guessing...

Dow Jones Industrial Average is giving a tough time for the chartists trying to predict the future of it's course. It is so close, negating a "Head and Shoulder" pattern - one of the strongest patterns. Dow Jones has had ~500 points rally so far in this month, which is historically the most bearish month. "Extremely" low trading volumes in the last few weeks could be attributed to this strange behaviour. On the other hand few analysts are suggesting, investors are waiting for the November elections to get over and only then we might get a decisive move in the US stock markets.

With just a few weeks ahead of the 4th quarter results, most companies would be trying their best to finish a strange year on a good note. Now to the charts.....


I know you guys will start wondering whether I can see only "Head & Shoulder" patterns :-). The pattern in the above chart gives a target of ~10,900 for Dow Jones.

Now to the "even" more interesting chart:


Just in case the previous pattern is successful then we would have "yet another" inverted head and shoulder pattern on the Dow Jones. And the target could be ~11,600 a new high since the recession started.

If all these patterns are to fructify, if there are no corrections in US will India have a correction - my answer would be "No". Indian stock market can be compared to a "beta stock" in the world market that outperforms the world in case of good news/bad news. But one thing for sure in case of Indian stock market is that the volatility is increasing and we might get a flash flood like correction and within no time get back to newer highs. A 10% correction within a week and then back to a newer high within the next few weeks - is quite a possibility.

If you are already invested in stocks - start booking part profits at new highs and re-enter on dips. You'll need a lot of patience - if you don't you'll regret :|.

If you are not in the market - the golden rule of investment is to enter on dips "not" when a stock is making a new high. Again restrain patience - if you don't like heart aches :-).

I am an "extremely" [yes I need an adverb, not redundant :-P] impatient guy - how am I in the stock market :-?. Well "Index futures" give an option to stay in the market "always" - long[buy and then sell] or short[sell and then buy], which further implies your investments work even when the markets are falling.

-Sri