samuraitaiga / py-metatrader

metatrader library for metatrader
Apache License 2.0
90 stars 48 forks source link

Demo Problem #15

Closed vtgandalf closed 5 years ago

vtgandalf commented 5 years ago

Hello everybody,

I am new to metatrader and your package so I started from trying to run your sample code on my set up environment which has: python 2.7 metatrader beautifulsoup4

The sample code: import datetime from metatrader.mt4 import initizalize from metatrader.backtest import BackTest

initizalize('C:\Program Files (x86)\MetaTrader 4 IC Markets')

from_date = datetime.datetime(2014, 9, 1) to_date = datetime.datetime(2015, 1, 1)

ea_name = 'Moving Average'

param = { 'Lots': {'value': 0.1}, 'MaximumRisk': {'value': 0.02}, 'DecreaseFactor': {'value': 3.0}, 'MovingPeriod': {'value': 12}, 'MovingShift': {'value': 6}, 'ModelingQualityPercentage': {'value': 90} }

backtest = BackTest(ea_name, param, 'USDJPY', 'M5', from_date, to_date)

ret = backtest.run()

print(ret.gross_profit)

After I run it the metatrader program runs for a little bit and after that it closes and I get the following error message:

Traceback (most recent call last): File "sample_trading.py", line 27, in ret = backtest.run() File "C:\Users\vtgan\Documents\MetatradingProject\Python\Sample\py27env\lib\site-packages\metatrader\backtest.py", line 154, in run ret = BacktestReport(self) File "C:\Users\vtgan\Documents\MetatradingProject\Python\Sample\py27env\lib\site-packages\metatrader\report.py", line 101, in init self.modeling_quality_percentage = float(modeling_quality_percentage_str) ValueError: could not convert string to float: n/a

If you could help me out that would be lovely :)