電子信箱 service [at] bituzi.com
幣圖誌首頁 facebook粉絲團 google plus google plus


返璞歸真之價格通道當沖交易解析



上星期告訴大家如何回到自己的原點來尋找新的交易靈感,也舉了很簡單的當沖程式當作例子,讓大家知道,即便是很簡單的想法,都有獲利的潛力。想必大家也很有興趣是如何撰寫出來的,尤其是新手,這種簡單的交易策略,是最容易上手的。今天就來解析如何利用價格通道的原理,來應用於當沖策略。

什麼是價格通道?


對於不熟悉程式交易的人來說,說價格通道可能會有些陌生。不過大部分的人應該都知道,最簡單的價格通道就是利用最近N根K棒的最高點與最低點當作上下通道。也就是說取最近N根K棒的最高點-Highest(high,N)當作上通道,N根K棒的最低點-Lowest(low,N)當作下通道。一般來說,當價格突破上通道時,就進場做多;當價格跌破下通道時,就進場做空。這是很簡單的價格通道設定方式,對於新手來說,應該也是很容易上手。

把價格通道轉換成進場方式


想必有按時閱讀獵人專欄的人應該都知道如何把價格通道轉換成進場方式了吧!其實很簡單,只要在原本設定進場的指令動些手腳就可以了。舉例來說:原本你習慣設定下根K棒以市價進場,也就是Buy(SellShort) next bar at market;。替換成最近N根K棒的最高或最低點進場,也就是Buy next bar at Highest(high,N) stop;
SellShort next bar at Lowest(low,N) stop;。所以獵人常在文章裡面說,破最近N根K棒的高點或低點進場,就是上面的用法喔!那上星期的程式到底怎麼寫呢?



價格通道當沖策略


撰寫一個訊號時,最重要的就是先設定參數與變數,參數是可以用來最佳化使用的,變數只是數值的暫存值而已。所以價格通道當沖策略的參數就是N根K棒的N,這樣你也可以自行在K線圖中變化你想使用的N值。所以要先設定inputs:N(20);,20是自行預設的數值,你可以自行選擇。而這個策略的主軸在於進場部分,要怎麼寫呢?參考如下:
IF T >= 0900 AND T <= 1200 THEN BEGIN
IF MARKETPOSITION=0 AND X=0 THEN begin
BUY NEXT BAR AT HIGHEST(H,N) STOP;
IF MARKETPOSITION=0 AND Y=0 THEN
SELLSHORT NEXT BAR AT LOWEST(L,N) STOP;
END;
當然進出場的時間上面只是舉例,不一定要設定9點跟12點,讀者可以設定自己喜歡的時間。而X跟Y分別代表多與空的進場次數,這樣的設定是限制當天多空只能各進場一次,避免過度交易的產生。那要怎麼計算進場次數呢?簡單的方式如下:
MP=MARKETPOSITION;
IF MP[1]=0 AND MP > 0 THEN X = X+1;
IF MP[1]=0 AND MP < 0 THEN Y = Y+1;
這邊使用MP來儲存目前的部位狀況,也就是MARKETPOSITION。MARKETPOSITION=1,就表示持有多單;MARKETPOSITION=-1,就表示持有空單;MARKETPOSITION=0,就表示空手。所以IF MP[1]=0 AND MP>0 THEN X=X+1;就表示做多一次,X就會累加一次,同理,Y也是。所以你要放寬多空進場次數的話,可以調整主程式的X與Y的限制範圍。




如此一來,程式的主軸就完成了,有沒有很簡單呢?有興趣的人可以試試看,當然你還可以加入自己的想法進去改寫,也許會寫出屬於自己的好程式喔!
獵人要在這邊告訴剛踏入程式交易領域的人,其實撰寫交易策略沒有這麼困難,困難的是你有沒有持續用心去寫,多寫才會熟悉語法跟指令,這樣才能培養把自己的想法轉換成程式語言的能力。因為寫程式交易最難的就是如何把交易想法傳換成程式語言,唯有不斷的練習與嘗試才有辦法更加精進。如果大家對本篇文章完整的程式碼有興趣的話,請多支持分享,並到此 回覆區留下資料,獵人會在分享數破100後,分享程式碼給大家練習參考。

希望本周的程式語言教學對於想進入程式交易領域的人會有幫助,也希望大家繼續支持獵人的專欄,獵人才有動力分享更多心得給大家喔!

撰寫程式交易最難的就是如何把交易想法傳換成程式語言,唯有不斷的練習與嘗試才有辦法更加精進。


除了網誌,幣圖誌每天還會在 Facebook 分享許多資訊,歡迎追蹤

19 意見:

匿名 提到...

Anyone know you to be able to commit the misconduct charged with website?
You won't know that until you have a nice long chat with a truck auto accident attorney, though.

Also visit my homepage - gsa search engine ranker

匿名 提到...

However, the results pertaining to free translation solutions may not exist completely precise.


Here is my web page: gsa search engine ranker

匿名 提到...

Upkeep careers depend at the success of utilizes they
manage. The positive attitude can give you energy and causes
you to be appreciate your life as it can be.



Feel free to surf to my web blog - gsa search engine ranker

匿名 提到...

And if you mulch all of your garden adequately, then you won't need to finally water the vegetables as often. Is it possible to cure diseases by using this law?

Here is my web-site; gsa search engine ranker

匿名 提到...

Evacuation orders inside Port Deposit also has kept most persons out
of city. All you should do can look for these kind of
indications.

Check out my weblog: gsa search engine ranker

匿名 提到...

You produce the choice to select what you motivation. Most included such luminaries as the Natural Roses, the Inspiral Carpets, and the entire Happy Mondays.


Look into my webpage gsa search engine ranker

匿名 提到...

I drоp а leaѵе a гesponse when Ι liκe a ρоst on a site
ог Ӏ hаve somеthing to contribute to the conversation.

Uѕuallу it is саusеd by the passion сommunісated
in the poѕt I browseԁ. Αnd on thіs ρoѕt "返璞歸真之價格通道當沖交易解析".

I waѕ exсіteԁ enοugh to drоρ
a cοmmеnt :-P І do have a few questіons fοr уou іf yοu uѕually ԁο not mіnԁ.
Coulԁ it bе just me οr ԁo a few of the
геmarks appeаr like wгіttеn by bгain dеаd ρeople?

:-P And, іf уοu агe writing on аdditional
plaсes, I would liκe to keeρ up wіth eѵеrything fгesh you have to pоѕt.
Wοuld you list eѵery one of аll your сommunity pages like your
tωitter fеed, Faсeboοk
page οг linκedin ргоfile?


Hеге is my page ... Some great benefits of Specialist Hotels

匿名 提到...

To start with, you require loading the files such as to mix directly distinct locations.
Canada boasts Hank Snow, Shania twain and Anne Murray.


Visit my page gsa search engine ranker

匿名 提到...

In 2 era or less lectronic your life stops without water. "Actually I had geared up on staying, sadly the fumes hailing from all the cracked oil tanks...

Take a look at my homepage :: gsa search engine ranker

匿名 提到...

Woω, awesome blοg layout! How long haѵe yοu
evеr beеn running a blog for?
you maκe blogging look eaѕy. The οѵerall
lοoκ of your sitе iѕ great, aѕ smartly
aѕ the content material!

Heгe іs my web blοg :: Bauchmuskelübungen

匿名 提到...

How of them performed actually lend individual to sexual depiction of Juggalettes?

Garth Brooks springs to be able to mind immediately.

Feel free to surf to my homepage ... gsa search engine ranker

匿名 提到...

It again has natural capability to cure the biochemical imbalances the fact
that causes many factors. Large stools are better provided they
actually are not hard.

my web blog gsa search engine ranker

匿名 提到...

The Universe can be not going to set your complication right magically.
This has been where a regular marketplace comes to rescue.


Also visit my blog post gsa search engine ranker

匿名 提到...

This piece of writing provides clear idea for the new viewers
of blogging, that really how to do running a blog.




payday loan online

匿名 提到...

Online lenders do not have a application fee when compared
to regular lending companies.

Take a look at my blog post ... gsa search engine ranker

匿名 提到...

Gгeat blog! Is your themе custom made or
diԁ you download іt from somewhere?
A theme like yours with a few simple aԁjustеments would rеally make mу blog
јump out. Pleаsе lеt me knoω where you got your design.
Μanу thanks

Heгe is my homeраgе: Motel Price tag Comparison Compared to Traditional Take a trip Search Sites - Resorts Savings

匿名 提到...

Online lenders do not have a application fee when compared to regular lending companies.


Here is my blog post ... gsa search engine ranker

匿名 提到...

Good web site you have got here.. It's hard to find excellent writing like yours these days. I honestly appreciate individuals like you! Take care!!

Also visit my blog post Green coffee cleanse info

匿名 提到...

Hello, constаntlу i uѕed to check ωeb site рoѕts hеre in thе early
hours іn the daylight, for the гeason that
i enϳoу to learn mοre and mοre.


Here is my wеbpаge ... rеservation hotеls
()