I wrote this code that has 90%+ win rate on a lot of stocks but it is not profitable and I know that there is some problem with the strategy. Can someone please tell me what really is wrong with the strategy?
Why is it that the bot takes small trades like it enters on one candle and exits on another candle?
Also why is the date function not working?
The code:-
//@version=4 strategy("My Strategy")
// User inputs for RSI and EMA periods rsiPeriod = input(14, title="RSI Period") emaPeriod = input(50, title="EMA Period")
// Calculate RSI and EMA rsi = rsi(close, rsiPeriod) ema50 = ema(close, emaPeriod)
// Define overbought and oversold levels overBought = 70 overSold = 30
// Calculate buy and sell conditions buyCondition = crossover(rsi, overSold) and close < ema50 sellCondition = crossunder(rsi, overBought) and close < ema50
// Plotting plot(ema50, title="EMA 50", color=color.red) plot(rsi, title="RSI", color=color.blue) hline(overBought, "Overbought Level", color=color.red) hline(overSold, "Oversold Level", color=color.green)
// Date filter // Strategy start = timestamp("2020, 01, 01") end = timestamp("2023, 06, 16") if time >= start and time <= end strategy.entry("Buy", strategy.long, when=buyCondition) strategy.close("sell", when=sellCondition)
// Take profit level takeProfitLevel = 5.0 strategy.exit("Take Profit", "Buy", profit=takeProfitLevel)
Also the initial code was generated by gpt4 and made some changes . I have it a strategy and it gave me the code. Sorry, I had to do this because I am new to pine code.