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

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

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



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: 2

2#
发表于 2013-4-9 10:22:49 |显示全部楼层 | [分享到 腾讯微博 新浪微博]
bt11 发表于 2013-4-9 10:20
if 多仓 then begin
SetProfitTarget(200);

多谢!!!!!!

使用道具 举报



Rank: 2

3#
发表于 2013-4-9 10:39:19 |显示全部楼层 | [分享到 腾讯微博 新浪微博]
bt11 发表于 2013-4-9 10:20
if 多仓 then begin
SetProfitTarget(200);

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

使用道具 举报



Rank: 2

4#
发表于 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: 2

5#
发表于 2013-4-9 10:52:16 |显示全部楼层 | [分享到 腾讯微博 新浪微博]
bt11 发表于 2013-4-9 10:50
SetProfitTarget(profitPoint*BigPointValue);
SetStopLoss(LossPoint*BigPointValue);  
这两句放到最后吧 ...

多谢~了~~

使用道具 举报



Rank: 2

6#
发表于 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: 2

7#
发表于 2013-4-10 15:49:40 |显示全部楼层 | [分享到 腾讯微博 新浪微博]
ptLibert 发表于 2013-4-10 15:17
策略里的止损止盈每根k线都可能会重新计算,跟手工下单的止损止盈分别存放在不同的变量里。
面前策略的止损 ...

多谢指导啊~~~

使用道具 举报



Rank: 2

8#
发表于 2013-4-16 09:36:18 |显示全部楼层 | [分享到 腾讯微博 新浪微博]
ptLibert 发表于 2013-4-10 15:17
策略里的止损止盈每根k线都可能会重新计算,跟手工下单的止损止盈分别存放在不同的变量里。
目前策略的止损 ...

请问PRINT 我写了。但是在交易日志里查询不到呢。从哪里能看到print出来的内容呢。

另外:如果我想看每一次价格波动引起的变化,我也想print出来,金魔方有这个功能 吗?

使用道具 举报



Rank: 2

9#
发表于 2013-4-16 13:05:02 |显示全部楼层 | [分享到 腾讯微博 新浪微博]
ptLibert 发表于 2013-4-16 10:53
print在
“量化交易”->"公式日志"中

tks~~~~~~~~~~

使用道具 举报

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


bottom

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

GMT+8, 2024-5-11 00:30 , Processed in 0.093750 second(s), 9 queries .

花生网 Copyright©2012-2014

回顶部