|
vedel 發表於 12-8-25 21:29
我明明就有寫道,還有畫圖,這個虛擬equity 會uptade;小第的觀念是減少與server端的交握,因為操作 ...
小弟近日在研究這類的東西
_SECTION_BEGIN("Portfolio");
eq = Foreign("~~~EQUITY", "C");
cash = Foreign("~~~EQUITY", "L");
dr = eq - Highest(eq);
bslh = HighestBars(eq);
GraphZOrder=1;
Plot(eq, "Portfolio Equity", colorLightBlue, styleArea );
if( ParamToggle("Show Cash", "No|Yes", 1 ) ) Plot(cash, "Cash", colorGreen, styleArea );
if( ParamToggle("Show Drawdown", "No|Yes", 1 ) ) Plot(dr, "Drawdown", colorDarkRed, styleArea );
if( ParamToggle("Show #bars since last high", "No|Yes", 0 ) ) Plot(bslh, "#bars since last high", colorDarkYellow, styleLine | styleOwnScale, 0, 10 * LastValue( Highest( bslh ) ) );
islastbar = Status("lastbarintest");
isfirstbar = Status("firstbarintest");
bar = BarIndex();
firstbar = LastValue( ValueWhen( isfirstbar, bar ) );
lastbar = LastValue( ValueWhen( islastbar, bar ) );
al = LastValue( ValueWhen( islastbar, LinRegSlope( eq, Lastbar - firstbar + 1 ) ) );
bl = LastValue( ValueWhen( islastbar, LinRegIntercept( eq, Lastbar - firstbar + 1 ) ) );
Lr = al * ( BarIndex() - firstbar ) + bl;
Lr = IIf( bar >= firstbar AND bar <= lastbar , Lr, Null );
if( ParamToggle("Show lin. reg.", "No|Yes", 0 ) )Plot( Lr , "Linear Reg", colorRed, styleThick );
_SECTION_END();
這個可以拿來做 MDD 和 equity 的計算
然後再搭配大大給小弟的方向
寫出一個虛擬的 equity 文字檔給策略讀取
並套用公式來自動控制 position sizing
---
參考看看了~`.
|
|