setting min period inside the strategy
-
Hello,
How can I set the first start candle inside the strategy. I found that this is done by setminperiod(minperiod) method. But I don't know how to set that inside a strategy. -
@siavash
minperiod
is set automatically (usually) as soon as all data has non-NaN
values. If you need to define the first bar of your backtest, then just check the date/time of the bars in thenext()
. If it is higher then your start date, then process your rules. -
I want to use for example 10 first candles inside the next method and after that sending order. I know that I can check date time inside the next method but it is so time consuming.
-
@siavash said in setting min period inside the strategy:
How can I set the first start candle inside the strategy I found that this is done by setminperiod(minperiod) method
@siavash said in setting min period inside the strategy:
I want to use for example 10 first candles inside the next method and after that sending order.
Both things have nothing to do with each other. If you want to skip
10
candles innext
, check the length of the strategy itself.@siavash said in setting min period inside the strategy:
I know that I can check date time inside the next method but it is so time consuming.
You are probably in the wrong business if you consider than programming something to make money automatically for you is time consuming.
-
I didn't understand your answer. What is time cosuming?????!!!! I mean that is there better way to set min period rather than using date time.
-
@siavash said in setting min period inside the strategy:
What is time cosuming?????
You said that it is time consuming.
@siavash said in setting min period inside the strategy:
mean that is there better way to set min period rather than using date time.
@backtrader said in setting min period inside the strategy:
... If you want to skip 10 candles in next, check the length of the strategy itself.
-
@backtrader
How can I skip. I dont know how?
I want to record 10 candles data and then send an order and save corresponding result in a text file. Also do this for remaining data. Could you please write code for help?🙏 -
@siavash said in setting min period inside the strategy:
@backtrader
How can I skip. I dont know how?
I want to record 10 candles data and then send an order and save corresponding result in a text file. Also do this for remaining data. Could you please write code for help?🙏if len(self) > (self.len_self_first_time_next_was_called + 10): # do something
Again: if things consider things to be time consuming and you can't write that simple code, you have to reconsider if you want to be in algotrading.