Assistance Required for coding Pairs Trading AFL

pankajpari

RSITradeMaster
#61
Hi manst, pls find below the replies to your queries :

1) how to find best suitable pair?(on daily chart)
The best way to find the most suitable pair would be by using an exploration. But since I am not very good at that writing one, I manually scan the pairs using the daily chart in the evening to see any opportunities for the next day.


2) I have found that many signals on the chart.when std dev is increased signals get reduced.which std dev is best?
I prefer to use 2 SD as 95.45% of the values lie within the 2 Standard Deviations of the Mean (3 SD covers 99.73% while 1 SD covers 68.27% values). Higher the SD one uses, the signals get reduced but it has a higher probability of returning to the mean (this is how I interpret the same - pls google SD for better understanding). Also, though higher SD can give better results, there is also a possibility that some good opportunities with lower SD can be missed out.

3) how long should be in trade? means when to exit?
It all depends on your risk & reward appetite. I have seen pairs giving more that 60-70% profits if one holds the pair for 2-3 months. But again, the losses can also go up drastically. Though, one needs to give some time for the pairs to show its true potential, according to me, one should hold the pairs for atleast 3-5 days. But it is also possible that the pairs can reach one's target level within a few minutes. In that case, it is always best to square off and take profit.....If one has 2 lots, one can take profit with 1 lot and trail the SL with the other lot.

4) are you trading with this?
Yes. I use the charts to enter, monitor & exit from a trade. But if you wish to use the same, request you to first paper trade and only after having understood the system & the risks involved in it, should you take the plunge. Though it is said that Pairs Trading is a Market Neutral strategy and will profit most of the times, it can give huge losses as well.... In case of directional trades, we enter with only one scrip and if the strategy goes wrong, the losses will happen in only one scrip....Pairs Trading involves 2 scrips and if things have to go wrong, they can go wrong in both the scrips. Hope you understand what I am saying.

Though I have been studying Pairs Trading since more than a year & half, I started trading with pairs only since the last 4-5 months. Since not much info is available on this strategy, you will need to do a lot of learning before you decide to go ahead with this strategy.

In case of any further doubts PM me your mail id / cell no. and I will get in touch with you. All the very best to you.:thumb:

Regards,

Pankaj
 
#62
Hi Pankajpari,
thanks a lot for your post, I found it very useful for me.I'm going try to use your indicators intraday in calendar futures spreads.At first look idicators work perfect.As for me will be better to use candles in the spread visualization,like in Amibroker's built in indicator spread.
And can you give me advise regarding your last "updated new indicator Pairs trading". Unfortunaly ,it does not work properly - no chart of spread,just information.Your previous indicator "pairs trading updated "is OK.I use Amibroker 5.60.2. I'll be appreciate so much for your reply,I really need different modes - difference,sum and ratio of pairs,and I think algorithm,as you described before,must be better.
Best wishes,
Serge
 

pankajpari

RSITradeMaster
#63
Hi Pankajpari,
thanks a lot for your post, I found it very useful for me.I'm going try to use your indicators intraday in calendar futures spreads.At first look idicators work perfect.As for me will be better to use candles in the spread visualization,like in Amibroker's built in indicator spread.
And can you give me advise regarding your last "updated new indicator Pairs trading". Unfortunaly ,it does not work properly - no chart of spread,just information.Your previous indicator "pairs trading updated "is OK.I use Amibroker 5.60.2. I'll be appreciate so much for your reply,I really need different modes - difference,sum and ratio of pairs,and I think algorithm,as you described before,must be better.
Best wishes,
Serge
Hi Serge,
Apologies for the late revert. Happy to know that you found the post useful.

Though I have not tried using the AFL for Calendar Future Spreads, I guess it should work very well with that strategy as well.

Since you are using it for the calendar strategy, you can create candlestick chart as follows :

1) Under Spread section (below CSpread) copy the following code :-

OSpread = PO - O;
HSpread = PH - H;
LSpread = PL - L;

2) Under section where the Line chart is plotted, replace the following :
Plot(Cspread,"Current Spread/Ratio", SprBarColor, styleNoTitle | ParamStyle("Style - Current Spread/Ratio") | GetPriceStyle());

with :

PlotOHLC( OSpread, HSpread, LSpread, CSpread, "Current Spread/Ratio", SprBarColor, styleCandle);

3) Under Spread section (below CRatio) copy the following code :-

ORatio = PO / O;
HRatio = PH / H;
LRatio = PL / L;

4) Under section where the Line chart is plotted, replace the following :
Plot(CRatio,"Current Spread/Ratio", SprBarColor, styleNoTitle | ParamStyle("Style - Current Spread/Ratio") | GetPriceStyle());

with :

PlotOHLC( ORatio, HRatio, LRatio, CRatio, "Current Spread/Ratio", SprBarColor, styleCandle);


This should fulfill your requirement.

Plotting candlesticks for the Spread / Ratio between 2 different scrips is difficult and cannot be done as above becos the 2 scrips would make their respective Highs & Lows at different times....

I didn't understand which updated indicator you are referring to and also didn't follow your reference to 'algorithm'. As regards to the different modes, my understanding is that for Pairs Trading only 2 modes are used - difference & ratio. As per my knowledge, sum is not taken.

Do let me know if you require any other assistance.

Regards,

Pankaj
 
#66
Hi Pankajpari! Sorry for delay,I've been at vacation.Thanks for your reply.I''ll try to make changes in your code.You have three versions of Pairs Trading indicator
- original,updated and updated new. I was speaking about the last one.
Regarding the spread of sum - it concerns the pairs with negative correlation,for example - S&P 500 and VIX index.One more idea to develop yours pairs trading indicator.The more real way to show the spread between pairs is to use BID and ASK prises of both of them.If we going to sell the spread we actually use BID price of upper pair and ASK price of down pair,and if we going to buy spread we use the ASK price of down pair and BID price of upper pair.Of course it have sense just for intraday trading when we want to buy or sell spread fast. For trading on daily basis does not matter which prices we use,but anyway it will be better to see the real spread on chart.
Best wishes,
Serge
 
#67
Hi Big Short, waiting for your post.....
Sorry i was completely away from this forum because of my final semester. I graduated if anyone is wondering :p. Anyways over the course of time i have in my opinion made my trading system quite viable and have been trading with it for the last 6 months with quite satisfactory results. I am planning to start my trading journal blog. you should check it out. I would like to compare notes if you have been trading your pairs trading system as well.

The link to my blog ( i hope i am not breaking some rule ) : http://marketsandm.blogspot.in/
 

Similar threads