Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (TipmyPip, AndrewAMD, Quad, aliswee, degenerate_762), 970 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 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: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
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: 61
D
dr_panther Offline
Junior Member
dr_panther  Offline
Junior Member
D

Joined: Aug 2016
Posts: 61
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 | chip programmers | 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