Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 8/16/2005(UTC) Posts: 182
|
Hi,
I need to have a protective trailing stop (not sure if I use the right word or not!), that moves to protect profit as price move favorably. The logic follows similar to Richard's ATS, but I have checked with him who confirmed that it is not possible to code the stop that I want.
Say for Long, with price is higher than the entry price (BPx) by 100, change the stop to entry price (BPx) + 5 (to cover commission and etc), and than if price reaches to the level of entry price (BPx) + 2*ATR(10), change the trailing stop to H-3.5*ATR(10). Please see the following:-
LE:=buy signal;
BPx:= to be defined;
InitBStop:=to be defined;
When PX hits BPx + 100 (# can be amended) ---> Stop changes to BPx + 5 (to cover comissions etc);
When Px hits BPx + 2*ATR(10) ---- > Stop moves to H-3.5*ATR(10);
This is similar to Ricard Dales’s DLL's example with pyramid points http://203.9.111.135/advancedstop/advancedstop.html which has added to move to next pyramid stop when next level of px hit e.g. BPx + 4*ATR(10)}
SE:=sell signal;
SPx=to be defined;
InitSStop:=to be defined;
When Px hits SPx -100 -----> Stop moves to SPX - 5 ;
when Px hits SPx - 2*ATR(10) ---- > Stop moves to L +3.5*ATR(10);
Can anyone show me how to do it?
Sa
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Hi sa,
I have been doing a little bit of playing around with this idea in the MSFL and could not get anything useful working without a bucket-load of PREVs. This obviously has a dramatic effect on the speed of execution and makes the system almost useless.
Written as an external function, just like Richard has done with his excellent but very generic version of Advanced Trailing Stops, a customised external function solution might be the way to go...
wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 8/16/2005(UTC) Posts: 182
|
Hi Wabbit,
I am glad that you have been playing around with this idea. Well, I think this idea is not new, and in fact, is quite generic, like the exit criteria as set in Rickey Cheung's book, The Trading Edge - How to Trade Like a Winner. He used the TradeStation language to write the formula for testing.
Well, I am quite surprised that there appears to be quite difficult to code the exit idea in Metastock. Even with the code with a bucket-load of PREVs, it could test the idea of the stop loss (as a protective stop). It appears to be difficult to apply the code in realtime trading (assuming a realtime trading platform has been set). The reason why I say this - when Ms is set with "Enable real-time to recalculate expert live", it will issue signal repetitively on the signal bar (say if a 5-min chart is used) when realtime data is updated during the 5-min.
Anyway, I really want to see how the trading performance of my system after applying the exit strategy.
Would you be kind enough to look at it and see if you have time to develop an external DLL?
BTY, is there any trick to tackle it, say with an external DLL to "remember" respective entry prices? Once the respective entry prices are stored / remembered and could be 'referred', it would be easy to write the exit code, right?
Sa
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
sa, I use trailing stops in my own trading where the stop gets tighter the longer the trade has been open with low volatility, so even if the trade plateaus I will eventually receive an exit. It suits some of my trades quite well. I also have a ratchetted stop that adjusts the stop at various points along the way, based on time and/or volatility combined with profitability. It works OK for me but often gets me out of a trade sooner with a small-medium profit even if the stock continues to climb, so its needs some tweaking and/or combining with other factors. A lot of people have troubles with real time charts having alerts generated on the individual ticks that are compiled together to form the last bar. Again, using a .dll there are a couple of ways to deal with the last bar: count the number of times a signal has been generated on the last bar, if an alert has been already been made on the last bar, then ignore all future signals until a new bar is formed, or wait until the bar is complete before generating any alerts at all (this can be achieved in MSFL by ignoring the last bar. When a new last bar starts, calculate the entry signals for the now-closed-second-to-last bar on the chart. It doesn't describe too well in text, it needs pictures, but its easier externally than in MSFL.) spaceant wrote: is there any trick to tackle it, say with an external DLL to "remember" respective entry prices? It is possible to some work with Mark's Global Variables .dll, but again, this involves some fiddling around. Please contact me via skype/email if you want to discuss a custom solution. wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 8/16/2005(UTC) Posts: 182
|
wabbit wrote: A lot of people have troubles with real time charts having alerts generated on the individual ticks that are compiled together to form the last bar. Again, using a .dll there are a couple of ways to deal with the last bar:
count the number of times a signal has been generated on the last bar, if an alert has been already been made on the last bar, then ignore all future signals until a new bar is formed, or
Can you show us how to do it?
Sa
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
In the programming language of your choice, write an external fuction:
detect the new bar reset the alertCounter to zero
if (new alert signal generated on this tick) increment alertCounter
if(alertCounter>1) return -alertCounter else return alertCounter;
This will return 0 if no alerts have been generated on the final bar, 1 on the first alert generated on the last bar, -2 on the second alert, -3 on the third alert etc....
Hope this helps
wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 8/16/2005(UTC) Posts: 182
|
Hi Wabbit,
Thanks for your reply, but I am unable to write an external dll. Is there anything that I can used, that is available, in the forum now?
Before having a custom solution with an external dll, I would like to test the stop ideas to see the performance. Therefore, it would be a next step to me.
It is possible to some work with Mark's Global Variables .dll, but again, this involves some fiddling around.
Can you demonstrate it?
I thik of it these few days. The GV dll is required to remember the "first" long / short signal, not the next ones before exit signals are issued. Is that the trick required?
Would this menthod be "efficient" in terms of operation as it requires no PREV?>
Sa
p/s I sent u an e-mail
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
sa,
Email not received. Please resend.
wabbit [:D]
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.