Professional Documents
Culture Documents
Usd JPY Bot
Usd JPY Bot
def __init__(self):
self.ichimoku = bt.indicators.Ichimoku()
self.stop_loss_price = 0
self.take_profit_price = 0
self.take_profit_count = 0
def next(self):
if not self.position:
if self.ichimoku.tenkan > self.ichimoku.kijun:
self.buy()
self.stop_loss_price = self.data.close[0] * (1 -
self.params.stop_loss)
self.take_profit_price = self.data.close[0] * (1 +
self.params.take_profit)
self.take_profit_count = 0
else:
if self.ichimoku.tenkan < self.ichimoku.kijun:
self.sell()
elif self.data.close[0] < self.stop_loss_price:
self.sell()
elif self.data.close[0] > self.take_profit_price:
self.take_profit_count += 1
if self.take_profit_count >= 10:
self.sell()