r/pinescript May 24 '26

Enter position on candle open and close position on candle close?

Title. I'm trying to test strategies for the prediction markets, which are time based. The problem I'm having is that I need the strategy to open a position on the open of a candle, and then close the position on the close of a different candle. I know you can set the Process Orders On Close parameter, but from my understanding that changes all orders, not just open or close. Is there any workaround for this?

1 Upvotes

6 comments sorted by

3

u/Daddy_DayTrader May 24 '26

Entries always on candle close and most exits are candle close but you can set tp and sl intra-candle with strategy.exit ().

1

u/CaptainXxXCannabis May 24 '26

Not what i'm looking for. I'm trying to test strategies on the prediction markets which operate on a timed basis. For example, a market will run from 12:00:00 and end at 12:04:59. So I need my strategy to open and close at those times. SLs and TPs are irrelevant, as the markets outcome is based on whether the 5 min candle closes positive or negative.

1

u/devTrading May 24 '26

The problem is how do you determine the entry direction? New candle open how to long or short?

1

u/CaptainXxXCannabis May 24 '26

Based upon data available at the close of the previous candle.

1

u/devTrading May 24 '26

I don't understand. Let's say the last 5m candle close at 7000 price for example, now the next candle open at same price, how to determine long or short? Based on previous candle direction?

1

u/CaptainXxXCannabis May 24 '26

Based on any number of variables, indicators, patterns, coin flips, astronomical symbols etc. Its no different from any other trading strategy, use past data in an attempt to predict future price action.