Posted By: EBMMLuke
Weekly Pivots - 01/25/21 21:16
Hi all!
I'm new to Zorro and am currently playing around with my first strategy.
I'm struggling with generating weekly pivots. As there is no weekly piv function built in, I collect High, Low, Close prices of a trading week in an if statement.
What I want zorro to do is to start collecting price at the first bar of the week, stop collecting at the last bar, then do the calculation. The trading week shall start after NY close and ends with NY close.
To get the correct prices (bars), I would have to start at "StartWeek = 72100" and end at "EndWeek = 52200", which is not possible (Start > End).
Any ideas how to solve this?
Thanks a lot!
Luke
I'm new to Zorro and am currently playing around with my first strategy.
I'm struggling with generating weekly pivots. As there is no weekly piv function built in, I collect High, Low, Close prices of a trading week in an if statement.
What I want zorro to do is to start collecting price at the first bar of the week, stop collecting at the last bar, then do the calculation. The trading week shall start after NY close and ends with NY close.
To get the correct prices (bars), I would have to start at "StartWeek = 72100" and end at "EndWeek = 52200", which is not possible (Start > End).
Any ideas how to solve this?
Thanks a lot!
Luke
Code
var WeeklyClose = 0; var WeeklyLow = 1000; var WeeklyHigh = 0; var Low; var High; var PivotPoint = 0; var S61 = 0; var R61 = 0; var CalcPivots = 0; var HighLow; vars WeeklyPivot; vars WeeklyS61; vars WeeklyR61; var MarketActive; function run() { set(PLOTNOW); BarPeriod = 60; LookBack = 24*10; BarMode = BR_FLAT + BR_WEEKEND; if (BarPeriod == 1440) { BarOffset = 21*60; BarMode = BR_FLAT + BR_WEEKEND; } if (BarPeriod == 240) { BarOffset = 60; BarMode = BR_FLAT + BR_WEEKEND; } asset = "EURUSD_2020"; StartWeek = 72100; //UTC EndWeek = 52200; //UTC StartDate = 20200314; EndDate = 20200322; const int NYMarketOpen = 10000; // ET time const int NYMarketClose = 52100; // ET time vars WeeklyPivot = series(PivotPoint); vars WeeklyS61= series(S61); vars WeeklyR61= series(R61); plot("Pivot", WeeklyPivot, LINE, RED); plot("S61", WeeklyS61, LINE, BLUE); plot("R61", WeeklyR61, LINE, BLUE); //start collecting prices if(NYMarketOpen <= tow(0) && tow(0) <= NYMarketClose) { //if(StartWeek <= tow(0) && tow(0) <= EndWeek) { //printf("\n\n Bar in Trading Week"); //printf("\n Date : %s", strdate(YMD,0)); //printf("\n tow = %d", tow(0)); Low = priceLow(); High = priceHigh(); WeeklyClose = priceClose(); if(Low < WeeklyLow) { WeeklyLow = Low; } if(High > WeeklyHigh) { WeeklyHigh = High; } printf("\n\n Date : %s", strdate(YMD,0)); printf("\n tow = %d", tow(0)); printf("\n Low = %f", WeeklyLow); printf("\n High = %f", WeeklyHigh); printf("\n Close = %f", WeeklyClose); CalcPivots = 1; } else { printf("\n\n Bar not in Trading Week"); printf("\n Date : %s", strdate(YMD,0)); if(CalcPivots == 1) { PivotPoint = ((WeeklyLow + WeeklyHigh + WeeklyClose) / 3); HighLow = (WeeklyHigh - WeeklyLow); S61 = PivotPoint - 0.618 * HighLow; R61 = PivotPoint + 0.618 * HighLow; CalcPivots = 0; printf("\n Weekly Close : %f", WeeklyClose); printf("\n Weekly Low : %f", WeeklyLow); printf("\n Weekly High : %f", WeeklyHigh); printf("\n Pivotpoint : %f", PivotPoint); printf("\n S61 : %f", S61); printf("\n R61 : %f", R61); WeeklyClose = 0; WeeklyLow = 1000; WeeklyHigh = 0; } } }