[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Trailingstop with different timeframe



PureBytes Links

Trading Reference Links

Hello everybody,

Cause programming is not my strongest point I hope someone can help 
me out with my problem. I have developed a 5-minute system. I have a 
static stoploss and stopprofit. But at this point I am testing it 
with realtime data I see often that a profit of for example 10 points 
on the Dow future disappears totally if the trend is turning, till my 
stop is hit. I would like to test if its not better to increase the 
stop, with for instance a trailingstop so that I will never lose such 
a profit anymore. When I put a trailingstop into my code it is 
backward looking cause it picks the high of the 5 minute bar. So this 
doesn't help me out. I will give a piece of my system so you can see 
how it is build up. I probably have to use the different timeframe 
function, but what of my code do I need to expand? I tried a lot but 
it didn't work.
So I hope one can help me out!

BTStartTime = ParamTime("Backtesting SOD","15:30:00");
BTEndTime = ParamTime("Backtesting EOD","21:40:00");
InSession = TimeNum() >= BTStartTime AND TimeNum() <= BTEndTime;

//My system here with several conditions like://
Cond2 = ADX(18) > 20 AND ADX(18) < 40;

//and a lot of reasons://
reason2  = Cross(StochK(4),50) AND cond1 AND NOT Cond7; 

Buysig  = reason2 OR reason3 OR reason4 OR reason5 OR reason6 OR 
reason7 OR reason8 ; 
Sellsig = reason10 OR reason11 OR reason12 OR reason13 OR reason14 OR 
reason15 OR reason16 ; 

Buy   = Sum(buysig,2) > Sum(Sellsig,2) AND insession; 

Short = Sum(buysig,2) < Sum(Sellsig,2) AND insession;  

Sell  = Sum(buysig,2) < Sum(Sellsig,2) OR TimeNum() >= BTEndTime; 
Cover = Sum(buysig,2) > Sum(Sellsig,2) OR TimeNum() >= BTEndTime;

Stop   = ApplyStop(stopTypeLoss,stopModePoint,Optimize("max. loss 
stop level",1.0,1.0,1.0,1.0),True,True,1 );
Profit = ApplyStop(stopTypeTrailing,stopModePoint,Optimize("max. 
profit stop level",1,1,10,1),True,True,1 );
SetTradeDelays(0,0,0,0);

PositionSize = 100 * 1;



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/