*multicharts - CDP_交易模型 *
=============================================================================
說明 | 應用前一天的最高價、最低價、及收盤價的計算與分析,將當日的股價變動範圍為五個等級,再利用本日開盤價的高低位置,做為超短線進出的研判標準。 | |||||||
計算公式 |
|
引用: http://www.ezchart.com.tw/inds.php?IND=CDP
=============================================================================
指標code:
Vars: CDP(0), NH(0), NL(0), AH(0), AL(0);
CDP = ( HighD(1) + LowD(1)+ 2*CloseD(1) ) / 4;
NH = 2*CDP - LowD(1);
NL = 2*CDP - HighD(1);
AH = CDP + ( HighD(1) - LowD(1) );
AL = CDP - ( HighD(1) - LowD(1) );
Plot1(NH, "NH");
Plot2(NL, "NL");
Plot3(AH, "AH");
Plot4(AL, "AL");
Plot5(CDP, "CDP");
=============================================================================
範例code:
//txf_cdp_trade
inputs: entry_timeb(0900),exit_timeb(1250);
inputs: entry_times(0850),exit_times(1250);
inputs: sl(50),time_out(1300);
vars: MP(0),CDP(0), NH(0), NL(0), AH(0), AL(0);
//cdp
AH = CDP + ( HighD(1) - LowD(1) );
NH = 2*CDP - LowD(1);
CDP = ( Highd(1) + Lowd(1)+ 2*Closed(1) ) *0.25;
NL = 2*CDP - HighD(1);
AL = CDP - ( HighD(1) - LowD(1) );
MP= marketposition;
//buy &sellshort _entry
if mp=0 and time>entry_timeb and time<exit_timeb and EntriesToday(date)<1 and c>o then begin
Buy("Buy")next bar AH or Higher; a
End;
if mp=0 and time>entry_times and time<exit_times and EntriesToday(date)<1 and c<o then begin
Sellshort("Sellshort")next bar AL or Lower;
End;
//sell&buytocover
if marketposition<>0 then
Sell from entry("Buy") next bar NH stop ;
if marketposition<>0 then
Buytocover from entry("Sellshort") next bar NL stop ;
end;
// stop loss*
setstoploss(sl*bigpointvalue);
{
//daytrade
if time>=time_out then begin
buytocover next bar at market;
sell next bar at market;
end;
}
//Settlement date
Condition99=(dayofweek(date)=3 and dayofmonth(date) > 14 and 22 > dayofmonth(date)) or date=1150224 or date=1040127 or date=1070226 or date=1100617 or date=1100222;
if marketposition<>0 and condition99=true then begin
if time>1345 then begin
sell("s_s") THIS BAR on close;
buytocover("s_b") THIS BAR on close;
end;
end;
-------------------------------------------------------------------------------------
※ 大家寫看看吧~歡迎聯繫來信討論~
※程式碼僅供研究,不為交易依據!!