|
我是新手,写了个指标,但在 PowerLanguage Editor 总是无法通过编译,请帮忙指出问题,不胜感激。
代码如下:
DefineDLLFunc: "D:\FILES\STOCK\GVA dll", float, "GVA";
Inputs:
Length(200),//
initialCapital(100000),
frame_ddays(10),
frame_pdays(250), //
contr(1), //shares(100)
Money(0.3);
arw.size(18);//箭头大小
variables:
var1 = GVA(close,Length);//指标值
var2 = lowstoploss=lowest(low,frame_pdays);//多头停损点
var3 = highstoploss=highest(high,frame_pdays);//空头停损点
var4 = lowdiffer=AbsValue(entryprice-lowstoploss);//
var5 = highdiffer=AbsValue(hithstoploss-entryprice);//
var6 = RiskPercent(Money);
var7 = TotalEquity=initialCapital+NetProfit;
var8 = Exitloss= TotalEquity * RiskPercent;
var9 = id.arw(-1);//箭头
condition1=highest(var1,frame_ddays)<20;
condition2=close[0]>close[frame_pdays];
condition3=close[0]<close[frame_pdays];
condition4=Exitloss > lowdiffer;
condition5=Exitloss > highdiffer;
// Entry Order
if condition1 and condition2 then
begin sellshort contr next bar at market;
end else if then condition1 and condition3
begin buy contr next bar at market;
end;
// Exit conditions for long
once condition4 begin setstoploss(Exitloss);
end;
if MarketPosition = 1 then begin
setDollarTraing((lowdiffer)*Bigpointvalue);
end ;
// Exit conditions for short
once condition5 begin setstoploss(Exitloss);
end;
if MarketPosition = -1 then begin
setDollarTraing((highdiffer)*Bigpointvalue);
end;
// 画出并标示做多箭头向上蓝色改变该K线颜色
if condition1 and condition3 then
begin
id.arw = ARW_new(date, time, low, false);
ARW_setsize(id.arw, arw.size);
Arw_SetText(id.arw , "Buy");
Arw_SetColor(id.arw , Blue);
PlotPaintBar(high,low,open,close,"",Blue);
end
// 画出并标示做空买入箭头向下红色改变该K线颜色
if condition1 and condition2 then
begin
id.arw = ARW_new(date, time, high, true);
ARW_setsize(id.arw, arw.size);
Arw_SetText(id.arw , "Sellshort");
Arw_SetColor(id.arw , Red);
PlotPaintBar(high,low,open,close,"",Red);
end
// 标出停损点
Plot1(lowstoploss,"LongOut",yellow);
Plot2(highstoploss,"ShortOut",yellow);
//画出GVA 指标
Plot3(var1,"GVA",Green);
|
|