Page 1 of 2

Price prediction using machine learning

PostPosted: Wed Oct 03, 2018 5:37 pm
by JuliaS
You can use ForexConnect API in machine learning models.

The following sample scripts are available at github:

PricePredictionMLregressionMA.py
This sample script shows how to use Machine Learning in Python and how to predict prices by using Linear Regression.
The input of the regression model is three Moving Averages calculated based on close prices. The algorithm uses a linear model to minimize the residual sum of squares between the observed responses in the dataset and the responses predicted by the linear approximation.

PricePredictionMLregressionPrevious.py
This sample script shows how to use Machine Learning in Python and how to predict prices by using Linear Regression.
The input of the regression model is close prices of previous bars. The algorithm uses a linear model to minimize the residual sum of squares between the observed responses in the dataset and the responses predicted by the linear approximation.

PricePredictionMLClassification.py
This sample script shows how to use Machine Learning in Python and how to predict prices
by using Support Vector Classification.
The model divides objects into two groups: "the price will grow on the next bar" and "the price will fall on the next bar".
The input data for the model are Open-Close and High-Low. The model tries to define whether the price is growing or falling on the basis of the input data.

Re: Price prediction using machine learning

PostPosted: Tue Oct 30, 2018 2:17 pm
by SANTOSH
Hello Julias ,

I am not able to log in .
Can u give the sample of how to write the arguments after SAMPLE.PY.


I am talking about this :
Need to know how to write the arguments .

If Python is added to the PATH Environmental Variable,
to run the sample script, execute the following command in a console:
python <Sample.py> <Arguments>

I write like this following the above :
C:\Users\abc>PricePredictionMLRegressionMA.py -l D291033620, -p 9173, -u https:/
/tradingstation.fxcm.com/, -c DEMO


May be the fxcm server url is wrong .
I use the server -u https://tradingstation.fxcm.com/

u] Can u get me the exact fxcm server url to add to the arguments. [/u]



I get the following error as attached .


C:\Users\abc>PricePredictionMLRegressionMA.py -l D291033620, -p 9173, -u https:/
/tradingstation.fxcm.com/, -c DEMO
C:\Users\abc\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\ex
ternals\joblib\externals\cloudpickle\cloudpickle.py:47: DeprecationWarning: the
imp module is deprecated in favour of importlib; see the module's documentation
for alternative uses
import imp
Status: CONNECTING
Status: DISCONNECTED
Traceback (most recent call last):
File "C:\Users\abc\AppData\Local\Programs\Python\Python37\PricePredictionMLReg
ressionMA.py", line 120, in <module>
main()
File "C:\Users\abc\AppData\Local\Programs\Python\Python37\PricePredictionMLReg
ressionMA.py", line 64, in main
common_samples.session_status_changed)
File "C:\Users\abc\AppData\Local\Programs\Python\Python37\lib\site-packages\fo
rexconnect\ForexConnect.py", line 205, in login
use_table_manager, table_manager_callback)
File "C:\Users\abc\AppData\Local\Programs\Python\Python37\lib\site-packages\fo
rexconnect\ForexConnect.py", line 152, in _login
raise LoginFailedError(self._status_listener.last_error)
forexconnect.errors.LoginFailedError: Unable to parse descriptor data


Kindly help,
Regards,
Santosh Sahu.
Email - sahusantosh30@gmail.com

Re: Price prediction using machine learning

PostPosted: Wed Oct 31, 2018 11:37 am
by Alexander.Gettinger
FXCM server url: fxcorporate.com/Hosts.jsp

What version of Python do you have?

Re: Price prediction using machine learning

PostPosted: Wed Oct 31, 2018 2:56 pm
by SANTOSH
Thanks Alexander .
I will use the above fxcm server and give a try .

I use python 3.7 with all the forex connect requirements on it .

Regards ,
Santosh .

Re: Price prediction using machine learning

PostPosted: Thu Nov 01, 2018 4:54 am
by SANTOSH
Thanks Alexander ,
I get it to working .
Can log in and use the machine leaarning .py samples which are in fxcodebase .

=========================================================================
I tried the following and got success .
PricePredictionMLClassification.py
The model divides objects into two groups: "the price will grow on the next bar" and "the price will fall on the next bar".


C:\Users\abc>PricePredictionMLC.py -l D291033620 -p 9173 -u fxcorporate.com/Hos
ts.jsp -c DEMO
C:\Users\abc\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\ex
ternals\joblib\externals\cloudpickle\cloudpickle.py:47: DeprecationWarning: the
imp module is deprecated in favour of importlib; see the module's documentation
for alternative uses
import imp
Status: CONNECTING
Status: CONNECTED
C:\Users\abc\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\sv
m\base.py:196: FutureWarning: The default value of gamma will change from 'auto'
to 'scale' in version 0.22 to account better for unscaled features. Set gamma e
xplicitly to 'auto' or 'scale' to avoid this warning.
"avoid this warning.", FutureWarning)
Train Accuracy: 54.17%
Test Accuracy: 48.33%
Status: DISCONNECTING
Status: DISCONNECTED

=========================================================================
Have a question :
How can we use the above python script in live market to predict the next bar , meaning whats the way to use it in the live market ?


Regards ,
Santosh .

Re: Price prediction using machine learning

PostPosted: Fri Nov 02, 2018 1:46 pm
by Konstantin.Toporov
Similar sample is in our development queue.

Re: Price prediction using machine learning

PostPosted: Sat Nov 03, 2018 2:03 am
by SANTOSH
You mean to say ,
Python machine learning is only for back testing ?
Cannot apply it for alerts ?

Regards ,
Santosh.

Re: Price prediction using machine learning

PostPosted: Wed Nov 14, 2018 10:47 pm
by SANTOSH
Hello Everyone ,

Is there any way to use Machine Learning for Live market alerting or signalling ?

Regards,
Santosh Sahu.

Re: Price prediction using machine learning

PostPosted: Fri May 31, 2019 11:18 pm
by SANTOSH
JuliaS wrote:You can use ForexConnect API in machine learning models.

The following sample scripts are available at github:

PricePredictionMLregressionMA.py
This sample script shows how to use Machine Learning in Python and how to predict prices by using Linear Regression.
The input of the regression model is three Moving Averages calculated based on close prices. The algorithm uses a linear model to minimize the residual sum of squares between the observed responses in the dataset and the responses predicted by the linear approximation.

PricePredictionMLregressionPrevious.py
This sample script shows how to use Machine Learning in Python and how to predict prices by using Linear Regression.
The input of the regression model is close prices of previous bars. The algorithm uses a linear model to minimize the residual sum of squares between the observed responses in the dataset and the responses predicted by the linear approximation.

PricePredictionMLClassification.py
This sample script shows how to use Machine Learning in Python and how to predict prices
by using Support Vector Classification.
The model divides objects into two groups: "the price will grow on the next bar" and "the price will fall on the next bar".
The input data for the model are Open-Close and High-Low. The model tries to define whether the price is growing or falling on the basis of the input data.



Can a lua strategy be machine learned ?


Regards ,
Santosh .

Re: Price prediction using machine learning

PostPosted: Wed Mar 04, 2020 10:00 am
by SANTOSH
Hi All
Can a lua strategy be machine learned?

Regards,
Santosh.