### Author Topic: count bars intrade combined with dual sell signal  (Read 1974 times)

#### gerard

• Newbie
• • Posts: 1 ##### count bars intrade combined with dual sell signal
« on: July 17, 2017, 07:25:48 am »
Hi

I am looking for some help. I would like to create a sell signal which is based on the number of days in a trade. I have found some code how to count the number of days but now I have to adjust it to what I want and I am unable to solve this puzzle . The code below is not working, as I think I am not coding in the right order ( and also want to count properly with days in trade)
Code: [Select]
`// Sample system// Buy RSI(2) is smaller than 20// Sell if number of days  intrade < 10 AND RSI(2)>70// Sell if Number of days intrade => 10 and RSI(2) > 90Buy =  RSI(2) < 20;Sell = (BArsintrade < 10 AND RSI(2)> 70) or (BArsintrade => 10 AND RSI(2)>90)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   // dont understand how I can remove sells occurring too soon  if( Sell[ i ] ) BarsInTrade = 0; // on sell reset barsintrade flag}`

Any help is highly appriciated!

Thanks

Gerard
« Last Edit: July 18, 2017, 02:08:25 am by administrator » `Buy =  RSI(2) < 20;Sell = (BarsSince(Buy) < 10 AND RSI(2) > 70) OR (BarsSince(Buy) >= 10 AND RSI(2) > 90);`