Click here to Login





                                                   Composite Tool Script Editor - Write to TXT

  0

0
Alpha Trader
2018-03-03 11:08:46


Trying to write some variables from a composite to a text file. Figured I could just add code in my Composite tool script editor to write a txt file.

This doesn't seem to work. Output file is not being written. Any limitations to the composite script editor?

Any help is appreciated!

double[] close = Functions.GetVariable("close");
double[] open = Functions.GetVariable("open");
double[] high = Functions.GetVariable("high");
double[] low = Functions.GetVariable("low");
double[] volume = Functions.GetVariable("volume");
double[] count = Functions.GetVariable("count");

double[] date0 = Functions.GetVariable("date0"); // date0 = Date(); in QS Composite tool code
double[] symbol = Functions.GetVariable("symbol"); //symbol = name(); in QS Composite tool code
double[] totcap = Functions.GetVariable("totcap");
double[] cap = Functions.GetVariable("cap");
double[] weight = Functions.GetVariable("weight");
double[] mcap = Functions.GetVariable("mcap");
double[] comborank = Functions.GetVariable("comborank");

string s1 = "HelloWorld:";

for (int i=1; i<close.Length;i++)
{

close[0] =1000;
close[i] =close[i]*close[i-1];
open[0] = 1000;
open[i] = close[i]*open[i]/100+close[i];
high[0] = 1000;
high[i] = close[i]*high[i]/100+close[i];
low[0] = 1000;
low[i] = close[i]*low[i]/100+close[i];
volume[i] =volume[i];
count[i] =count[i];

string s2 = "Hello World:";

date0[0] = 0;
date0[i] = date0[i];
symbol[0] = 0;
symbol[i] = symbol[i];
totcap[0] = 0;
totcap[i] = totcap[i];
cap[0] = 0;
cap[i] = cap[i];
weight[0] = 0;
weight[i] = weight[i];
mcap[0] = 0;
mcap[i] = mcap[i];
comborank[0] = 0;
comborank[i] = comborank[i];

s2 = close[i] +(char)Keys.Tab + date0[i] +(char)Keys.Tab + symbol[i] +(char)Keys.Tab + totcap[i] +(char)Keys.Tab + cap[i] +(char)Keys.Tab + weight[i] +(char)Keys.Tab + mcap[i] +(char)Keys.Tab + comborank[i] + Environment.NewLine;
s1 +=s2;
System.IO.File.AppendAllText("C:\\QuantShare Exports\\output.txt", s1);
}

Functions.SetCompositeData(close);
Functions.SetCompositeDataInOpenField(open);
Functions.SetCompositeDataInHighField(high);
Functions.SetCompositeDataInLowField(low);
Functions.SetCompositeDataInVolumeField(volume);
Functions.SetCompositeDataInOpenInterestField(count);



QuantShare
2018-03-05 03:47:35

  0

You should add the "AppendAllText" function outside of the "for" loop, otherwise, the "s" variable will be written on each iteration.
However, even with that, you should get data in the "output.txt" file. Try to use "Global.Trace" to see if loop is being executed correctly. Trace data will be displayed in "View -> Output".



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
ADX Composite Indicator for the Stock Market
Keltner Channel Market Composite
Short selling composite
Channel Drawing Tool
Maximum Drawdown Composite Indicator

How-to Lessons
How to run a screen or a watchlist from a script
How to get stocks for a particular index using the global script
How to filter stocks in a market composite
How to execute a script at regular intervals
How to create a composite index/indicator

Related Forum Threads
Plot through the script editor
Watchlist and Script Editor
Composite tool
Data Interpolation c# Script
Money Management Script variables and more

Blog Posts
How to measure market strength with the composite tool
Create a trading strategy using the money management tool - Part ...
4 Market Composite Indicators Based on Industry Data
Introduction to the Events Monitor Tool
QS Trading Software: Global Script









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.