花生网

标题: 新手请教,设置开多仓的止盈和止损 [打印本页]

作者: djy252    时间: 2013-4-9 10:06     标题: 新手请教,设置开多仓的止盈和止损

#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呢。
新手请教


作者: bt11    时间: 2013-4-9 10:20

if 多仓 then begin
SetProfitTarget(200);


SetStopLoss(100);
end

可以看下这些函数的帮助

另外,可以参考http://www.hs633.com/forum.php?m ... &extra=page%3D1
作者: djy252    时间: 2013-4-9 10:22

bt11 发表于 2013-4-9 10:20
if 多仓 then begin
SetProfitTarget(200);

多谢!!!!!!
作者: djy252    时间: 2013-4-9 10:39

bt11 发表于 2013-4-9 10:20
if 多仓 then begin
SetProfitTarget(200);

请问下,修改了公式,直接保存就编译了是吗?
作者: bt11    时间: 2013-4-9 10:42

要点编译,请参考
http://www.hs633.com/helpmanual/index.html?bianyizhibiao.htm
作者: djy252    时间: 2013-4-9 10:44

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;
作者: bt11    时间: 2013-4-9 10:50

SetProfitTarget(profitPoint*BigPointValue);
SetStopLoss(LossPoint*BigPointValue);  
这两句放到最后吧,另外,你这个公式如果用到股指,就是100*300=3万块止赢,总仓位;如果要对每手止赢,可以
SetStopContract;
SetProfitTarget(profitPoint*BigPointValue);
SetStopLoss(LossPoint*BigPointValue);  
作者: djy252    时间: 2013-4-9 10:52

bt11 发表于 2013-4-9 10:50
SetProfitTarget(profitPoint*BigPointValue);
SetStopLoss(LossPoint*BigPointValue);  
这两句放到最后吧 ...

多谢~了~~
作者: djy252    时间: 2013-4-10 13:17

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 止损平仓

作者: bt11    时间: 2013-4-10 14:36

持仓这个面板中的  止损止赢价  是人为设置的,策略的里止赢止损不在这里体现。
作者: ptLibert    时间: 2013-4-10 15:17

本帖最后由 ptLibert 于 2013-4-10 17:33 编辑

策略里的止损止盈每根k线都可能会重新计算,跟手工下单的止损止盈分别存放在不同的变量里。
目前策略的止损止盈还没有很方便的观看手段,只能自己通过print函数打出来进行观察。


作者: djy252    时间: 2013-4-10 15:49

ptLibert 发表于 2013-4-10 15:17
策略里的止损止盈每根k线都可能会重新计算,跟手工下单的止损止盈分别存放在不同的变量里。
面前策略的止损 ...

多谢指导啊~~~
作者: djy252    时间: 2013-4-16 09:36

ptLibert 发表于 2013-4-10 15:17
策略里的止损止盈每根k线都可能会重新计算,跟手工下单的止损止盈分别存放在不同的变量里。
目前策略的止损 ...

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

另外:如果我想看每一次价格波动引起的变化,我也想print出来,金魔方有这个功能 吗?
作者: ptLibert    时间: 2013-4-16 10:53

print在
“量化交易”->"公式日志"中
作者: djy252    时间: 2013-4-16 13:05

ptLibert 发表于 2013-4-16 10:53
print在
“量化交易”->"公式日志"中

tks~~~~~~~~~~
作者: xsyzm    时间: 2013-4-17 14:23

嗯,试试看
作者: zhulimeng    时间: 2015-3-5 12:43

问个类似的问题,在策略评测里用的策略 如何设置 止损按浮动比例来?看来下帮助不是很明白虚心请教 比如

If BarsSinceEntry(0)=5 Then Sell('', DEFAULT, 0, 0, Ot_Market, OB_THISBAR);
if SetStopLoss(EntryPrice(0)*0.95*CurrentContracts) then Sell('', DEFAULT, 0, 0, Ot_Stop, OB_THISBAR);

买入后第5天无论怎么样都卖出,但5天内浮动盈亏到了开仓价的95%无论如何都止损这样怎么写


PS:刚刚下到这个牛逼的软件 达人指教啊不然没信心了~~~~~~~~




欢迎光临 花生网 (http://hs633.com/) Powered by Discuz! X2