View Full Version : How to Code this Smartly?
spaceant
2008-10-03, 08:49
Hi all,
I have a problem to resolve as I want to code an indicaotor in an intraday chart to sow the average of the previous 20-day trading range. I can use HighD() and Low() to code in the intraday chart, say
yesterday range = Highe(1) - Low(1);
It can be done with the similar code for the rest of previous 19-day range and take the average.
However, in terms of performance to show the indicator real time. It is bad as it refers to past 20-day bars for calculation.
In Metastock, I can use a DLL to calculate the average 20-day range in the daily chart and write into a file; then it can recall the value from the file in an intraday chart.
Is there any similar DLL or function in TS?
Sa
insert 2 symbol into 1 chart, and use close of data1 and close of data2 to referrnce them in one indicator
spaceant
2008-10-04, 11:29
Hi Neo,
Thanks for your post.
Butl, I don't quite understand what you mean. Can you demonstrate?
Sa
Would it be possible in this case to insert the multiple time frame bars all into the same chart? You can insert up to 50 data streams into a chart. They can be different symbols or the same symbol and may have differing bar intervals. With your chart selected, follow the Insert -> Symbol menu sequence to add a new symbol, or symbol with a different bar interval, to your chart. In general, it is best to format the symbols so as to have the shortest bar interval as Data1, since a strategy can buy and sell only Data1.
Once the symbols are inserted into the chart, you can perform calculations on them using syntax like the following:
variables: MyD2Avg( 0, Data2 ) ;
MyD2Avg = Average( Close, 10 ) of Data2 ;
spaceant
2008-10-08, 12:50
Would it be possible in this case to insert the multiple time frame bars all into the same chart? You can insert up to 50 data streams into a chart. They can be different symbols or the same symbol and may have differing bar intervals. With your chart selected, follow the Insert -> Symbol menu sequence to add a new symbol, or symbol with a different bar interval, to your chart. In general, it is best to format the symbols so as to have the shortest bar interval as Data1, since a strategy can buy and sell only Data1.
Once the symbols are inserted into the chart, you can perform calculations on them using syntax like the following:
variables: MyD2Avg( 0, Data2 ) ;
MyD2Avg = Average( Close, 10 ) of Data2 ;
Neo,
Thanks for your help! I now can code it.
Bye the way, I have also use another method by creating a function to calculate the 20-day range. I am testing on it on its working efficiency which is nice.
The method by openning and referring to the daily data will minimize the number of periods loaded in order to calculate the 20-day range.
Well, I don't know which method should work better.
Any comment?
Sa
the way i showed you has the following you need to pay attention:
1,it can be back tested
2,it can not be back tested in intrabar mode.
spaceant
2008-11-01, 17:07
Neo and other friends,
If I use the following code to set up a filter if SMA of 50 and 200 of daily data as a filter, for intraday trading.
variables: MyD2Avg( 0, Data2 ) ;
MyD2Avg = Average( Close, 10 ) of Data2 ;
How can I do it? ... as I would need 200 intraday data in order to get the SMA of 50 & 200 for the filter. This has a tecnical problem as the current month future would have 200 days of data....
How can I resolve it?
Regards,
Sa
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.