以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]未来函数怎么用?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=78492)

--  作者:bbking
--  发布时间:2015/5/12 10:31:18
--  [求助]未来函数怎么用?
 比如我要计算在每根K线的收盘价买入~
在接下来的行情中以1%为止损~2%为止盈~
然后把每根止盈的K线标记成红色

如何通过未来函数实现?

--  作者:jinzhe
--  发布时间:2015/5/12 10:46:08
--  

 

 

if (h-enterprice)/enterprice>=0.02 and holding>0  then sell......;//多头止盈

if (enterprice-l)/l>=0.01 and holding>0 then sell.....;//多头止损

 

if (h-enterprice)/enterprice>=0.01 and holding<0  then sellshort......;//空头止损

if (enterprice-l)/l>=0.02 and holding<0 then sellshort.....;//空头止盈

 

stickline((enterprice-l)/l>=0.02 and holding=0 and ref(holding<0,1),h,l,8,0),colorred;

stickline((h-enterprice)/enterprice>=0.02 and holding=0 and ref(holding>0,1),h,l,8,0),colorred;


--  作者:bbking
--  发布时间:2015/5/12 11:21:31
--  
你没明白我的意思~
我是要求他显示每根K线~如果这根K线作为开仓点~
那么最后的结果是止盈还是止损
给他标注出来~

不是写图表回测

--  作者:jinzhe
--  发布时间:2015/5/12 11:28:13
--  
能不能给个图片说明一下?
--  作者:bbking
--  发布时间:2015/5/12 12:09:05
--  


if bar=1 then begin
buy...
end

if (h-enterprice)/enterprice>=0.02 and holding>0  then sell......;//多头止盈

if (enterprice-l)/l>=0.01 and holding>0 then sell.....;//多头止损


从第一根BAR开始算~
如果第一根BAR开仓~最终是赚钱的~则返回1止损的则返回2

然后第二根BAR~如果最终是赚钱的则返回1止损则返回2
if bar=2 then begin
buy...
end

if (h-enterprice)/enterprice>=0.02 and holding>0  then sell......;//多头止盈

if (enterprice-l)/l>=0.01 and holding>0 then sell.....;//多头止损


...

如此~把所有bar算一遍...其实无需使用buy sell这些函数
只需要用未来函数应该也能做到
这是个非常简单的策略

--  作者:jinzhe
--  发布时间:2015/5/12 13:27:45
--  

请结合图片说明一下需求


--  作者:bbking
--  发布时间:2015/5/12 13:35:08
--  
说白了就是一个指标啊~非1即0

1则表示这根K线开仓为止盈
0则表示这根K线开仓为止损

具体交易方式是以当根K线的收盘价为开仓价~上2%为止盈~下1%为止损
这个不需要图的吧?

--  作者:jinzhe
--  发布时间:2015/5/12 13:46:39
--  
你讲的太抽象而我又无法理解,最好的办法是你上张图让我看看你到底想要实现些什么
--  作者:bbking
--  发布时间:2015/5/12 14:21:48
--  
我无语啊~我能够简单通过编程画出图来我还需要问你怎么编程吗?

就是一个指标~判断当根K线的收盘价作为开仓点的盈亏情况~



具体交易的代码如下~
if barpos=1 then begin
buy(1,1,limitr,c);
end
if (h-enterprice)/enterprice>=0.02 and holding>0  then sell(1,holding,limitr,c);//多头止盈
if (enterprice-l)/l>=0.01 and holding>0 then sell(1,holding,limitr,c);//多头止损

从bar=1开始~如果bar=1开仓后最后结果为止盈则返回1否则返回0
如果bar=1开仓后最后结果为止盈则返回1否则返回0
...

这样等于每根bar都有个盈亏的标记
把这个盈亏标记输出成指标

--  作者:jinzhe
--  发布时间:2015/5/12 14:36:09
--  
我的意思是,把你前面说的那些要求,用图片的形式解释一下,