NexusFi: Find Your Edge


Home Menu

 





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


Discussion in EasyLanguage Programming

Updated
    1. trending_up 3,978 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]

  #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?
Quant vue
Trading Reviews and Vendors
What broker to use for trading palladium futures
Commodities
Cheap historycal L1 data for stocks
Stocks and ETFs
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

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


© 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