NexusFi: Find Your Edge


Home Menu

 





Exporting print content to csv or txt file real time


Discussion in EasyLanguage Programming

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




 
Search this Thread

Exporting print content to csv or txt file real time

  #1 (permalink)
 ww3361 
London UK
 
Experience: Intermediate
Platform: Tradestation, Multicharts, MarketDelta
Trading: Currency Futures
Posts: 11 since May 2013
Thanks Given: 0
Thanks Received: 3

I have written an indicator to keep track of the last closing price from each interval and export it as a text file to the designated folder.

The indicator works perfectly in the offline environment when not connected to a live server. It updates and prints the content into the text file with the current time, even though it doesn't receive any new feed in the offline environment.

However, when I use the same indicator on my live server, it calculates in the background as I can see from the Output, but it does not export the text file to the folder unless I toggle it off or remove it from the chart.

The example output in the offline environment was calculated in real-time.

11/07/2022, 2200, 44872.92, 07:07:10, @CL#C, 103.34000
11/07/2022, 2200, 44872.92, 07:09:11, @CL#C, 103.34000
11/07/2022, 2200, 44872.92, 07:11:12, @CL#C, 103.34000

Does anyone have experience exporting print content in real time to csv or txt file?


Below is the example of the code I have used;

 
Code
inputs: Jstart(44835), directory(""),interval(120);//

vars: intrabarpersist closepx(0), Filename(""), intrabarpersist datetimenow(0), intrabarpersist timenow(0);
vars: intrabarpersist content("");

Once cleardebug; 

	FileName = SymbolName+ ".txt"; // 

	datetimenow = datetime;
	closepx = c; 
	timenow = time;
	content = ELDateToString(Date) + ", " + NumToStr(timenow, 0) + ", " 
		         + NumToStr(datetimenow, 2) + ", " + FormatTime("HH:mm:ss", ELTimeToDateTime_s(CurrentTime_s)) + ", " + SymbolName + ", " + NumToStr(Closepx, 5) + NewLine;
		

if lastbaronchart and datetimenow>Jstart then begin   //and if we use lastbaronchart, start recording as last bar

	    FileAppend(directory + FileName, content);  	
    
	    RecalcLastBarAfter(interval); 
	    
end;

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Increase in trading performance by 75%
The Elite Circle
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
17 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
My NQ Trading Journal
12 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

wilkinsw,

your code works fine here in realtime. When I understand your statement "it does not export the text file to the folder unless I toggle it off or remove it from the chart" correctly, the data is written as soon as you change the status of the indicator. If this is correct, this might indicate a problem outside of your code and MC. Do you see the same behavior when you test your code with realtime data on a desktop computer?

Regards,

ABCTG


wilkinsw View Post
I have written an indicator to keep track of the last closing price from each interval and export it as a text file to the designated folder.

The indicator works perfectly in the offline environment when not connected to a live server. It updates and prints the content into the text file with the current time, even though it doesn't receive any new feed in the offline environment.

However, when I use the same indicator on my live server, it calculates in the background as I can see from the Output, but it does not export the text file to the folder unless I toggle it off or remove it from the chart.

The example output in the offline environment was calculated in real-time.

11/07/2022, 2200, 44872.92, 07:07:10, @CL#C, 103.34000
11/07/2022, 2200, 44872.92, 07:09:11, @CL#C, 103.34000
11/07/2022, 2200, 44872.92, 07:11:12, @CL#C, 103.34000

Does anyone have experience exporting print content in real time to csv or txt file?


Below is the example of the code I have used;

 
Code
inputs: Jstart(44835), directory(""),interval(120);//

vars: intrabarpersist closepx(0), Filename(""), intrabarpersist datetimenow(0), intrabarpersist timenow(0);
vars: intrabarpersist content("");

Once cleardebug; 

	FileName = SymbolName+ "2.txt"; // 

	datetimenow = datetime;
	closepx = c; 
	timenow = time;
	content = ELDateToString(Date) + ", " + NumToStr(timenow, 0) + ", " 
		         + NumToStr(datetimenow, 2) + ", " + FormatTime("HH:mm:ss", ELTimeToDateTime_s(CurrentTime_s)) + ", " + SymbolName + ", " + NumToStr(Closepx, 5) + NewLine;
		

if lastbaronchart and datetimenow>Jstart then begin   //and if we use lastbaronchart, start recording as last bar
//if barStatus(1) = 2 and datetimenow>Jstart then begin  // I have also use this one as well as it allow me start earlier than the last bar.

	    Print(FormatTime("HH:mm:ss - ", ELTimeToDateTime_s(CurrentTime_s)), 
		"GetAppInfo(aiRealTimeCalc): ", GetAppInfo(aiRealTimeCalc), GetAppInfo(aicalcreason));
		
	    print(content);
	     
	    FileAppend(directory + FileName, content);  	
    
	    RecalcLastBarAfter(interval); 
	    
end;


Follow me on Twitter Reply With Quote




Last Updated on July 24, 2023


© 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