|
樓主 |
發表於 11-8-30 22:17
|
顯示全部樓層
- function GetBackAdjustedData( DataPath )
- {
- DateData=DateNum();
- AdjustedDiff=0;
- //for(i=0; i<BarCount; i++)
- //_TRACE(NumToStr(DateData[i],1.0));
- fh=fopen(DataPath, "r");
- if(fh)
- {
- while( !feof(fh) )
- {
- string=fgets(fh);
- //_TRACE("#"+string);
- GetDate=StrExtract(string, 0);// the date to Transfer
- GetDiff=StrExtract(string, 5);// Diff between two month
-
- //_TRACE("#"+GetDate+": "+GetDiff);
- GetYear=StrLeft(GetDate,4);
- GetMonthDay=StrRight(GetDate,4);
- GetDate=NumToStr( StrToNum(GetYear)-1900,1.0)+GetMonthDay;
- //_TRACE("#"+GetDate);
- GetDateNum=StrToNum(GetDate);
- GetDiffNum=StrToNum(GetDiff)*-1;
- for(i=0; i<BarCount; i++)
- {
- //_TRACE("#"+GetDate+" : "+NumToStr(DateData[i],1.0)+" : " + GetDiff);
-
- if(DateData[i]<=GetDateNum)
- AdjustedDiff[i]+=GetDiffNum;
- else
- break;
- }
-
- }
- fclose(fh);
- }
- else
- {
- _TRACE("ERROR, File does not exist!!");
- }
- return AdjustedDiff;
- }
- DataPath=ParamStr("Data Path","C:\\Program Files (x86)\\AmiBroker\\Formulas\\Custom\\BackAdjusted.txt");
- BackAdjustedDiff=GetBackAdjustedData(DataPath);
- newOpen=O+BackAdjustedDiff;
- newHigh=H+BackAdjustedDiff;
- newClose=C+BackAdjustedDiff;
- newLow=L+BackAdjustedDiff;
- //PlotOHLC(newOpen, newHigh, newLow, newClose, "BackAdjusted", colorRed, styleCandle);
- Buy=Sell=Short=Cover=0;
- GenName="~Adjusted"+Name();
- if ( Status("action") == actionScan )
- {
- AddToComposite(newOpen,GenName,"O");
- AddToComposite(newHigh,GenName,"H");
- AddToComposite(newLow,GenName,"L");
- AddToComposite(newClose,GenName,"C");
- AddToComposite(V,GenName,"V");
- }
- PlotOHLC(Foreign(GenName,"O"), Foreign(GenName,"H"), Foreign(GenName,"L"), Foreign(GenName,"C"), "Foreign", colorRed, styleCandle);
- _SECTION_BEGIN("Price");
- SetChartOptions(0,chartShowArrows|chartShowDates);
- _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
- Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
- _SECTION_END();
複製代碼 |
評分
-
查看全部評分
|