Dear Seniors / Experts,
Coming back to you for your help. I want the Pairs Trading AFL with Candlestick. Currently the same is a Line Chart.
I tried working on the same using HHV, Highest, TimeFrameGetPrice, etc. functions, but just couldn't code it.
The following is a small brief on the requirement :
(i) A simple code using the difference between the Open, High, Low and Close of one Scrip with that of the second Scrip (like, 'PH - H' or 'PL - L') will not work [H - High of Scrip 1, L - Low of Scrip 1, PH - High of Scrip 2, PL - Low of Scrip 2].
This is becos, even if Scrip 1 is making a high at say, 12:30 PM, Scrip 2 may not make a high at that exact time (though, it is possible that the Scrip 2 may make a high at an earlier or a later time, say at 12:32 PM, but is its highly unlikely that the high will be exactly at 12:30 PM).
(ii) If the chart is seen in a smaller TF, say, 15 minute TF, one can easily notice the Highs & Lows made by the Current Spread during the day. This is unlike viewing the chart in a Daily TF, where we can notice only one price point of the Current Spread at the extreme right of the chart, which is the CMP / LTP of the Current Spread.
Pls find attached the images of 2 charts, one showing the High made (in 15 Minute TF) on 22nd Nov '12 and the other showing the Low made (in 15 Minute TF) on 22nd Nov '12.
http://i.imgur.com/a0Cnb.png
http://i.imgur.com/gdYH1.png
You may also download the AFL of the Line Chart from the below mentioned link. (In order to view the chart of 'Line with Dots', go to "View > Price Chart Style > Line with Dots" in AmiBroker.
Pankaj Parimal - Pairs Trade (New Updated).txt - 4shared.com - document sharing - download
The attached images are of the pair - Bank Nifty & SBI. The same can be viewed by first selecting the chart of SBI and then using parameters (by right clicking on the chart) to key in the High Priced Scrip, i.e., Bank Nifty.
If one views the chart in a lower TF, say, 1 Minute TF, we can find a more accurate value of High or Low made by the Current Spread during the day.
Though AmiBroker has various functions like, TimeFrameGetPrice, TimeFrameExpand, TimeFrameCompress, HHV, LLV, Highest, Lowest, HighestVisibleValue, LowestVisibleValue, etc., I am not able to use the same to code this requirement.
(iii) The Open and Close values can be got by a simple code like 'PO - O' and 'PC - C', where PO - Opening Price of Scrip 2, PC - Closing Price of Scrip 2, O - Opening Price of Scrip 1 and C - Closing Price of Scrip 1. [But again, as in the case of High & Low, the Opening and the Closing prices of the 2 scrips may not be executed at the same time and may differ a little.]
Request the Seniors to suggest a better way, if any, of retrieving the Opening & Closing prices of Current Spread.
(iv) Once we have the Open, High, Low & Close values of the Current Spread, we can plot the Candlestick of Current Spread.
I would like to request all the seniors & experts to kindly help me with my requirement.
Pls let me know if you require further explanation or are unable to understand my requirement.