3 registered members (Ayumi, Akow, AndrewAMD),
1,505
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Using a session's high/low
#464418
02/11/17 22:55
02/11/17 22:55
|
Joined: Feb 2014
Posts: 181
RTG
OP
Member
|
OP
Member
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: 66
dr_panther
Junior Member
|
Junior Member
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:
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);
}
|
|
|
|