@Jalal-Ahmadi Hi.
What do you mean "for optimization"?
Yes, it works.
Nikolai
@Nikolai
Quant developer.
Python / MQL5.
Posts made by Nikolai
-
RE: Metaquotes MQL 5 - API
-
RE: Metaquotes MQL 5 - API
Hi, everyone. New update of both repos.
All goals in
MQL5-JSON-API
was done.
Pending orders inBacktrader-MQL5-API
was finished.
We will start production testing next week. -
RE: Metaquotes MQL 5 - API
New update of both repos.
MQL5 JSON API
is finished. Historical data load speed was optimized. I have to finish various features like:- expiration
- deviation
- hedging
- error handling docs
- etc.
Reconnection and data uploading after reconnection were added to
Backtrader-MQL5-API
The main goal for now is to finish pending orders management. -
RE: STOP TRAIL order questions.
@ciceron hi again.
I was wrong. Oanda broker has StopTrail implementation.if order.exectype == bt.Order.StopTrail: okwargs['distance'] = order.trailamount
https://github.com/ftomassetti/backtrader-oandav20/blob/master/btoandav20/stores/oandav20store.py
I didn't have any practice with Oanda broker, so i don't know how stoptrail works on Oanda side. But your understanding is correct for backtesting.
-
RE: STOP TRAIL order questions.
Hi Ciceron.
As i see Oanda broker doesn't have trailing stop implementation. Only:
# Order type matching with oanda _ORDEREXECS = { bt.Order.Market: 'MARKET', bt.Order.Limit: 'LIMIT', bt.Order.Stop: 'STOP', bt.Order.StopLimit: 'STOP', }
https://github.com/ftomassetti/backtrader-oandav20/blob/master/btoandav20/stores/oandav20store.py
-
RE: Metaquotes MQL 5 - API
Hello everyone,
I have released
Backtrader-MQL5-API
stable beta. MQL5 has complex order management logic, so i have some headache implementing it tobacktrader
. )) Only market orders working right now. It will take some time to finish pending orders.self.position
doesn't work too. Because of threadingnext
happens several times before position approval returns from MQL5. @backtrader Do you have any idea how to fix it? Thanks. -
RE: Problem with Bracket Order
Hi. I think that you should add
exectype
param.p1 = 100 p2 = p1 - 0,01 * p1 p3 = p1 + 0,01 * p1 self.buy_bracket(price=p1, stopprice=p2, limitprice=p3, exectype=bt.Order.Limit)
-
RE: Metaquotes MQL 5 - API
I have released stable beta
MQL5 JSON API
. Most part of the documentation is also ready. See it on github.Backtrader MQL
broker stable beta is almost ready too. Don't use alfa release of the broker. The code would not work because MQL side was refactored. -
RE: Stochastic RSI indicator.
@Tomas
Hi. I wrote an example strategy for you. You can access the indicator lines through the name in__init__
method.class CryptoStochRSI(bt.Strategy): params = ( ('stoch_k_period', 3), ('stoch_d_period', 3), ('stoch_rsi_period', 14), ('stoch_period', 14), ('stoch_upperband', 80.0), ('stoch_lowerband', 20.0), ('take_profit', 0.04), ('stop_loss', 0.01), ('size', 20), ('debug', False), ) def __init__(self): self.stoch = StochasticRSI(k_period=self.p.stoch_k_period, d_period=self.p.stoch_d_period, rsi_period=self.p.stoch_rsi_period, stoch_period=self.p.stoch_period, upperband=self.p.stoch_upperband, lowerband=self.p.stoch_lowerband) def next(self): if not self.position: close = self.data.close[0] price1 = close price2 = price1 - self.p.stop_loss * close price3 = price1 + self.p.take_profit * close if self.stoch.l.fastk[0] < 20: self.buy_bracket(price=price1, stopprice=price2, limitprice=price3, exectype=bt.Order.Limit) if self.stoch.l.fastk[0] > 80: self.sell_bracket(price=price1, stopprice=price3, limitprice=price2, exectype=bt.Order.Limit)