 
等级: 超级版主
- 注册:
- 2021-5-18
- 曾用名:
- FireScript
|
以下范例 有2个未定义变量,就是开多开空条件。你把你自己的条件替换过来就行了。
variable:maxprofit=0;//有仓位时最大获利幅度
input:N(5,1,100,1);
//开仓部分 按照这个语句方式 进行全局变量重置
IF 开多条件 and holding=0 THEN
BEGIN
BUY(1,1,limit,c);
maxprofit:=0;
END
IF 开空条件 and holding=0 THEN
BEGIN
BUYSHORT(1,1,limit,c);
maxprofit:=0;
END
//判断当前持仓状态下的最大盈利
win:=0;
win2:=0;
//空头更新记录的部分
if holding > 0 and enterbars > 0 then
begin
win:=(c-enterprice)/enterprice*100; //记录最大盈利
if win>maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
//多头更新记录的部分
if holding < 0 and enterbars > 0 then
begin
win:=(enterprice-c)/enterprice*100; //记录最大盈利
if win > maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
//出现最高盈利后,回落到盈利的N%平仓出场.
多移动止赢:SELL(win2 >= N and openprofit > 0, 0,limit,c);
空移动止盈:SELLshort(win2 >= N and openprofit > 0, 0,limit,c);
|
|