NexusFi: Find Your Edge


Home Menu

 





PSP Class - Can't any get Close value past [1]


Discussion in EasyLanguage Programming

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




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

I'm just starting with trying to work with the PriceSeriesProvider (PSP) Class.

I wrote the following code, but I get an error as soon as I tried to change PSP1.Close to anything beyond 0 or 1. (Eventually I want to get the value for PSP1.Clsoe[14] or something similar).

What am I doing wrong here that prevents me from looking at the value for anything greater than Close[1]?


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

var: PriceSeriesProvider PSP1(null), TestValue(null);

Input: SecondSymbol("SPY");

once
	begin
	PSP1 = new PriceSeriesProvider ;
	PSP1.Symbol = SecondSymbol ;
	PSP1.Interval.ChartType = DataChartType.Bars ;
	PSP1.Interval.IntervalType = DataIntervalType.Daily ;
	PSP1.Interval.IntervalSpan = 1 ;
	PSP1.Range.FirstDate = 
	DateTime.FromELDateAndTime( Date[MaxBarsBack], 
		Time[MaxBarsBack] ) ; 
	PSP1.Realtime = true;
	PSP1.Load = true ;
	end ;

TestValue = PSP1.Close[14];

plot1(TestValue, "PSP Close");


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Penalties in Budapest, Peace Deadline in Tehran: Arsenal …
Prediction Markets & Event Contracts
Hormuz Surges From 14% to 26.5% Intraday as Irans Answer …
Prediction Markets & Event Contracts
Fed Hike Odds at 57% After Warsh: England Surges 12.9%, …
Prediction Markets & Event Contracts
Fabrication or Framework? Irans Denied MOU Explains the …
Prediction Markets & Event Contracts
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643

CreativelyChris,

since PSPs load asynchronously your code might be trying to access values that are not yet present. As a safety net you can try checking the PSP has enough values using "PSP1.Count" before you access a certain index. For performance reasons you can use a boolean flag that you set to true once when the PSP has enough values. This way you avoid having to check this on every bar.

Depending on your MaxBarsBack setting it is also not guaranteed that the PSP holds 14 bars back when you try to access it on the first bar. The check mentioned above can help preventing the error message in that case, too.

Regards,

ABCTG


CreativelyChris View Post
I'm just starting with trying to work with the PriceSeriesProvider (PSP) Class.

I wrote the following code, but I get an error as soon as I tried to change PSP1.Close to anything beyond 0 or 1. (Eventually I want to get the value for PSP1.Clsoe[14] or something similar).

What am I doing wrong here that prevents me from looking at the value for anything greater than Close[1]?


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

var: PriceSeriesProvider PSP1(null), TestValue(null);

Input: SecondSymbol("SPY");

once
	begin
	PSP1 = new PriceSeriesProvider ;
	PSP1.Symbol = SecondSymbol ;
	PSP1.Interval.ChartType = DataChartType.Bars ;
	PSP1.Interval.IntervalType = DataIntervalType.Daily ;
	PSP1.Interval.IntervalSpan = 1 ;
	PSP1.Range.FirstDate = 
	DateTime.FromELDateAndTime( Date[MaxBarsBack], 
		Time[MaxBarsBack] ) ; 
	PSP1.Realtime = true;
	PSP1.Load = true ;
	end ;

TestValue = PSP1.Close[14];

plot1(TestValue, "PSP Close");


Follow me on X Reply With Quote




Last Updated on February 7, 2022


© 2026 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 - Downloads - Top
no new posts