大家好,我想写一个trailing stop 的程序,在tradestation上。不知道哪里出了问题,麻烦帮我看看好么? 我大概的要做的是:在2011。3。17的时候long 100 share 的SPY,然后设置一个sell trailing stop, 这个trailing stop 是以highest high 为参照 (1-a%)highest high 为 trigger price的。 就是要写这个trailing stop 的easylanguage。 这是我的写的 Input: stoplosspct(.05); Variables: sellstop(0), hdlenght(0); {hdlenght represents the lenght we hold the stocks} {buy shares} If Date =1110316 Then buy ("buy") next bar at market; {trailing stop} hdlenght = Barssinceentry (1); If Marketposition = 1 { this is trailing command} Then sellstop = Highest (High, hdlenght) - stoplosspct*Highest (High, hdlenght); If marketposition = 1 and high <= sellstop {this is exit command} Then sellshort next bar at market; 问题可能弱了点~。 但是才是第二天接触tradestation,所以多包涵下哈。 大家帮我看看吧~。谢谢了
然后我一运行 charting 的左上角就有个灰色的 SA标志 好像是代表 strategy automatically disabled ~。。。。 以前还能标出 buy 只是没出场标志 现在啥都没有了
刚看了个网站上的例子,从新下了下。貌似可以出来了 但是知道对不对。 Input: stoplosspct(.005); Variables: sellstop(0), poshigh(0); {buy shares} If Date = 1110316 then Buy ( "Buy" ) next bar at market ; {trailing stop} If Marketposition = 1 Then begin If Barssinceentry = 0 then poshigh = high; sellstop = poshigh - stoplosspct*poshigh; if Barssinceentry > 0 and High > poshigh Then poshigh = high; sellstop = poshigh - stoplosspct*poshigh; If high < sellstop then Sellshort ("sell") next bar at sellstop stop; end; 还有个问题就是 这个方法是用poshigh 去记录历史最大high的 但是函数 highest(price, lenght) 在这里怎么用啊? 貌似highest(H, barssinceentry) 总是出不来正确的highest 的值啊 是在不懂 barssincerentry 怎么用 找了好几本书 讲的都叫人不怎么懂啊。。。 前辈们给我讲讲吧