COCO研究院

 找回密碼
 註冊
搜索
查看: 5223|回復: 10

請教LWBO的MC碼

[複製鏈接]
發表於 13-2-11 19:31 | 顯示全部樓層 |閱讀模式
Larry william BO當沖策略只提到進場的大概方法 五分鐘線
以前一天高低點之差,再乘以0.3,然後在找出今天開盤後15分鐘內的高低點
高點-(前一天高低點之差,再乘以0.3)=今天的空方線
低點+(前一天高低點之差,再乘以0.3)=今天的多方線
突破多方線上方一點點,或空方線下方一點點,則進場做多或是放空,收盤前清倉。
william好像沒提到具體的出場方法,所以我自己設成尾盤時間到了,或是價格反向突破多方線或是空方線也清倉
一點只做多一次

可以請大大幫我看看我哪裡寫錯了嗎?
圖上看有些應該會引發訊號卻沒有訊號,好怪
input:factor(0.3);
vars:s(0),tobuy(9999),toshort(o),k(0);
value1=Highd(1)-LowD(1);
s=factor*value1;
k=k+1;
if time>0845 and time<=0900 then begin
toshort=highest(high,3)-s;
arw_new_self(d,0900,toshort,false);
tobuy=lowest(low,3)+s;
arw_new_self(d,0900,tobuy,true);
end;
if marketposition=0 and k=0 and time>0900 and t<1300 and c>tobuy then begin
buy next bar tobuy+1 stop;
k=1;
end;
if marketposition=0 and time>0900 and t< 1300 and c<toshort then begin
sellshort next bar toshort-1 stop;
k=1;
end;
if marketposition>0 and time >= 1340 then
sell next bar at market;
if marketposition>0 and C<toshort then
sell next bar at market;
if marketposition<0 and time >= 1340 then
buytocover next bar at market;
if marketposition<0 and C>tobuy then
buytocover next bar at market;



 樓主| 發表於 13-2-11 20:57 | 顯示全部樓層
有時該出現訊號沒有出信買進賣出動作
設定成一天只交易一次,結果有時一天出現好幾次交易
設定是收盤前全部出場
結果有時隔天尾盤才平倉
真不知道是哪裡搞錯了
發表於 13-2-11 21:05 | 顯示全部樓層
結算日當天時間只到1330,你的平倉時間設成1340之後,會在結算日隔天尾盤才平倉!

評分

參與人數 1金錢 +2 收起 理由
glaxo + 2 按一個讚

查看全部評分

 樓主| 發表於 13-2-11 21:11 | 顯示全部樓層
本帖最後由 glaxo 於 13-2-11 21:18 編輯

example

example
阿  對喔  我忘了結倉的因子
謝謝樓上大大
練習寫程式會撞牆 鬼打牆

請問可以幫我看看為何K線有突破紅線tobuy
卻沒出現動作呢
發表於 13-2-11 22:43 | 顯示全部樓層
為什麼版主剛開始要設定k=k+1?
有什麼義意?
 樓主| 發表於 13-2-11 23:10 | 顯示全部樓層
我弄錯了剛剛去爬文爬好久
應該是
if date[0]<>date[1] then k=0

if condiiton and k=0 then begin
buy...;
k=k+1;
end;

這樣應該就可以一天只交易一次了
學習程式交易之路真是挑戰
發表於 13-2-11 23:26 | 顯示全部樓層
當沖策略一定要最後一行加
setexitonclose;
否則回測結算日那天上會有留倉問題

評分

參與人數 1金錢 +2 收起 理由
glaxo + 2 按一個讚

查看全部評分

 樓主| 發表於 13-2-11 23:54 | 顯示全部樓層
在修改了一下
把出場設緊密一點
2007回測到現在
基本上是正成長
可以drawdown還頗大的
不知道還可以怎麼調整
還沒參數最佳化過
input:factor(0.3);
vars:s(0),tobuy(9999),toshort(o),k(0);

value1=Highd(1)-LowD(1);
s=factor*value1;

if date[0]<> date[1] then k=0;

if time>0845 and time<=0900 then begin
toshort=highest(high,3)-s;
arw_new_self(d,0900,toshort,false);
tobuy=lowest(low,3)+s;
arw_new_self(d,0900,tobuy,true);
end;

if marketposition=0 and k=0 and time>0900 and time<1300 and c>tobuy then begin
buy next bar at market;
k=K+1;
end;

if marketposition=0 and k=0 and time>0900 and time< 1300 and c<toshort then begin
sellshort next bar at market;
k=k+1;
end;

if marketposition>0 and time >= 1320 then
sell next bar at market;

if marketposition>0 and C<toshort then
sell next bar at market;

if marketposition>0 and C< entryprice(0)-20 then
sell next bar at market;


if marketposition<0 and time >= 1320 then
buytocover next bar at market;

if marketposition<0 and C> tobuy then
buytocover next bar at market;


if marketposition<0 and C>entryprice(0)+20 then
buytocover next bar at market;

setexitonclose;

 樓主| 發表於 13-2-12 00:34 | 顯示全部樓層
把k棒數從 3改成可變化的參數
發現0.1-1以及1-10都可以獲利
是否意味參數數值影響不大
交易邏輯追高殺低本身就具有獲利能力?

繼續探討
發表於 13-2-12 08:53 | 顯示全部樓層
謝謝分享!!
之前有看過類似的劃線圖..
剛好拿來研究一下!
 樓主| 發表於 13-2-12 09:24 | 顯示全部樓層
待會來試試政大的策略回春術
看能不能提升績效
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-4-29 20:47

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook