### Replace Pioneer Home   All Examples   Free Download

RSS: Replace Pioneer Examples

# 657.Text data calculation -- How to calculate Parabolic SAR on a 5 days basis of stock data?

 User: editor -- 2010-11-17          << 656  658 >> Hits: 4042 Type: Text data calculation Search all Text data calculation examples Description: How to calculate Parabolic SAR on a 5 days basis of stock data? all weeks except the first week must have 5 days, where the date is the first date of the week series.  the OHLVC is calculated as: O = First Open, H = Highest High, L = Lowest Low,  C = Last Close, and V = EMA average. Input Sample: CODE,DATE,OPEN,HIGH,LOW,CLOSE,VOLUME  AIQ,03/02/09,2.91,2.98,2.54,2.54,2845000 AIQ,03/03/09,2.60,2.64,2.44,2.46,3036900 AIQ,03/04/09,2.51,2.84,2.47,2.78,7518800 AIQ,03/05/09,2.71,2.71,2.50,2.56,2468700 AIQ,03/06/09,2.58,2.91,2.56,2.89,2962900 AIQ,03/09/09,2.63,3.59,2.52,3.03,3380300 AIQ,03/10/09,3.19,3.59,3.05,3.58,7604400 AIQ,03/11/09,3.48,3.60,3.41,3.55,2349100 Output Sample: DATE_GROUP TIME FIRST_OPEN HIGHEST_HIGH LOWEST_LOW EMA_VOLUME LAST_CLOSE SAR 03/04/09 00:00 2.91 2.98 2.44 5245866 2.78 2.98 03/11/09 00:00 2.71 3.60 2.50 4046566 3.55 2.44 Answer: Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps. 1. ctrl-o open source text/csv stock file 2. ctrl-h open 'replace' window * set 'replace with pattern' to: \$R * click 'advanced' tab, set 'run following for each matched unit' to: use Math::Business::ParabolicSAR; my \$sar = new Math::Business::ParabolicSAR(0.02, 0.2); @a=split(/\n/,\$match); \$R=''; for(0..\$#a) { @m=(undef,split(/,/,\$a[\$_])); if ((\$#a-\$_)%5==4 ||\$_==0) { \$A=\$m[3]; } #start of group \$B=max(\$B,\$m[4]); \$N++; if (\$N==1) { \$C=\$m[5]; } \$C=min(\$C,\$m[5]); \$D+=\$m[7]*\$N; \$M+=\$N; if ((\$#a-\$_)%5==0) { # end of group \$T=\$m[2]; \$E=\$m[6]; #calculate ParabolicSAR \$sar->insert([\$A,\$B,\$C,\$E]); \$S=\$sar->query; \$R.=sprintf("%s 00:00 %.2f %.2f %.2f %d %.2f %.2f\n",\$T,\$A,\$B,\$C,\$D/\$M,\$E,\$S); \$A=0; \$B=0; \$C=0; \$D=0; \$E=0; \$N=0; \$M=0; } }  3. click 'replace', done! 4. ctrl-s save to file Download Script:  scripts/657.rst.zip Screenshot 1:  Replace_Window Screenshot 2:  Replace_Advanced_Window Similar Examples: How to calculate Williams %R from stock data? (67%)How to calculate Acc/Dis and corresponding 24 days' MA base on stock data? (65%)How to calculate OBV(On Balance Volume) base on stock data? (64%)How to calculate CFMO 15 and CFMO 21 from csv file of stock data? (63%)How to calculate Acc/Dis, OBV and related MA values of stock data? (61%)How to calculate SUM of EMAs and Covariance of close value from stock data? (59%)How to calculate the area of triangles base on 3 sides automatically? (58%)How to calculate Elder's Force Index (EFI) and related MA, EMA for stock data? (55%) Check Demo of Text data calculation Keywords: parabolic  parabolicsar  how to calculate parabolic sar  parabolic sar  calculate parabolic sar  parabo  ow to calculate parabolic sar  abcd  week  series  calculate sar  sar calculation  open source sar calculation  calculate stock sar  calculate sar data  to calculate sar for 5 days  calculate average  replace with a series