找回密碼
 註冊
搜索
查看: 2988|回復: 10

[範例程式碼] 请教大大一个问题

[複製鏈接]
發表於 14-5-15 18:08 | 顯示全部樓層 |閱讀模式
_SECTION_BEGIN("MACDPrediction");
/*An MACD, Signal Cross is, in general, a bullish Signal.
Since it comes with a significant delay, it would be important to anticipate this Cross. Some days before the Cross, we often see an MACD turning point. It is interesting to investigate the related conditions AND use them before the end of the session.
The following AFL code will give the necessary next ROC for a higher MACD value.*/
//The probable Cross between MACD AND its Signal, by D. Tsokakis, Feb2005
SetBarsRequired(10000,0);
function EMAn ( Cnext , r3)
{
return ( 2 * Cnext + ( r3 - 1 ) * EMA ( C , r3 ) ) / ( r3 + 1 ) ;
}
function MACDn ( Cnext , r1 , r2 )
{
return EMAn ( Cnext ,r1 ) - EMAn ( Cnext , r2 ) ;
}
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
det = 500 ;
perc = 25/100 ;
Clast = SelectedValue ( C ) ;
det = 500 ;
perc = 25/100 ;
Clast = SelectedValue ( C ) ;
MACDlast = SelectedValue(MACD());
SIGNALlast = SelectedValue ( Signal ( ) );
Cnextmin = ( 1 - perc ) * Clast ;Cnextmax = ( 1 + perc ) * Clast ;
step = ( Cnextmax - Cnextmin ) / det ;
nextROC1 = -100 * perc ;
nextROC2 = -100 * perc ;
for ( Cnext = Cnextmin ; Cnext <= Cnextmax ; Cnext = Cnext + step )
{
X = MACDn ( Cnext , 12 , 26 ) ;
Y = EMA ( X , 9 ) ;
MACDnext = SelectedValue ( X );
SIGNALnext = SelectedValue ( Y );
NextROC = 100 * ( -1 + Cnext / Clast ) ;
NextROC0 = 100 * ( -1 + Cnext / Clast ) ;
if ( macdnext < SignalLAST )
{
NextROC1 = NextROC ;
}
if ( MACDnext < MACDlast )
{
nextROC2 = nextROC0;
}
}

//Plot ( 0 ,"", colorBlack ,styleDashed ) ;
Plot (nextROC1  ,"", colorRed) ;
Plot ( nextROC2 ,"", colorGreen  ) ;

_SECTION_END();


请教程式如何改 才能得到每日的nextROC1和nextROC2
 樓主| 發表於 14-5-16 10:08 | 顯示全部樓層
Can anybody help me? Thanks
回復

使用道具 舉報

 樓主| 發表於 14-5-16 11:49 | 顯示全部樓層
SelectedValue的问题?
回復

使用道具 舉報

發表於 14-5-16 12:54 | 顯示全部樓層
Plot (nextROC1  ,"nextROC1", colorRed) ;
Plot ( nextROC2 ,"nextROC2", colorGreen  ) ;
回復

使用道具 舉報

 樓主| 發表於 14-5-16 13:07 | 顯示全部樓層
不行,一样的。只能得到两条直线
回復

使用道具 舉報

發表於 14-5-16 13:38 | 顯示全部樓層
Title = "NextROC1 = "+nextroc1+"     NextROC2 = "+nextroc2;
回復

使用道具 舉報

 樓主| 發表於 14-5-16 13:43 | 顯示全部樓層
hitrader 發表於 14-5-16 13:38
Title = "NextROC1 = "+nextroc1+"     NextROC2 = "+nextroc2;

只能显示当日的数据 见图
2014-5-16 13-42-15.jpg
回復

使用道具 舉報

 樓主| 發表於 14-5-17 17:49 | 顯示全部樓層
anybody help me?
回復

使用道具 舉報

發表於 14-5-17 18:28 | 顯示全部樓層
hangye 發表於 14-5-17 17:49
anybody help me?

把 SelectedValue  去掉試試看唷~~
回復

使用道具 舉報

 樓主| 發表於 14-5-17 21:19 | 顯示全部樓層
还是不行唷,大大
回復

使用道具 舉報

 樓主| 發表於 14-5-19 09:04 | 顯示全部樓層
这段程式码实在难懂
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則


Archiver|手機版|站長信箱|廣告洽詢|COCO研究院

GMT+8, 25-9-6 01:10

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回復 返回頂部 返回列表