NexusFi: Find Your Edge


Home Menu

 





help with print to file commands.


Discussion in TradeStation

Updated
      Top Posters
    1. looks_one maggtrading with 5 posts (0 thanks)
    2. looks_two SMCJB with 3 posts (3 thanks)
    3. looks_3 ABCTG with 2 posts (2 thanks)
    4. looks_4 kevinkdog with 1 posts (1 thanks)
    1. trending_up 4,766 views
    2. thumb_up 6 thanks given
    3. group 3 followers
    1. forum 10 posts
    2. attach_file 1 attachments




 
Search this Thread

help with print to file commands.

  #11 (permalink)
maggtrading
quintana roo, méxico
 
Posts: 84 since Mar 2013
Thanks Given: 222
Thanks Received: 40

regards to everyone,


i was finally to get this to work. as herr ABCTG correctly stated, the code as i had previously shared required each symbol to have its own folder, and ts required those folders to have been created before trying to write to them. i made some minor modifications and the indicator now works as desired.



 
Code

  
using elsystem;   
using elsystem.collections;   
using elsystem.io;  
using tsdata.common; 
using tsdata.marketdata; 
using tsdata.trading;  
   
inputs:   
price(close),   
length(9),   
string iprimarydirectory("c:\tslogs\"),  
string symtic("clm19"),  
string indnam("sma crossovers");   
   
variables:   
sma(0),  
streamwriter sw(null);   
  
//	pass in a string containing line to be written to the file	     
method void recordevent(string msg)     
variables:     
string filepath;     
begin     
	//	create file name, including a directory based upon the symbol     
	//     
	//	note:   symbol should not contain characters that are not valid in file names     
	//			indicator name should not contain invalid characters for a file name     
	//			add whatever other parameters desired	     
	filepath = string.format("{0}\{1}_{2}_{3:yyyymmddhhmmss}.log",     
		iprimarydirectory,     
		symtic,    
		indnam,     
		datetime.now); 
		     
	print(filepath); 
	sw = streamwriter.create(filepath);  
	sw.autoflush = true;    
	sw.writeline(msg);      
	sw.close();     
end;     
  
  
sma  = average (price, length);  
  
  
plot1 ( sma, "sma alert logs" );  
  
  
if price[0] > sma[0] and price[1] < sma[1] and lastbaronchart and barstatus( 1 ) = 2 then begin  
recordevent(" uptrend has started ");    
end;  
  
if price[0] < sma[0] and price[1] > sma[1] and lastbaronchart and barstatus( 1 ) = 2 then begin  
recordevent(" downtrend has started ");   
end;

so here you have, there are three versions in this thread of a working indicator to record events to local files instead of relying on the typical ts alerts. the best thing about this forum is that if anyone is searching on the internet for help to use tradestation or easylanguage print to file, append file and streamwriter commands, threads in this forum will turn up in search results and anyone can read them even without being registered members.


very well, regards, thanks to all.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 




Last Updated on May 17, 2019


© 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