NexusFi: Find Your Edge


Home Menu

 





I would like to change a variable using a txt document that will change with a stock.


Discussion in EasyLanguage Programming

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




 
Search this Thread

I would like to change a variable using a txt document that will change with a stock.

  #1 (permalink)
Mgem
New York City
 
Posts: 15 since Apr 2021
Thanks Given: 2
Thanks Received: 0

I would like to change a variable using a txt document that will change with a stock.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Are there any eval firms that allow you to sink to your …
Traders Hideout
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

Mgem,

can you post the code you have so far? This might help in steering you in the right direction.

Regards,

ABCTG



Mgem View Post
I would like to change a variable using a txt document that will change with a stock.


Follow me on Twitter Reply With Quote
  #3 (permalink)
Mgem
New York City
 
Posts: 15 since Apr 2021
Thanks Given: 2
Thanks Received: 0


Yup this is what I have so far

 
Code
using elsystem;    
using elsystem.io;  
    
inputs:    
	iDateFile( "C:\Users\Michael\Desktop\StatsTime.txt" ), 
	iInterval( 25 ), // Number of seconds to pause between charts   
	iEnableCycling( true ); 
	    
variables: 
	int Idx( 0 ),  
	StreamReader SR( null ),  
	intrabarpersist FirstTime( "" ), 
	intrabarpersist NextTime( "" ),    
	Timer Tmr( null ); 
    
method void Tmr_Elapsed( elsystem.Object sender, elsystem.TimerElapsedEventArgs args )     
begin 
	RunCommand( NextTime );    
end;  
 
method void CreateTimer() 
begin 
	Tmr = Timer.Create();    
	Tmr.Interval = (1000 * iInterval) astype int;    
	Tmr.Elapsed += Tmr_Elapsed; 
	Tmr.AutoReset = false;  
	Tmr.Start(); 
end;  
  
once( LastBarOnChartEx )  
begin  
 
	if GetAppInfo( aiMacroEnabled ) = 0 then 
		RaiseRuntimeError( "Study requires RunCommand enabled." ); 
 
	SR = StreamReader.Create( iDateFile ); 
	 
	while SR.EndOfStream = false  
	begin 
		if Idx = 0 then 
		begin 
			FirstTime = SR.ReadLine(); 
			NextTime = FirstTime; 
		end 
		else if Time = StrToNum(NextTime) then 
		begin 
			NextTime = SR.ReadLine(); 
			CreateTimer(); 
			break; 
		end 
		else 
		begin 
			NextTime = SR.ReadLine(); 
			if iEnableCycling and SR.EndOfStream and Time = StrToNum(NextTime) then 
			begin 
				NextTime = FirstTime; 
				CreateTimer(); 
				break; 
			end; 
		end; 
		 
		Idx += 1; 
	end; 
 
	SR.Close(); 

end;

Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

Mgem,

seeing that you have multiple similar posts in the TS forum regarding this or similar topics it might make sense to concentrate the efforts in one place.
Can you describe in your words what the code does and what it should do instead? Additionally, why did you decide to use Runcommand and a timer for the task at hand?

Regards,

ABCTG


Mgem View Post
Yup this is what I have so far

 
Code
using elsystem;    
using elsystem.io;  
    
inputs:    
	iDateFile( "C:\Users\Michael\Desktop\StatsTime.txt" ), 
	iInterval( 25 ), // Number of seconds to pause between charts   
	iEnableCycling( true ); 
	    
variables: 
	int Idx( 0 ),  
	StreamReader SR( null ),  
	intrabarpersist FirstTime( "" ), 
	intrabarpersist NextTime( "" ),    
	Timer Tmr( null ); 
    
method void Tmr_Elapsed( elsystem.Object sender, elsystem.TimerElapsedEventArgs args )     
begin 
	RunCommand( NextTime );    
end;  
 
method void CreateTimer() 
begin 
	Tmr = Timer.Create();    
	Tmr.Interval = (1000 * iInterval) astype int;    
	Tmr.Elapsed += Tmr_Elapsed; 
	Tmr.AutoReset = false;  
	Tmr.Start(); 
end;  
  
once( LastBarOnChartEx )  
begin  
 
	if GetAppInfo( aiMacroEnabled ) = 0 then 
		RaiseRuntimeError( "Study requires RunCommand enabled." ); 
 
	SR = StreamReader.Create( iDateFile ); 
	 
	while SR.EndOfStream = false  
	begin 
		if Idx = 0 then 
		begin 
			FirstTime = SR.ReadLine(); 
			NextTime = FirstTime; 
		end 
		else if Time = StrToNum(NextTime) then 
		begin 
			NextTime = SR.ReadLine(); 
			CreateTimer(); 
			break; 
		end 
		else 
		begin 
			NextTime = SR.ReadLine(); 
			if iEnableCycling and SR.EndOfStream and Time = StrToNum(NextTime) then 
			begin 
				NextTime = FirstTime; 
				CreateTimer(); 
				break; 
			end; 
		end; 
		 
		Idx += 1; 
	end; 
 
	SR.Close(); 

end;


Follow me on Twitter Reply With Quote
  #5 (permalink)
Mgem
New York City
 
Posts: 15 since Apr 2021
Thanks Given: 2
Thanks Received: 0

For sure. This was something I was sent from John on the TS forum. It originally was meant for cycling through stock symbols and it worked pretty well. the code below was my attempt at getting it to cycle through time rather then symbols. The timer is in there in order to allow the stock to fully load and print the data I needed before moving onto the next one. Right now this code doesnt seem to do anything. What I was attempting to do is have it set as a variable and have it cycle through a list and change with the according date and symbol. If you need me to go into more detail or need to see the current code im using to cycler through the dates and trade just let me know and I can give that to you

Reply With Quote




Last Updated on June 30, 2022


© 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