AminHP / gym-mtsim

A general-purpose, flexible, and easy-to-use simulator alongside an OpenAI Gym trading environment for MetaTrader 5 trading platform (Approved by OpenAI Gym)
MIT License
412 stars 101 forks source link

Should use open price instead of close price #35

Closed luxiaolei closed 1 year ago

luxiaolei commented 1 year ago

Hi HP,

Thanks for ur great project, just a thought on line 85 of mt_simulator.py

    for order in self.orders:
        order.exit_time = self.current_time
        order.exit_price = self.price_at(order.symbol, order.exit_time)['Close'] # Should be Open price
        self._update_order_profit(order)
        self.equity += order.profit

I think you meant open price? because the candlestick is timed at the open time of the bar.

AminHP commented 1 year ago

Hi @luxiaolei ,

The actual value at the time of trading is somewhere between High and Low prices. However, due to the simulation limits, an approximate value (such as Close and Open price or even (Close+Open)/2) can work. You can choose what most suits you.

luxiaolei commented 1 year ago

I see, thanks:)