Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

data of candlesticks #244

Unanswered
sgs1 asked this question in Q&A
Discussion options

Hi guys!

I've read this in the manual.
"Within Strategy.init(), data arrays are available in full length, as passed into Backtest (for precomputing indicators and such). However, within Strategy.next(), data arrays are only as long as the current iteration, simulating gradual price point revelation. In each call of Strategy.next() (iteratively called by Backtest internally), the last array value (e.g. data.Close[-1]) is always the most recent value."

Now: I'd like to open a buy position only if the close price of the next candle is greater than the previous.
Can I do this? From the manual, I think that I cannot do it.
Thank you.

You must be logged in to vote

Replies: 1 comment

Comment options

This matches whenever the current value is greater than the previous:

 def next(self):
 if self.data.Close[-1] > self.data.Close[-2]:
 ...
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /