以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  策略编写求助区  (http://weistock.com/bbs/list.asp?boardid=11)
----  请老师改成金字塔的,谢谢!!!  (http://weistock.com/bbs/dispbbs.asp?boardid=11&id=12347)

--  作者:zws
--  发布时间:2012/6/10 23:18:18
--  请老师改成金字塔的,谢谢!!!

 

 

 

以随机进场为基础的趋势系统(wealth-lab)

 

思路:随机产生0-100的数值。数值大于49多头进场,否则空头进场。进场后,多头10新低退出,空头10新高退出。

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;

namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
protected override void Execute()
{


Random autoRand = new Random( );
for(int bar = 20; bar < Bars.Count; bar++)
{
if (IsLastPositionActive)
{



double level = (LastPosition.PositionType == PositionType.Long) ? Lowest.Series(Low, 10)[bar] : Highest.Series(High, 10)[bar];


 
ExitAtStop( bar+1, LastPosition,level);

}
else
{
double r=100 * autoRand.NextDouble( );
if(r>49)

BuyAtMarket( bar+1);
else
ShortAtMarket( bar+1);

 


}
}
}
}
}



 


--  作者:Leon
--  发布时间:2012/6/11 8:43:56
--  
这是什么?C#代码么?
--  作者:RogarZ
--  发布时间:2012/6/11 9:09:11
--  
wealth-lab我们这边没有懂 也不知道这个代码啥意思 你能不能把你需要的策略思路讲明白
--  作者:Leon
--  发布时间:2012/6/11 9:16:29
--  

楼主写的MyStrategy类继承的WealthScript是什么?


--  作者:zws
--  发布时间:2012/6/11 23:09:50
--  
思路:随机产生0-100的数值。数值大于49多头进场,否则空头进场。进场后,多头10新低退出,空头10新高退出。

--  作者:zws
--  发布时间:2012/6/14 22:55:12
--  

自己顶一下!!

 

是否还没有随机函数?


--  作者:rushtaotao
--  发布时间:2012/6/15 8:45:56
--  
随机数:RAND( 100);
if 随机数>49 then    buy(1,1,market);
if 随机数<49 then    buyshort(1,0,market);
if enterprice>10+c   then sell(1,0,market);
if enterprice+10<c   then sellshort(1,0,market);