WL5 公开的策略 http://www.wealth-lab.com/Charting/...R8CQ3TpY0lWj7QvX9syy9+5bpyCJKf8EgkYeatEhBXDRO WL4 公开的策略 http://wl4.wealth-lab.com/cgi-bin/WealthLab.DLL/browsechartscripts 方法一:Wealth-Lab 3.x/4.x的代码转换到5.x的移植工具 下载地址:http://atp.fidelity.com/WealthLabPro/WealthScriptTranslatorSetup.exe 方法二:在Wealth-Lab 5 里直接运行基于Wealth-Lab 4.x交易策略的方法 Aronow Software LLC 推出了一个名叫Wealth-Lab 4 Compatibility Library 的产品,可以让我们在 Wealth-Lab 5 平台里直接运行基于 Wealth-Lab 4.x 以前版本的大部分交易策略。关注 Wealth-Lab 的朋友们可能知道在Wealth-Lab 社区 4.x 以前版本积累了上千个交易策略与技术指示,这些都是我们学习的很重要的参考资源,不过由于 Wealth-Lab 从 5.0 版本开始上了.net 平台,现在 Wealth-Lab 5 设计交易策略的语言为流行的 C#,以前的版本一直用的是 Pascal,所以 Wealth-Lab 5 不能直接使用 Wealth-Lab 4.x 所开发的交易策略与技术指示,当然高手可以人工转换或者期待 Fidelity Investments 推出转换工具(已推出,见方法一)。而现在 Wealth-Lab 4 Compatibility Library 给我们带来了一些惊喜,可惜要价75美元,演示版本最大限制使用500根bars。 使用方法: 1、安装 Wealth-Lab 4.x; 2、安装 Wealth-Lab 5.x; 3、安装Wealth-Lab 4 Compatibility Library 到 Wealth-Lab 5.x 目录; 4、启动 Wealth-Lab 5.x,新建图表后选译 WL 4 Compatibility Library 打开 Wealth-Lab 4.0 Script Executor 然后再选择来自 Wealth-Lab 4.x 的交易策略。 Wealth-Lab 4 Compatibility Library 下载 http://aronowsoftware.com/WL4CompatInstall.msi
http://wl4.wealth-lab.com/cgi-bin/WealthLab.DLL/editsystem?id=26 http://wl4.wealth-lab.com/cgi-bin/WealthLab.DLL/editsystem?id=9157 太谢谢您了兄弟!8son@163.com
1: Code: using System; using System.Collections.Generic; using System.Text; using System.Drawing; using System.Threading; // Sleep() using System.Windows.Forms; using WealthLab; using WealthLab.Indicators; using finantic.TL; // WealthScriptTL namespace WealthLabCompile2 { class Strategy : WealthScriptTL { #region file ChartScript // start of prolog: This is a comment at the top of each file public new void Init(){ base.Init(); //optional settings UseUpdatedEMA(true); SetStdDevCalculation(StdDevCalculation.Population); } // end of prolog: This is a comment at the top of each file public int Bar = 0; /** This method contains the meat of your script, i.e, any statements that are not inside a user defined class or function/procedure. */ protected override void Execute(){ Init(); // [declaration for class ChartScript used to be here] InstallProfitTarget(100); InstallTrailingStop(30, 30); InstallBreakEvenStop(10); for (Bar = 10; Bar <= (Bars.Count - 1); Bar++) { ApplyAutoStops(Bar); if ((CumDown(Bar, WL_CLOSE, 4) == 9)) BuyAtMarket((Bar + 1), ""); } } // start of epilog: This is a comment at the end of each file } // class Strategy } // namespace // end of epilog #endregion file ChartScript
2: Code: using System; using System.Collections.Generic; using System.Text; using System.Drawing; using System.Threading; // Sleep() using System.Windows.Forms; using WealthLab; using WealthLab.Indicators; using finantic.TL; // WealthScriptTL namespace WealthLabCompile2 { class Strategy : WealthScriptTL { // OptVars private StrategyParameter OptVar1, OptVar2, OptVar3, OptVar4; public Strategy() { OptVar1 = CreateParameter("OptVar1", 12, 4, 27, 1); OptVar2 = CreateParameter("OptVar2", 6, 0, 10, 1); OptVar3 = CreateParameter("OptVar3", 4, 0, 10, 1); OptVar4 = CreateParameter("OptVar4", 1, 1, 5, 1); } #region file ChartScript // start of prolog: This is a comment at the top of each file public new void Init(){ base.Init(); //optional settings UseUpdatedEMA(true); SetStdDevCalculation(StdDevCalculation.Population); } // end of prolog: This is a comment at the top of each file public int x, Bar = 0; public int nPeriod = 0; public int xDevPane = 0; public int nPriceMid, nMidDev, nHiDev, nLoDev, nHiLoDev, nHiLoDevWMA, nLoDevPct, nBuyPivot, nSellPivot, nBuySellPct, nPosToTrade = 0; public double fTmp, fBuyPct, fSellPct, fSellMult = 0.0; public string sInput = null; /** This method contains the meat of your script, i.e, any statements that are not inside a user defined class or function/procedure. */ protected override void Execute(){ Init(); // [declaration for class ChartScript used to be here] nPeriod = (int)(int) OptVar1.Value; fBuyPct = (double)((int) OptVar2.Value / 100); fSellPct = (double)((int) OptVar3.Value / 100); fSellMult = (double)(int) OptVar4.Value; /** Create the MID Series */ nPriceMid = (int)CreateSeries(); for (Bar = 0; Bar <= (Bars.Count - 1); Bar++) { fTmp = (double)(((PriceHigh(Bar) + PriceLow(Bar))) / 2); SetSeriesValue(Bar, nPriceMid, fTmp); } /** Create the Mid Deveation */ nMidDev = (int)DivideSeries(SMASeries(nPriceMid, nPeriod), nPriceMid); /** Create the Buy Sell Percents */ nBuySellPct = (int)CreateSeries(); for (Bar = 0; Bar <= (Bars.Count - 1); Bar++) { fTmp = (double)Math.Abs((GetSeriesValue(Bar, nMidDev) - 1)); SetSeriesValue(Bar, nBuySellPct, fTmp); } /** Create the MIDDev Series */ nHiLoDev = (int)DivideSeries(WL_HIGH, WL_LOW); nHiLoDevWMA = (int)SMASeries(nHiLoDev, nPeriod); /** Create the Hi and Lo Deveations */ nHiDev = (int)MultiplySeries(SMASeries(WL_HIGH, nPeriod), nHiLoDevWMA); nLoDev = (int)SubtractSeries(SMASeries(WL_LOW, nPeriod), MultiplySeries(SMASeries(WL_LOW, nPeriod), SubtractSeriesValue(nHiLoDevWMA, 1))); /** Create the Buy and Sell Pivots */ nSellPivot = (int)MultiplySeriesValue(nHiDev, ((1 + fSellPct))); nBuyPivot = (int)MultiplySeriesValue(nLoDev, ((1 - fBuyPct))); /** Plot the MAs */ PlotSeries(nHiDev, 0, 900, WL_THIN); DrawLabel((("HiDev(" + Convert.ToString(nPeriod)) + ")"), 0); PlotSeries(nLoDev, 0, 090, WL_THIN); DrawLabel((("LoDev(" + Convert.ToString(nPeriod)) + ")"), 0); PlotSeries(nSellPivot, 0, 900, WL_THICK); DrawLabel((("nSellPivot(" + Convert.ToString(nPeriod)) + ")"), 0); PlotSeries(nBuyPivot, 0, 090, WL_THICK); DrawLabel((("BuyPivot(" + Convert.ToString(nPeriod)) + ")"), 0); for (Bar = (nPeriod * 2); Bar <= (Bars.Count - 1); Bar++) { if ((PriceLow(Bar) <= GetSeriesValue(Bar, nBuyPivot))) { SetBackgroundColor(Bar, WL_GREENBKG); BuyAtMarket((Bar + 1), "Buy"); } else { if ((PriceHigh(Bar) >= GetSeriesValue(Bar, nSellPivot))) { nPosToTrade = (int)0; if ((ActivePositions.Count > 0)) { nPosToTrade = (int)(int)Math.Floor((((ActivePositions.Count * GetSeriesValue(Bar, nBuySellPct))) * fSellMult)); if ((nPosToTrade == 0)) nPosToTrade = (int)1; } if ((nPosToTrade > 0)) { SetBackgroundColor(Bar, WL_REDBKG); for (x = 0; x <= (PositionCount - 1); x++) { if (PositionActive(x)) { SellAtMarket((Bar + 1), x, "Sell"); nPosToTrade = (int)(nPosToTrade - 1); if ((nPosToTrade == 0)) break; } } } } } } } // start of epilog: This is a comment at the end of each file } // class Strategy } // namespace // end of epilog #endregion file ChartScript