Gamestudio Links
Zorro Links
Newest Posts
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
Release 2.68 replacement of the .par format
by Martin_HH. 09/23/25 20:48
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,175 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Using a session's high/low #464418
02/11/17 22:55
02/11/17 22:55
Joined: Feb 2014
Posts: 183
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 183
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.
Re: Using a session's high/low [Re: RTG] #464423
02/12/17 14:25
02/12/17 14:25
Joined: Aug 2016
Posts: 66
D
dr_panther Offline
Junior Member
dr_panther  Offline
Junior Member
D

Joined: Aug 2016
Posts: 66
Just a few general tips:
you could use StartMarket and EndMarket to define the session of a market, and then use dayHigh, and dayLow, it simply looks cleaner.

here is a first approximation to what you may need:

Code:
function run(){
StartDate = 20160901;
EndDate = 20160910;
BarPeriod = 15;
//BarZone = 6;
asset("SPX500");
 

StartMarket=0830; // <<<<
EndMarket=1515;   // <<<<


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

var session_low = dayLow(ET,1); // <<<<
var session_high = dayHigh(ET,1); // <<<<

 
plot("US Session High Price", session_high,MAIN, RED); 
plot("US Session Low Price", session_low, MAIN, GREEN); 

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

//Setup quartiles
plot("Q1", session_low + 0.25 * USRange,MAIN, BLUE); 
plot("Q2", session_low + 0.50 * USRange,MAIN, BLUE); 
plot("Q3", session_low + 0.75 * USRange,MAIN, BLUE); 

}



Moderated by  Petra 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1