0

In a Pine script, I am running dca strategy within 1 minute time frame. When the RSI Deviation occurs in a different time frame (for example, 1 hour), I want the position not to be opened until the certain candle period ends (for example, 40 minutes). How can I do that

Thank you

1 Answers1

0

You can do a manual check the time of the current candle in the different time frame and only open a position if the candle has completed.

timeFrame = 40m
timeRSIDeviation = 60m

timeFrame = time(timeFrame)
timeRSIDeviation = time(timeRSIDeviation)
currentTime = timestamp()
rsiDeviationOccurred = (currentTime > timeRSIDeviation)

if (rsiDeviationOccurred and currentTime == timeFrame)
    strategy.entry("DCA", strategy.long)
Jishan Shaikh
  • 1,572
  • 2
  • 13
  • 31
  • Hello, thank you for your answer. but this is not the correct answer. my question: I want to stop position entries for a certain candle time after RSI Deviation occurs. I know this but I can't apply it "if entry and not (bar_index - rsiDeviationOccurred >= 40)" – turkprinting Dec 09 '22 at 20:31
  • How do I set the variable "rsiDeviationOccurred"? – turkprinting Dec 09 '22 at 20:41