Hi,
This one is from Mr. Janeczko, he put it online as an example, but I cannot find the link. Replace buy/sell,etc. witch your rules, the rest is pretty much self-explanatory. Buy = MACD() > 0 AND RSI() > 30; Sell = MACD() < 0 OR Cross( 70, RSI() ); SetPositionSize(1,spsShares); // now we would like to ensure that position is NOT // exited during first MinHoldBars MinHoldBars = 17; // say don't want to exit for first 17 bars since entry // first filter out buy signals occuring outside testing range Buy = Buy AND Status("barinrange"); BarsInTrade = 0; for( i = 0; i < BarCount; i++ ) { // if in-trade, then increase bar counter if( BarsInTrade > 0 ) BarsInTrade ++; else if( Buy[ i ] ) BarsInTrade = 1; // on buy signal start counting bars-in-trade // if we are in trade - remove sells occurring too soon if( BarsInTrade < MinHoldBars ) Sell[ i ] = 0; else if( Sell[ i ] ) BarsInTrade = 0; // on sell reset barsintrade flag } printf("barsintrade:\n"); WriteVal(barsintrade); Greets, Matthias From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf Of JEFF F Sent: Donnerstag, 15. Juli 2010 00:41 To: amibroker@yahoogroups.com Subject: [amibroker] Hold a trade for a minimum # of bars Can anyone tell me how to hold a trade for a minimum # of bars (such as 3) before checking for a sell signal? I have tried settradedelay(0,3,0,0) but when i backtest, the trade still happens the next day. Same with changing the delay within the settings button. Any help is appreciated. Thanks