I want to test out a trading idea on the S&P500. The basic premise is that the US CBOT session of the S&P500 defines a trading range for the Globex session.

It starts with the notion that the US CBOT session defines an upper and lower range for the GLOBEX session. The price feed I have from FXCM (SPX500) is a continuous almagamation of both sessions.

I need to take the MaxVal and MinVal between 0830 and 1515 Chicago time to set the hypothetical range for the following Globex session.ss

I believe I have achieved this in the attached code.

Next I want to setup quartiles between these two US session limits and project them into the globex session. This is where I atm having problems. When I run the code the variable Q1 doesnt print or plot.

Code follows
==========================================
// Attempt to code my S&P500 approach
//CBOT trading hours to 08:30 to 15:15
// Chicago offset relative to UTC is 6, Chicago relative to AEST is 16

function run(){
StartDate = 20170207;
BarPeriod = 15;
//BarZone = 6;
asset("SPX500");

vars PriceHigh = series(priceHigh());
vars PriceLow = series(priceLow());

if(tod(24) == 0830 and tod(24) <= 0831)
plot("US Session Open", priceLow()-1, TRIANGLE2, BLACK );

if(tod(24) >= 1515 and tod(24) <= 1516)
{
// HighPrice = MaxVal(Price, 27);

plot("US Session High Price", MaxVal(PriceHigh, 27), TRIANGLE4, RED);
plot("US Session Low Price", MinVal(PriceLow, 27), TRIANGLE, GREEN);

//calculate the range of the US session
var USRange = MaxVal(PriceHigh, 27) - MinVal(PriceLow, 27);
plot("USRange", USRange, NEW, BLUE);
printf("nUS Session High %.2f%", MaxVal(PriceHigh, 27));
printf("nUS Session Low %.2f%", MinVal(PriceLow, 27));
printf("nUS Session Range %.2f", USRange);

//Setup quartiles
var Q1 = MinVal(PriceLow, 27) + 0.25 * USRange;
plot("Q1", Q1,MAIN, LINE);
//this is the troublesome part
}
}


Last edited by RTG; 02/11/17 22:58.