NexusFi: Find Your Edge


Home Menu

 





PSP.Close not updating?


Discussion in EasyLanguage Programming

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




 
Search this Thread

PSP.Close not updating?

  #1 (permalink)
CreativelyChris
Los Angeles, CA
 
Posts: 13 since Sep 2021
Thanks Given: 1
Thanks Received: 0

Hello,

New to EL and trying to figure the following out (mostly with a lot of trial and error).

I'm using a PSP to get the daily close price of another ticker, and working to backtest a strategy but just ran into an issue...

In simple terms, the strategy would take a ticker, and load a second ticker in a PSP, and if the PSP.Close[0] is less than the close of the price seven days ago, PSP.Close[7] then buy the first ticker.

The problem I have is I'm trying to use "Date of Next Bar" in my code (right now in a print statement to troubleshoot), and when I do this it causes the PSP to not update, only showing me the values of one set of dates.
Is there a way to use "PSP.Close" and "Date of Next Bar" together where the PSP.Close will still update?

Looking at the code below - if I remove "Date of Next Bar" it works, but ideally I need to call that data so I can see if I want to buy on tomorrow's date based on other criteria.

 
Code
using elsystem ;
using tsdata.common ;
using tsdata.marketdata ;

	
Var: PriceSeriesProvider PSP1(null);


once
	begin
	PSP1 = new PriceSeriesProvider ;
	PSP1.Symbol = "$TNX.X" ;
	PSP1.Interval = DataInterval.FromCurrentSymbolData( BarType, BarInterval );
	PSP1.Range.FirstDate = 
	DateTime.FromELDateAndTime( Date[MaxBarsBack], 
			Time[MaxBarsBack] ) 
			- TimeSpan.Create( 100, 0, 0, 0 ) ; 
	PSP1.Realtime = true;
	PSP1.Load = true ;
	Value99 = PSP1.Count ;
	end ;

	
Once ClearPrintLog;



Print("Date: ", Date, "    DoNB: ", Date of next bar, "    PSPC0: ", PSP1.Close[0], "    PSPC7: ", PSP1.Close[7]);
if (PSP1.Close[0] - PSP1.Close[7] < 0) Then
			buy("Buy On the Open") at next bar at Open;




if BarsSinceEntry = 7 Then
	SetExitOnClose;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
Quantum physics & Trading dynamics
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

CreativelyChris,

one thing that comes to mind is using intrabar order generation for what you have in mind instead. Is there a reason why you did not explore this further?

Regards,

ABCTG



CreativelyChris View Post
Hello,

New to EL and trying to figure the following out (mostly with a lot of trial and error).

I'm using a PSP to get the daily close price of another ticker, and working to backtest a strategy but just ran into an issue...

In simple terms, the strategy would take a ticker, and load a second ticker in a PSP, and if the PSP.Close[0] is less than the close of the price seven days ago, PSP.Close[7] then buy the first ticker.

The problem I have is I'm trying to use "Date of Next Bar" in my code (right now in a print statement to troubleshoot), and when I do this it causes the PSP to not update, only showing me the values of one set of dates.
Is there a way to use "PSP.Close" and "Date of Next Bar" together where the PSP.Close will still update?

Looking at the code below - if I remove "Date of Next Bar" it works, but ideally I need to call that data so I can see if I want to buy on tomorrow's date based on other criteria.

 
Code
using elsystem ;
using tsdata.common ;
using tsdata.marketdata ;

	
Var: PriceSeriesProvider PSP1(null);


once
	begin
	PSP1 = new PriceSeriesProvider ;
	PSP1.Symbol = "$TNX.X" ;
	PSP1.Interval = DataInterval.FromCurrentSymbolData( BarType, BarInterval );
	PSP1.Range.FirstDate = 
	DateTime.FromELDateAndTime( Date[MaxBarsBack], 
			Time[MaxBarsBack] ) 
			- TimeSpan.Create( 100, 0, 0, 0 ) ; 
	PSP1.Realtime = true;
	PSP1.Load = true ;
	Value99 = PSP1.Count ;
	end ;

	
Once ClearPrintLog;



Print("Date: ", Date, "    DoNB: ", Date of next bar, "    PSPC0: ", PSP1.Close[0], "    PSPC7: ", PSP1.Close[7]);
if (PSP1.Close[0] - PSP1.Close[7] < 0) Then
			buy("Buy On the Open") at next bar at Open;




if BarsSinceEntry = 7 Then
	SetExitOnClose;


Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
CreativelyChris
Los Angeles, CA
 
Posts: 13 since Sep 2021
Thanks Given: 1
Thanks Received: 0


Good idea ABCTG - the reason I didn't explore that, is I haven't used that feature yet.

adding [IntrabarOrderGeneration = True]; and changing at next bar at open to "this bar" seems to work.
There seems to be a bug or something in my code which I'll track down, but overall, I think it's working now.

Thank you for the idea.

Reply With Quote




Last Updated on February 23, 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