NexusFi: Find Your Edge


Home Menu

 





Pimp your Sierra with R


Discussion in Sierra Chart

Updated
    1. trending_up 2,203 views
    2. thumb_up 8 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Pimp your Sierra with R

  #1 (permalink)
 
puma's Avatar
 puma 
zurich
 
Experience: Advanced
Platform: Sierra ahRrrr CQG ...
Trading: Bund, ES, ...
Posts: 964 since Aug 2010
Thanks Given: 7,273
Thanks Received: 1,507

One can use R and data from e.g quandl.com to feed sierra (EoD).

This way you can turn your little Sierra into an economics machine.
(fuck you Bloomberg ! )

Here is an example/template for the Baltic Dry Index.

(I am not a coder - so feel free to better this embarrassing script)

 
Code
### Baltic Dry Index
### via quandl
### v0.1 share 

###    ----
# 
# 
#_____________________________________________________________________________

### Meta data    ----
name1 <- "bender is great"
stamp.date <- Sys.Date()
description <- "Baltic Dry Index. Source: DryShips Inc." 
# 
#______________________________________________________________________________

### set variables   ----
quandl.auth <- 'GetThisFromYourQuandlAccount' #https://www.quandl.com
quandl.symbol <- "OFDP/INDEX_BDI_1"
path.to.sierra.data <- "F:/Programme/aaaa Trading/SierraChart5/Data/r.BDI.dly"

#_____________________________________________________________________________

### Libraries     -------------------------------------------------------------
library("Quandl")
library("xts")
library("sqldf")
#______________________________________________________________________________

### Auth for Quandl   ----
Quandl.auth(quandl.auth)
# 
#_____________________________________________________________________________

### DL from quandl  ------------------------------------------------------------
d = Quandl(quandl.symbol, 
               collapse=NULL, # NULL for Daily
               start_date="1900-01-01", 
               type="xts")

#plot(qdata[,1])
#______________________________________________________________________________

### opti data for sierra   ----

# convert xts 2 df
d.df <- as.data.frame(d)
rn <- row.names(d.df)

# opti Date 
rn <- sapply(rn, 
               function(x) 
                       {as.character(gsub("-","/", as.character(x)))})

# write back opti row names
row.names(d.df) <- rn

# make pseudo OHLC
d.df[,2] <- d.df[,1]
d.df[,3] <- d.df[,1]
d.df[,4] <- d.df[,1]
d.df[,5] <- d.df[,1]
d.df[,1] <- rn

# rename col
names(d.df) <- c("Date","Open","High","Low","Close")

#_____________________________________________________________________________

### merge with data in (txt-) DB ----
# this preserves the data downloaded earlier - 
# in case there is more data in local DB, than in the web-source

# get downloaded quandl data
d_DL <- d.df
rm(d.df)

# get current data in DB 
if (file.exists(path.to.sierra.data)){
        
        d_DB <- read.table(path.to.sierra.data,
                           header=T,
                           sep=",",
                           colClasses=c("character","numeric","numeric","numeric",
                                        "numeric"))
        d_DB[,1] <- sapply(d_DB[,1], 
                           function(x) 
                           {as.character(gsub("-","/", as.character(x)))})
} else {
        
        d_DB <- d_DL  
}

# Only the rows which are NOT in both data frames:
d_update <- sqldf('SELECT * FROM d_DL EXCEPT SELECT * FROM d_DB')

# merge into updated DB
d_DBnew <- merge(d_update, d_DB, all.x=T, all=T) 
rm(d_DB)
rm(d_DL)
rm(d_update)

#_____________________________________________________________________________

### write to file   ----
write.table(d_DBnew,path.to.sierra.data,sep=",",row.names=FALSE, quote=F)
#_____________________________________________________________________________

### clean   ----
rm(list=ls())
#_____________________________________________________________________________


Follow me on Twitter Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Quantum physics & Trading dynamics
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
Cheap historycal L1 data for stocks
Stocks and ETFs
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #2 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,470 since Jun 2009
Thanks Given: 33,249
Thanks Received: 101,673

I believe @Nicolas11 also posted a lot of R/Sierra code for manipulating data.



Mike



Join the free Markets Chat beta: one platform, all the trade rooms!

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
 
puma's Avatar
 puma 
zurich
 
Experience: Advanced
Platform: Sierra ahRrrr CQG ...
Trading: Bund, ES, ...
Posts: 964 since Aug 2010
Thanks Given: 7,273
Thanks Received: 1,507



Big Mike View Post
I believe @Nicolas11 also posted a lot of R/Sierra code for manipulating data.



Mike

TY , I will have a look

Follow me on Twitter Started this thread Reply With Quote
  #4 (permalink)
 
puma's Avatar
 puma 
zurich
 
Experience: Advanced
Platform: Sierra ahRrrr CQG ...
Trading: Bund, ES, ...
Posts: 964 since Aug 2010
Thanks Given: 7,273
Thanks Received: 1,507

quandl changed the symbol to:

OFDP/INDEX_BDI

Follow me on Twitter Started this thread Reply With Quote




Last Updated on November 29, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts