Kraniv:In indicator builder, how would I program a basic trailing stop. In pseudo type language
( after buy signal put a stop 20 ticks below low of last 3 bars, then after 1 period put stop 20 ticks below the low)
so in a uptrend, the stop would be 20 ticks below the low of the previous bar. hope this makes sense, any help would be appreciated
First you need some code to identify when the buy signal occurred. Later you might think you need some latching, but now let us just assume you don't.
buy:={some logic goes here};
Next, you need to find the lowest low on the bar when the entry was true, and then subtract 20 points:
initialStop:=ValueWhen(1,buy,L)-20;
You have defined the trailing component as the previous bar low minus 20:
trailingStop:=Ref(L,-1)-20;
This is where things start to get interesting because you haven't mentioned that the stop loss can only move in the favour of the trade, so you might consider something like this:
stop:=if(barssince(buy)<=1,initialStop,highestsince(1,buy,trailingStop));
Anyway, I hope you have enough ideas to formulate your own codes?
Hope this helps.
wabbit
"The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
Edsgar W. Dijkstra
MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
For custom MetaStock programming : http://www.wabbit.com.au
My SkyPE status : 
My SkyPE account : wabbit.com.au