Write data to file - Sierra Chart Programming | futures io social day trading
futures io futures trading


Write data to file
Updated: Views / Replies:2,654 / 14
Created: by WarEagle Attachments:1

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
 1  
 
Thread Tools Search this Thread
 

Write data to file

  #1 (permalink)
DOM on the Range
Birmingham, AL
 
Futures Experience: Intermediate
Platform: SierraChart
Broker/Data: DDT/Rithmic
Favorite Futures: TF/ZN/CL
 
WarEagle's Avatar
 
Posts: 30 since Apr 2010
Thanks: 56 given, 25 received

Write data to file

I am new to SC, and love it so far. The biggest obstacle is going to be learning a new programming language and C++ is certainly a challenge for me. I am pretty good with EasyLanguage and I am coming from MultiCharts (and before that TradeStation) where I wrote a lot of my own custom stuff.

There is really only one indicator that I need right off the bat so I am hoping someone may know how to do this or point me to it if it already exists somewhere. I use a second program that does not connect to my real time data feed but will update with ASCII data files. So in MC I would simply write the data (Date, Time, Open, High, Low, Close) from a chart to a file that would be named with whatever symbol and resolution was on the chart. Each time a bar closed the file would be updated with the new data. Here is the EL code:

 
Code
Inputs: filename("C:\Trading\Data\");
Vars: fn(""), type(""), Interval(2), Prices("");

Interval = bartype_ex;

If Interval = 1 then type = "tick.csv";
If Interval = 2 then type = "min.csv";
If Interval = 3 then type = "hr.csv";
If Interval = 11 then type = "range.csv";

Prices = ELDateToString(Date) & "," & NumToStr(T,0) & "," & NumToStr(O,2) & "," & NumToStr(H,2) & "," & NumToStr(L,2) & "," & NumToStr(C,2); 

fn = filename & GetSymbolName & "_" & NumToStr(BarInterval,0) & type;

If CurrentBar = 1 then FileDelete(fn);

FileAppend(fn,Prices + NewLine);
The output file will be "CLM3_1min.csv" if its applied to a 1 minute chart of CL. I looked through the built in and custom indicators included with SC and did not see anything that looked like it would do this. Any help or suggestions are appreciated.

Reply With Quote
 
  #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)
Elite Member
England
 
Futures Experience: Advanced
Platform: SierraChart
 
Posts: 58 since Jul 2009
Thanks: 5 given, 57 received


There is a study you can add to the chart called "Write Bar Data to File". Here is a link to the documentation.

Technical Studies Reference - Sierra Chart

You have some control over the format. It updates realtime but beware that it does not write the current bar until it is completed (which I think is fair enough).

If this does not meet your needs, I am certain that a user has posted to the SC forum a piece of ACSIL code that does the job. I think this was done before SC created their study.

Give it a go anyway.

Reply With Quote
The following 2 users say Thank You to swandro for this post:
 
  #4 (permalink)
DOM on the Range
Birmingham, AL
 
Futures Experience: Intermediate
Platform: SierraChart
Broker/Data: DDT/Rithmic
Favorite Futures: TF/ZN/CL
 
WarEagle's Avatar
 
Posts: 30 since Apr 2010
Thanks: 56 given, 25 received

Wow, I have no idea how I missed that study. I must have only looked in the user contributed section. That should be perfect, thanks!

Reply With Quote
The following user says Thank You to WarEagle for this post:
 
  #5 (permalink)
Rristocrat
zurich
 
Futures Experience: Advanced
Platform: Sierra ahRrrr CQG ...
Favorite Futures: Bund, ES, ...
 
puma's Avatar
 
Posts: 963 since Aug 2010
Thanks: 7,268 given, 1,489 received

I can not find this old / original "write to file"- study.

I need the last Bar updated and written to a file.

The official version does not update the last bar.

Can someone please post the link to the original version ?

Thank you very much

Reply With Quote
 
  #6 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received

Hi,

I'm aware that the last message is many months old.

The code of SC's "Write Bar Data To File" study is available in Studies6.cpp, and can probably be adapted so that the study also save the last bar.

Nicolas

Reply With Quote
 
  #7 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received

Here is the code that I personally use (compiled with Microsoft Visual Studio Express 2012 for Windows Desktop):

 
Code
#include <iostream>
#include <string>
#include <fstream>
#include "sierrachart.h"

SCDLLName("Write Bar Data To File 2");

SCSFExport scsf_WriteBarDataToFile2(SCStudyGraphRef sc) {

	SCInputRef OutputFile = sc.Input[0];

	if(sc.SetDefaults)
	{
		sc.GraphName="Write Bar Data To File 2";
		sc.StudyDescription="Write Bar Data To File 2";
		sc.FreeDLL = 0;

		sc.GraphRegion = 0;

		OutputFile.Name = "File Path";
		SCString OutputFileDefaultName;
		OutputFileDefaultName.Format("D:\\SierraChart1\\Data\\%s#CB.csv", sc.Symbol.GetSubString(2,0));
		OutputFile.SetString(OutputFileDefaultName);

		return;
	}

	std::ofstream file(OutputFile.GetString(), std::ios::out | std::ios::trunc);

	if (!file) {
		SCString Buffer;
		Buffer.Format("Unable to open file %s", OutputFile.GetString());
		sc.AddMessageToLog(Buffer, 1);
		return;
	}

	file << "Date, Open, High, Low, Close, Volume" << std::endl;

	for (int Index=0; Index < sc.ArraySize; Index++)
	{

		int year,month,day;
		SCDateTimeMS BaseDateTimeIn = sc.BaseDateTimeIn[Index];
		BaseDateTimeIn.GetDateYMD(year, month, day);
		SCString DateString;
		DateString.Format("%d/%02d/%02d", year, month, day);

		int ValueFormat = sc.BaseGraphValueFormat;

		char *formatString ;
		formatString = "%s, %s, %s, %s, %s, %.0f";

		float OpenValue  = sc.Open[Index];
		float HighValue  = sc.High[Index];
		float LowValue   = sc.Low[Index];
		float CloseValue = sc.Close[Index];

		SCString BarDataString;
		BarDataString.Format(formatString,
			DateString.GetChars(),		
			sc.FormatGraphValue(OpenValue, ValueFormat).GetChars(),
			sc.FormatGraphValue(HighValue, ValueFormat).GetChars(),
			sc.FormatGraphValue(LowValue, ValueFormat).GetChars(), 
			sc.FormatGraphValue(CloseValue, ValueFormat).GetChars(),
			sc.Volume[Index]);

		file << BarDataString << std::endl;
	}		

	file.close();
	SCString Buffer;
	Buffer.Format("Quotes of %s saved in file %s", sc.Symbol, OutputFile.GetString());
	sc.AddMessageToLog(Buffer, 0);

	return;
}

Reply With Quote
The following 9 users say Thank You to Nicolas11 for this post:
 
  #8 (permalink)
Rristocrat
zurich
 
Futures Experience: Advanced
Platform: Sierra ahRrrr CQG ...
Favorite Futures: Bund, ES, ...
 
puma's Avatar
 
Posts: 963 since Aug 2010
Thanks: 7,268 given, 1,489 received

re

great gift, TY Nicolas

I will try your code over the next weekend


Reply With Quote
 
  #9 (permalink)
Rristocrat
zurich
 
Futures Experience: Advanced
Platform: Sierra ahRrrr CQG ...
Favorite Futures: Bund, ES, ...
 
puma's Avatar
 
Posts: 963 since Aug 2010
Thanks: 7,268 given, 1,489 received


Nicolas11 View Post
Here is the code that I personally use (compiled with Microsoft Visual Studio Express 2012 for Windows Desktop):

Hi Nicolas11,

can you post the DLL please.

I have trouble compiling it and don't have Visual Studio on this PC.

TY

Reply With Quote
 
  #10 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received


@puma,

Enclosed.

Nicolas

Attached Files
Register to download File Type: dll WriteBarDataToFile2.dll (177.0 KB, 10 views)
Reply With Quote
The following 4 users say Thank You to Nicolas11 for this post:

Reply



futures io > > > > > Write data to file

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Import Historical data from text file spinnybobo NinjaTrader 8 January 28th, 2016 01:43 PM
NinjaTrader - Importing text file tick data DarkPoolTrading NinjaTrader 7 May 17th, 2012 09:08 AM
problem with reading data from txt file Altas NinjaTrader Programming 2 May 11th, 2011 05:29 PM
Importing data as .txt file in Multicharts arjfca The Elite Circle 2 January 31st, 2011 07:15 PM
Data file convertion esignal to Market Analyst Roland Reviews of Brokers and Data Feeds 3 February 13th, 2010 07:01 PM


All times are GMT -4. The time now is 05:52 PM.

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-12 in 0.12 seconds with 20 queries on phoenix via your IP 54.167.44.32