Re: [問題] 請教TS語法

看板Trading (金融交易)作者 (愛情 VS 人生)時間15年前 (2010/08/26 13:51), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/3 (看更多)
※ 引述《chmchm (123)》之銘言: : 這是寰宇TS程式交易全攻略的例題 : 我覺得怪怪的 : 還請大家不吝指教 : --------------------------------------------- : Q:買進後以買進價-20點設為停損, : 若是買進後沒觸及停損而拉開獲利 : 當獲利大於50點時,則將停利設為買進價+20 你說的邏輯,與下面的程式碼有些差異… If MarketPosition = 1 Then Begin If Close > (EntryPrice + 50) then ExitLong Next Bar at EntryPrice + 20 Points Stop else ExitLong Next Bar at EntryPrice - 20 Points Stop; end; If MarketPosition = - 1 Then Begin If Close < (EntryPrice - 50) then ExitShort Next Bar at EntryPrice - 20 Points Stop else ExitShort Next Bar at EntryPrice + 20 Points Stop; end; : A: If MarketPosition = 1 Then Begin : ExitLong Next Bar at EntryPrice + 50 Points Stop; : ExitLong Next Bar at EntryPrice - 20 Points Stop; : end; : If MarketPosition = - 1 Then Begin : ExitShort Next Bar at EntryPrice - 50 Points Stop; : ExitShort Next Bar at EntryPrice + 20 Points Stop; : end; 我沒試過這種寫法,不知道結果如何… 按 EL 的說明, STOP 觸發在較指定價位更不好的位置,所以 Buy at 7700 Stop 觸發在7700以上 (和 ExitShort 意同) Sell at 7700 Stop 觸發在7700以下 (和 ExitLong 意同) 原文如下: ● Stop orders can only be executed on the next bar. ● Stop can be read as "this price or worse", meaning higher for a Long Entry and Short Exit, lower for a Short Entry and Long Exit. ● Stop orders require a reference price. 希望對你有些幫助。 : 對於他的寫法 我感到有點奇怪與不解 : 請大家不吝指教 : 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.85.209.218

08/26 14:52, , 1F
邏輯蠻正確的 感謝^^
08/26 14:52, 1F
文章代碼(AID): #1CTW343X (Trading)
討論串 (同標題文章)
本文引述了以下文章的的內容:
5
8
完整討論串 (本文為第 2 之 3 篇):
5
8
文章代碼(AID): #1CTW343X (Trading)