标题:
【MultiCharts(MC)程序化(量化)网上培训学习系列】第416节:经典策略范例“超级趋势(Supertrend)"量化策略、编写程式码、运行展示及进行初步回测
[打印本页]
作者:
龙听
时间:
2025-4-28 05:46
标题:
【MultiCharts(MC)程序化(量化)网上培训学习系列】第416节:经典策略范例“超级趋势(Supertrend)"量化策略、编写程式码、运行展示及进行初步回测
【MultiCharts(MC)程序化(量化)网上培训学习系列】第416节:经典策略范例“超级趋势(Supertrend)"量化策略、编写程式码、运行展示及进行初步回测
[mp4]http://mp4.qhlt.club/Rec%200416.mp4[/mp4]
1、注册论坛会员即可免费获得公开课视频
源码
及文档;升级至付费会员免回复查看
策略源码
、文档;升级至prime会员无阻碍畅游全站
期货
策略、源码、回测、优化、视频、教程、图书、文档,具体参考:
http://www.qhlt.cn/thread-37840-1-1.html
;
2、通过期货论坛推荐新开立期货账号,可免费获得付费会员或prime会员资格并享受账户特惠政策,参考:
http://www.qhlt.cn/thread-25049-1-1.html
;
3、通过期货论坛开立期货账号并绑定MC享受专属优惠政策:
http://www.qhlt.cn/thread-80442-1-1.html
;
4、PC购买/服务器托管如何选择及量化软件相关设置指导:
http://www.qhlt.cn/thread-105169-1-1.html
;
5、全网最大策略源码区:
http://www.qhlt.cn/forum-109-1.html
;策略精选推荐优化区:
http://www.qhlt.cn/forum-874-1.html
;回测排名:
http://www.qhlt.cn/forum-877-1.html
;
6、对视频中策略有困惑、想法、建议、优化?欢迎关注管理员微信进行切磋与交流。动动手,扫二维码加入微信群跟一众量化爱好者切磋吧:
管理员微信:
论坛官方微信群:
电报群:
;
作者:
龙听
时间:
2025-4-28 05:47
程式码部分:
Inputs:
ATRLength(10),
Multiplier(3.0);
Variables:
ATR(0),
UpperBand(0),
LowerBand(0),
Trend(1),
Supertrend(0),
PrevSupertrend(0),
PrevTrend(1);
// Calculate ATR
ATR = AvgTrueRange(ATRLength);
// Calculate Bands
UpperBand = (High + Low) / 2 + Multiplier * ATR;
LowerBand = (High + Low) / 2 - Multiplier * ATR;
// Supertrend Calculation
If CurrentBar = 1 then begin
Supertrend = UpperBand;
PrevTrend = 1;
end
else begin
if Close > PrevSupertrend then Supertrend = MaxList(LowerBand, PrevSupertrend)
else
Supertrend = MinList(UpperBand, PrevSupertrend);
if Close > Supertrend then Trend = 1
else if Close < Supertrend then Trend = -1;
end;
// --- Entry and Exit Rules ---
// Trend Change -> Entry Signals
if Trend <> PrevTrend then begin
if Trend = 1 then begin
// Close Short Position first
if MarketPosition < 0 then BuyToCover ("ExitShort") next bar at market;
// Open Long Position
Buy ("LongEntry") next bar at market;
end
else if Trend = -1 then begin
// Close Long Position first
if MarketPosition > 0 then Sell ("ExitLong") next bar at market;
// Open Short Position
SellShort ("ShortEntry") next bar at market;
end;
end;
// Save for next bar
PrevSupertrend = Supertrend;
PrevTrend = Trend;
复制代码
作者:
龙听
时间:
2025-4-28 06:15
运行交易回测
作者:
龙听
时间:
2025-4-28 06:16
视频中程式码部分:
本帖隐藏的内容需要回复才可以浏览
作者:
龙听
时间:
2025-4-28 06:17
1、只要出趋势都能抓住。
2、振荡市场会亏损。
3、这不是一个全天候的策略,适合半自动化交易。即通过分析认为后市会出现趋势性行情,再开启此策略。
欢迎光临 龙听期货论坛 (http://www.qhlt.cn/)
Powered by Discuz! 7.2