欢迎您光临花生网社区!
| |

 找回密码
 立即注册
查看: 6866|回复: 16
打印 上一主题 下一主题

新手请教,设置开多仓的止盈和止损 [复制链接]



Rank: 2

跳转到指定楼层
1#
发表于 2013-4-9 10:06:21 |只看该作者 |倒序浏览 | [分享到 腾讯微博 新浪微博]
#note
"主图指标"

//---------------------------------------------------------------------
//-----参数设置----------------------
//---------------------------------------------------------------------

Input:                                        //公式参数
        N(9,1,100,1),
        P1(3,2,10,1),
        P2(3,2,10,1);
       
       
RSV:=(CLOSE-LLV(LOW,N))/(HHV(HIGH,N)-LLV(LOW,N))*100;
K:=SMA(RSV,P1,1);
D:=SMA(K,P2,1);
bEnterLong :=CROSS(k,d) ; {多头买入}
bExitLong :=CROSS(d,k) ; {多头卖出}
bEnterShort :=CROSS(d,k) ;//空头开仓条件
bExitShort :=CROSS(k,d) ;//空头平仓条件

If bEnterLong Then Buy;
If bExitLong Then Sell;
If bEnterShort Then SellShort;
If bExitShort Then BuyToCover;


此代码为系统自带KDJ金叉只能交易系统,
请问,我如何设置开多仓的时候设置止盈200 和止损 100呢。
新手请教

使用道具 举报



Rank: 8Rank: 8

2#
发表于 2013-4-9 10:20:37 |只看该作者 | [分享到 腾讯微博 新浪微博]
if 多仓 then begin
SetProfitTarget(200);


SetStopLoss(100);
end

可以看下这些函数的帮助

另外,可以参考http://www.hs633.com/forum.php?m ... &extra=page%3D1
1,Initial stop loss
2,Trailing stop loss(Moves up from initial stop to reduce risk,Protects us at break-even point)
3,Profit protection stop(Keeps winning trades from becoming losses,Locks in a portion of the open profit)
4,Profit maximizing exit(Attempts to exit without giving back profits)

使用道具 举报



Rank: 2

3#
发表于 2013-4-9 10:22:49 |只看该作者 | [分享到 腾讯微博 新浪微博]
bt11 发表于 2013-4-9 10:20
if 多仓 then begin
SetProfitTarget(200);

多谢!!!!!!

使用道具 举报



Rank: 2

4#
发表于 2013-4-9 10:39:19 |只看该作者 | [分享到 腾讯微博 新浪微博]
bt11 发表于 2013-4-9 10:20
if 多仓 then begin
SetProfitTarget(200);

请问下,修改了公式,直接保存就编译了是吗?

使用道具 举报



Rank: 8Rank: 8

5#
发表于 2013-4-9 10:42:55 |只看该作者 | [分享到 腾讯微博 新浪微博]
1,Initial stop loss
2,Trailing stop loss(Moves up from initial stop to reduce risk,Protects us at break-even point)
3,Profit protection stop(Keeps winning trades from becoming losses,Locks in a portion of the open profit)
4,Profit maximizing exit(Attempts to exit without giving back profits)

使用道具 举报



Rank: 2

6#
发表于 2013-4-9 10:44:25 |只看该作者 | [分享到 腾讯微博 新浪微博]
bt11 发表于 2013-4-9 10:20
if 多仓 then begin
SetProfitTarget(200);

看到编译地方了,
我设置开仓无论是多仓和空仓都设置止盈和止损,这样对吗

profitPoint := 100;
LossPoint := 20

SetProfitTarget(profitPoint*BigPointValue);
SetStopLoss(LossPoint*BigPointValue);  
       
If bEnterLong Then Buy;
If bExitLong Then Sell;
If bEnterShort Then SellShort;
If bExitShort Then BuyToCover;

使用道具 举报



Rank: 8Rank: 8

7#
发表于 2013-4-9 10:50:58 |只看该作者 | [分享到 腾讯微博 新浪微博]
SetProfitTarget(profitPoint*BigPointValue);
SetStopLoss(LossPoint*BigPointValue);  
这两句放到最后吧,另外,你这个公式如果用到股指,就是100*300=3万块止赢,总仓位;如果要对每手止赢,可以
SetStopContract;
SetProfitTarget(profitPoint*BigPointValue);
SetStopLoss(LossPoint*BigPointValue);  
1,Initial stop loss
2,Trailing stop loss(Moves up from initial stop to reduce risk,Protects us at break-even point)
3,Profit protection stop(Keeps winning trades from becoming losses,Locks in a portion of the open profit)
4,Profit maximizing exit(Attempts to exit without giving back profits)

使用道具 举报



Rank: 2

8#
发表于 2013-4-9 10:52:16 |只看该作者 | [分享到 腾讯微博 新浪微博]
bt11 发表于 2013-4-9 10:50
SetProfitTarget(profitPoint*BigPointValue);
SetStopLoss(LossPoint*BigPointValue);  
这两句放到最后吧 ...

多谢~了~~

使用道具 举报



Rank: 2

9#
发表于 2013-4-10 13:17:03 |只看该作者 | [分享到 腾讯微博 新浪微博]
bt11 发表于 2013-4-9 10:50
SetProfitTarget(profitPoint*BigPointValue);
SetStopLoss(LossPoint*BigPointValue);  
这两句放到最后吧 ...

出现个问题,为什么我设置了止盈和止损,持仓中止损价格和止盈价格还是都是0呢。很不解。是不是没有设置成功?

#note
"主图指标"

//---------------------------------------------------------------------
//-----参数设置----------------------
//---------------------------------------------------------------------

Input:                                        //公式参数
        N(9,1,100,1),
        P1(3,2,10,1),
        P2(3,2,10,1);
       
       
RSV:=(CLOSE-LLV(LOW,N))/(HHV(HIGH,N)-LLV(LOW,N))*100;
K:=SMA(RSV,P1,1);
D:=SMA(K,P2,1);
bEnterLong :=CROSS(k,d) ; {多头买入}
bExitLong :=CROSS(d,k) ; {多头卖出}
bEnterShort :=CROSS(d,k) ;//空头开仓条件
bExitShort :=CROSS(k,d) ;//空头平仓条件




       
If bEnterLong Then Buy;
If bExitLong Then Sell;
If bEnterShort Then SellShort;
If bExitShort Then BuyToCover;

profitPoint := 3;
LossPoint := 8;
SetStopContract;
SetProfitTarget(profitPoint*BigPointValue);///盈利900 止盈平仓
SetStopLoss(LossPoint*BigPointValue); /// 亏损2400 止损平仓

使用道具 举报



Rank: 8Rank: 8

10#
发表于 2013-4-10 14:36:49 |只看该作者 | [分享到 腾讯微博 新浪微博]
持仓这个面板中的  止损止赢价  是人为设置的,策略的里止赢止损不在这里体现。
1,Initial stop loss
2,Trailing stop loss(Moves up from initial stop to reduce risk,Protects us at break-even point)
3,Profit protection stop(Keeps winning trades from becoming losses,Locks in a portion of the open profit)
4,Profit maximizing exit(Attempts to exit without giving back profits)

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册


bottom

Archiver|www.hs633.com ( 粤ICP备11107430号 )

GMT+8, 2024-4-28 02:32 , Processed in 0.090815 second(s), 8 queries .

花生网 Copyright©2012-2014

回顶部