龙听期货论坛's Archiver






 微信: QQ:

龙听 发表于 2020-12-6 10:18

期货软件TB系统源代码解读系列73-恒温器系统

**** Hidden Message *****[/size]

龙听 发表于 2020-12-6 10:19

做空代码及结果如下:
[code]Params

Numeric swingTrendSwitch(20);

Numeric swingPrcnt1(0.50);

Numeric swingPrcnt2(0.75);

Numeric atrLength(10);

Numeric bollingerLengths(50);

Numeric numStdDevs(2);

Numeric trendLiqLength(50);

Numeric Lots(0);

Vars

NumericSeries cmiVal(0);

BoolSeries buyEasierDay(False);

BoolSeries sellEasierDay(False);

NumericSeries myATR(0);

NumericSeries MidLine(0);

Numeric Band(0);

NumericSeries upBand(0);

NumericSeries dnBand(0);

NumericSeries trendLokBuy(0);

NumericSeries trendLokSell(0);

NumericSeries keyOfDay(0);

NumericSeries swingBuyPt(0);

NumericSeries swingSellPt(0);

NumericSeries trendBuyPt(0);

NumericSeries trendSellPt(0);

NumericSeries swingProtStop(0);

NumericSeries trendProtStop(0);

BoolSeries swingEntry(False);

Begin

If(!CallAuctionFilter()) Return;

cmiVal = Abs(Close - Close[29])/(Highest(High,30) - Lowest(Low,30))*100;

trendLokBuy = Average(Low,3);

trendLokSell= Average(High,3);

keyOfDay = (High + Low + Close)/3;

buyEasierDay = False;

sellEasierDay = False;

If(Close[1] > keyOfDay[1]) sellEasierDay = True;

If(Close[1] <= keyOfDay[1]) buyEasierDay = True;

myATR = AvgTrueRange(atrLength);

If(buyEasierDay == True)

{

swingBuyPt = Open + swingPrcnt1*myATR[1];

swingSellPt = Open - swingPrcnt2*myATR[1];

}

If(sellEasierDay == True)

{

swingBuyPt = Open + swingPrcnt2*myATR[1];

swingSellPt = Open - swingPrcnt1*myATR[1];

}

swingBuyPt = Max(swingBuyPt,trendLokBuy[1]);

swingSellPt = Min(swingSellPt,trendLokSell[1]);

MidLine = AverageFC(Close,bollingerLengths);

Band = StandardDev(Close,bollingerLengths,2);

upBand = MidLine + numStdDevs*Band;

dnBand = MidLine - numStdDevs*Band;

trendBuyPt = upBand;

trendSellPt = dnBand;

If(cmiVal[1] < swingTrendSwitch)

{

If(MarketPosition != -1 And Low <= swingSellPt)

{

SellShort(Lots,Min(Open,swingSellPt));

swingEntry = True;

}

If(MarketPosition == -1 And BarsSinceEntry >= 1 And High >= swingBuyPt)

{

BuyToCover(0,Max(Open,swingBuyPt));

swingEntry = False;

}

}

swingProtStop = 3*myATR;

trendProtStop = Average(Close,trendLiqLength);

If(cmiVal[1] >= swingTrendSwitch)

{

If(swingEntry == True)

{

If(MarketPosition == -1 And BarsSinceEntry >= 1 And High >= (EntryPrice + swingProtStop[1]))

{

BuyToCover(0,Max(Open,EntryPrice + swingProtStop[1]));

swingEntry = False;

}

}

If(swingEntry == False)

{

If(MarketPosition != -1 And BarsSinceExit >= 1 And Low <= trendSellPt[1])

{

SellShort(Lots,Min(Open,trendSellPt[1]));

}

If(MarketPosition == -1 And BarsSinceEntry >= 1 And High >= Min(trendBuyPt[1],trendProtStop[1]))

{

BuyToCover(0,Max(Open,Min(trendBuyPt[1],trendProtStop[1])));

}

}

}

End[/code]

[attach]25967[/attach]

骄天龙 发表于 2021-2-9 21:07

谢谢楼主!新年快乐!

龙听小虎 发表于 2023-11-11 10:03

{:115:}

页: [1]
渠道·推广(20年运营值得信赖!)▼:温馨提示:期货论坛稳定、流畅的访问体验有赖于赞助商的广告支持,赞助商业务内容非本站官方业务,期货、证券及外汇投资均有亏损的风险,访问赞助商广告即代表您已了解其中的风险。欢迎意向赞助商联系客服或管理员咨询相关事宜。
                     
❤️2025年通过期货论坛开户享受如下优惠政策:政策一:手续费最低交易所+1分起,政策二:日内炒单及大资金享更高比率返还,政策三:保证金可申请交易所标准+0,政策四:开户即享有论坛Prime会员资格(价值199元/年),开户咨询管理员或右侧客服! 😋欧美期货杂志购买、下载与中文翻译:/thread-10603-1-1.html |TB/MC开户优惠政策:/thread-5986-1-1.html2025年最新交易所手续费表:/thread-7537-1-1.htmlSC2.png2025年最新中文翻译:/thread-160355-1-1.html;
欧美期货程序化期刊中文翻译目录: 【1982/83.01-12期】 【1984.01-12期】 【1985.01-12期】 【1986.01-12期】 【1987.01-12期】 【1988.01-12期】 【1989.01-12期】 【1990.01-12期】 【1991.01-12期】 【1992.01-12期】 【1993.01-12期】 【1994.01-12期】 【1995.01-12期】 【1996.01-12期】 【1997.01-12期】 【1998.01-12期】 【1999.01-12期】 【2000.01-12期】 【2001.01-12期】 【2002.01-12期】 【2003.01-12期】 【2004.01-12期】 【2005.01-12期】 【2006.01-12期】 【2007.01-12期】 【2008.01-12期】 【2009.01-12期】 【2010.01-12期】 【2011.01-12期】 【2012.01-12期】 【2013.01-12期】 【2014.01-12期】正在更新中...... 【2015.01-12期】待补 【2016.01-12期】待补 【2017.01-12期】正在更新中...... 【2018.01-12期】 【2019.01-12期】 【2020.01-12期】 【2021.01-12期】 【2022.01-12期】 【2023.01-12期】 【2024.01-12期】 【2025.01-12期】正在更新中......