How can I get more trades with this strategy?

Hello. My idea is to buy stocks, when the closing price is higher than the opening price and the stock is in a range between 10 and 0 zero percent under the All Time High. If I test the following code with the S&P 500 stocks, I get only 117 trades from the year 2000 until 2022. So, I think, that I have done a mistake with the All time high filter. What can I improve that it will work correctly?

HighestValue 		= Ref(HHV(High,99999),-1);
ATHfiltero90		= C > (HighestValue*0.90);

Buy = C > O AND ATHfiltero90;
Sell = 0;

SL= Optimize("SL", 10, 2, 10, 1); // 10% loss
ApplyStop( stopTypeLoss, stopModePercent, SL, True);

TP = Optimize("TP", 10, 2, 10, 1); // 10% profit
ApplyStop( stopTypeProfit, stopModePercent, TP, True);

For example change position size.

HighestValue 		= Ref(HHV(High,99999),-1);
ATHfiltero90		= C > (HighestValue*0.90);

SetPositionSize(1, spsShares);
//SetPositionSize(10, spsPercentOfEquity);

Buy = C > O AND ATHfiltero90;
Sell = 0;

SL= Optimize("SL", 10, 2, 10, 1); // 10% loss
ApplyStop( stopTypeLoss, stopModePercent, SL, True);

TP = Optimize("TP", 10, 2, 10, 1); // 10% profit
ApplyStop( stopTypeProfit, stopModePercent, TP, True);
1 Like

Acording your comment, I added

SetOption("MaxOpenPositions", 100);
SetPositionSize(1, spsPercentOfEquity);

And now I get more than 11.000 Trades :wink: I'm new to AmiBroker and I think, there is a lot to learn for me. Many thanks to you.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.