NexusFi: Find Your Edge


Home Menu

 



Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now, It is Free
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)


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


Discussion in EasyLanguage Programming

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




 
Search this Thread

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

(login for full post details)
  #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?
NT8 PnF Crowd Funding
NinjaTrader
App for low-lag news print readouts?
Traders Hideout
EARNMAX Scam
Trading Reviews and Vendors
BollingerPro discussion
The Elite Circle
Can Dump be caught with Algo Trade
Crypto Futures
 

(login for full post details)
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,416 since Apr 2013
Thanks Given: 437
Thanks Received: 1,613

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 Twitter Reply With Quote





Last Updated on February 7, 2022


© 2023 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