R Neural Network example - Matlab, R project and Python | futures io social day trading
futures io futures trading


R Neural Network example
Updated: Views / Replies:2,618 / 13
Created: by Big Mike Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

R Neural Network example

  #1 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,353 given, 83,234 received

R Neural Network example

Inovance Blog - Using a Neural Network to Model the S&P 500

 
Code
install.packages("quantmod")
library("quantmod")
#Allows us to import the market data and indicators we need
install.packages(“neuralnet”)
library(“neuralnet”)
#Provides the artificial neural network algorithm (there are a variety of R packages that allow you build ANNs, however neuralnet allows us to easily plot the network and has all the functionality we need for this example)
startDate<-as.Date('2009-01-01')
endDate<-as.Date('2014-01-01')
getSymbols("^GSPC",src="yahoo",from=startDate,to=endDate)
#Retrieve the data we need
RSI3<-RSI(Op(GSPC),n=3)
#Calculate a 3-period RSI
EMA5<-EMA(Op(GSPC),n=5)
EMAcross<-Op(GSPC)-EMA5
#Look at the difference between the open price and a 5-period EMA
MACD<-MACD(Op(GSPC),fast = 12, slow = 26, signal = 9)
MACDsignal<-MACD[,2]
#Grab the signal line of the MACD
BB<-BBands(Op(GSPC),n=20,sd=2)
BBp<-BB[,4]
#We will use the Bollinger Band %B, which measures the price relative to the upper and lower Bollinger Bands
Price<-Cl(GSPC)-Op(GSPC)
#For this example we will be looking to predict the numeric change in price
DataSet<-data.frame(RSI3,EMAcross,MACDsignal,BBp,Price)
DataSet<-DataSet[-c(1:33),]
colnames(DataSet)<-c("RSI3","EMAcross","MACDsignal","BollingerB","Price")
#Create our data set, remove the data where the indicator values are being calculated, and name our columns
 
Code
Then normalize our data.
Normalized <-function(x) {(x-min(x))/(max(x)-min(x))}
NormalizedData<-as.data.frame(lapply(DataSet,Normalized))
#We are normalizing our data to be bound between 0 and 1
And create our training and test sets:
TrainingSet<-NormalizedData[1:816,]
TestSet<-NormalizedData[817:1225 ,]
Now let’s actually build our artificial neural network.
nn1<-neuralnet(Price~RSI3+EMAcross+MACDsignal+BollingerB,data=TrainingSet, hidden=3, learningrate=.001,algorithm="backprop")
#We are using our indicators to predict the price over the training set, and a learning rate of .001 with a backpropagation algorithm
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following 4 users say Thank You to Big Mike for this post:
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Spread Trader
Austin TX
 
Futures Experience: Advanced
Platform: Ninjatrader, Python, & R
Broker/Data: RJO
Favorite Futures: Futures, Spreads
 
SodyTexas's Avatar
 
Posts: 313 since Sep 2013
Thanks: 96 given, 843 received



Big Mike View Post
Inovance Blog - Using a Neural Network to Model the S&P 500

 
Code
install.packages("quantmod")
library("quantmod")
#Allows us to import the market data and indicators we need
install.packages(“neuralnet”)
library(“neuralnet”)
#Provides the artificial neural network algorithm (there are a variety of R packages that allow you build ANNs, however neuralnet allows us to easily plot the network and has all the functionality we need for this example)
startDate<-as.Date('2009-01-01')
endDate<-as.Date('2014-01-01')
getSymbols("^GSPC",src="yahoo",from=startDate,to=endDate)
#Retrieve the data we need
RSI3<-RSI(Op(GSPC),n=3)
#Calculate a 3-period RSI
EMA5<-EMA(Op(GSPC),n=5)
EMAcross<-Op(GSPC)-EMA5
#Look at the difference between the open price and a 5-period EMA
MACD<-MACD(Op(GSPC),fast = 12, slow = 26, signal = 9)
MACDsignal<-MACD[,2]
#Grab the signal line of the MACD
BB<-BBands(Op(GSPC),n=20,sd=2)
BBp<-BB[,4]
#We will use the Bollinger Band %B, which measures the price relative to the upper and lower Bollinger Bands
Price<-Cl(GSPC)-Op(GSPC)
#For this example we will be looking to predict the numeric change in price
DataSet<-data.frame(RSI3,EMAcross,MACDsignal,BBp,Price)
DataSet<-DataSet[-c(1:33),]
colnames(DataSet)<-c("RSI3","EMAcross","MACDsignal","BollingerB","Price")
#Create our data set, remove the data where the indicator values are being calculated, and name our columns
 
