1) varBars = BarsSince(buy); // bars since buy varPrice1 = IIf(varBars<2, C, Ref(C,-varbars)); // find buy price varDirection = C>Ref(C,-varbars); // 1 if profitable trade varProfit = IIf(varBars<2, 0, IIf(varDirection,C-varPrice1,varPrice1- C)); varClose = varProfit; // close trade if profitable
This is off the top of my head. Probably inefficient but you get the idea. Use varClose (=1) to trigger your close in whatever way you want. ~B --- In [email protected], "supistarde" <[EMAIL PROTECTED]> wrote: > > Hello community, > > I have two questions: > > 1) how can i program that a trade is closed after x days (for example > 15 days) when the profit is minor than x percent? I tried several > options but none worked in portfolio backtest. The position was > sometimes closed after 15 days and sometimes not. Do not know why. > > 2) I do not want to enter a position if a huge gap appeared in the > last 30 bars. How can I program this? > > Thanks! > 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 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:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