Code
Then normalize our data.
Normalized <-function(x) {(x-min(x))/(max(x)-min(x))}
NormalizedData<-as.data.frame(lapply(DataSet,Normalized))
#We are normalizing our data to be bound between 0 and 1
And create our training and test sets:
TrainingSet<-NormalizedData[1:816,]
TestSet<-NormalizedData[817:1225 ,]
Now let’s actually build our artificial neural network.
nn1<-neuralnet(Price~RSI3+EMAcross+MACDsignal+BollingerB,data=TrainingSet, hidden=3, learningrate=.001,algorithm="backprop")
#We are using our indicators to predict the price over the training set, and a learning rate of .001 with a backpropagation algorithm
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Mike

You forgot the package MASS to run NN

Add:
 
Code
library(MASS)
somewhere at the top

Sody

"The great Traders have always been humbled by the market early on in their careers creating a deep respect for the market. Until one has this respect indelibly engraved in their makeup, the concept of money management and discipline will never be treated seriously."
Reply With Quote
The following user says Thank You to SodyTexas for this post:
 
  #4 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,353 given, 83,234 received

Not much discussion in this direction, took a year to catch the error

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following user says Thank You to Big Mike for this post:
 
  #5 (permalink)
Market Wizard
Houston, TX
 
Futures Experience: Advanced
Platform: XTrader
Broker/Data: Advantage Futures
Favorite Futures: Energy
 
Posts: 2,123 since Dec 2013
Thanks: 1,749 given, 3,358 received
Forum Reputation: Legendary


Big Mike View Post
Not much discussion in this direction, took a year to catch the error

My Machine Learning education has been coming a long a little slower than I wanted. I've been doing a lot of work in the last few weeks with Random Forests for the Kaggle Titanic Competition which I have found extremely interesting, but probably not relevant to my trading. SVM's and NN's always seem to be the thing I want to tackle next™

Reply With Quote
The following user says Thank You to SMCJB for this post:
 
  #6 (permalink)
Spread Trader
Austin TX
 
Futures Experience: Advanced
Platform: Ninjatrader, Python, & R
Broker/Data: RJO
Favorite Futures: Futures, Spreads
 
SodyTexas's Avatar
 
Posts: 313 since Sep 2013
Thanks: 96 given, 843 received


SMCJB View Post
My Machine Learning education has been coming a long a little slower than I wanted. I've been doing a lot of work in the last few weeks with Random Forests for the Kaggle Titanic Competition which I have found extremely interesting, but probably not relevant to my trading. SVM's and NN's always seem to be the thing I want to tackle next™

I learned ML from UDEMY for both Python and R. Might be worth looking at.

Sody

"The great Traders have always been humbled by the market early on in their careers creating a deep respect for the market. Until one has this respect indelibly engraved in their makeup, the concept of money management and discipline will never be treated seriously."
Reply With Quote
The following 2 users say Thank You to SodyTexas for this post:
 
  #7 (permalink)
Market Wizard
Houston, TX
 
Futures Experience: Advanced
Platform: XTrader
Broker/Data: Advantage Futures
Favorite Futures: Energy
 
Posts: 2,123 since Dec 2013
Thanks: 1,749 given, 3,358 received
Forum Reputation: Legendary

I have one of their courses open in my browser as we speak. Their stuff looks interesting but I havent taken any actual courses yet. I did do the coursera.org machine learning course 18 months ago which I thought was very good. Wish it had been in R rather than Octave though. Also a little surprised they didnt cover CART and Random Forest's, one of the reasons I've been looking at them the last two months.

Reply With Quote
 
  #8 (permalink)
Elite Member
glostrup, denmark
 
Futures Experience: Advanced
Platform: Custom platform
Broker/Data: CQG
Favorite Futures: Futures, Options, Stocks
 
ktrader's Avatar
 
Posts: 249 since Aug 2011
Thanks: 151 given, 274 received


SMCJB View Post
My Machine Learning education has been coming a long a little slower than I wanted. I've been doing a lot of work in the last few weeks with Random Forests for the Kaggle Titanic Competition which I have found extremely interesting, but probably not relevant to my trading. SVM's and NN's always seem to be the thing I want to tackle next™

Good luck with the survivor-classification

And using random forests for classification can definitely be applied for use in trading, so time well spent

--ktrader

Reply With Quote
The following user says Thank You to ktrader for this post:
 
  #9 (permalink)
Spread Trader
Austin TX
 
Futures Experience: Advanced
Platform: Ninjatrader, Python, & R
Broker/Data: RJO
Favorite Futures: Futures, Spreads
 
SodyTexas's Avatar
 
Posts: 313 since Sep 2013
Thanks: 96 given, 843 received


SMCJB View Post
I have one of their courses open in my browser as we speak. Their stuff looks interesting but I havent taken any actual courses yet. I did do the coursera.org machine learning course 18 months ago which I thought was very good. Wish it had been in R rather than Octave though. Also a little surprised they didnt cover CART and Random Forest's, one of the reasons I've been looking at them the last two months.

They been offering $15 dollar sales on most of there classes. CART and Random Forest is covered in the link I posted.

"The great Traders have always been humbled by the market early on in their careers creating a deep respect for the market. Until one has this respect indelibly engraved in their makeup, the concept of money management and discipline will never be treated seriously."
Reply With Quote
The following user says Thank You to SodyTexas for this post:
 
  #10 (permalink)
Market Wizard
Houston, TX
 
Futures Experience: Advanced
Platform: XTrader
Broker/Data: Advantage Futures
Favorite Futures: Energy
 
Posts: 2,123 since Dec 2013
Thanks: 1,749 given, 3,358 received
Forum Reputation: Legendary



ktrader View Post
Good luck with the survivor-classification

And using random forests for classification can definitely be applied for use in trading, so time well spent

--ktrader

Yes i've found the whole concept of random forests very very interesting and had a lot of fun investigating/optimizing with leaf sizes and mtry settings. Specific to the Kaggle Titanic problem though I've found that my models are overfitting the data and out of sample scores are lower, which wasnt as much the case when i was doing Logistic regression (before I knew about Forests). I have thought of some potential trading applications but it'll probably be months before I start investigating them. I don't have anything to base this on, but I was expecting SVM and NN to be better for trading.


SodyTexas View Post
They been offering $15 dollar sales on most of there classes. CART and Random Forest is covered in the link I posted.

Thanks Sody I'll definitely take a look. I like watching video's like that during the trading day when things get quiet. I assume if you buy the course you can go back and rewatch the video's as much as you like?

Reply With Quote

Reply



futures io > > > > R Neural Network example

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Profitable Neural Network Strategy zacharydw00 EasyLanguage Programming 67 July 19th, 2014 06:02 PM
Experimental one step AForge-based NN predictor for OHLC data (Neural Network) bnichols NinjaTrader Programming 28 December 24th, 2012 03:20 PM
TradingSolutions with Neural networks emini_Holy_Grail Trading Reviews and Vendors 4 October 30th, 2010 09:55 AM
Neural Networks free Code gabga100 Platforms and Indicators 3 December 10th, 2009 03:38 AM


All times are GMT -4. The time now is 01:33 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-16 in 0.13 seconds with 19 queries on phoenix via your IP 23.22.136.56