Gamestudio Links
Zorro Links
Newest Posts
AssetAdd() vs. modern asset list?
by jcl. 02/21/24 15:01
How many still using A8
by Aku_Aku. 02/20/24 12:18
Zorro Trader GPT
by TipmyPip. 02/16/24 06:53
Support PEEK for time and calendar functions
by AndrewAMD. 02/14/24 22:23
Deeplearning Script
by tomaslolo. 02/07/24 18:28
The Super-System
by TipmyPip. 02/06/24 19:32
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 594 guests, and 7 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
Weekly Pivots #482291
01/25/21 21:16
01/25/21 21:16
Joined: Jan 2021
Posts: 2
E
EBMMLuke Offline OP
Guest
EBMMLuke  Offline OP
Guest
E

Joined: Jan 2021
Posts: 2
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


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;
		}
	}
}

Re: Weekly Pivots [Re: EBMMLuke] #487186
02/03/23 18:02
02/03/23 18:02
Joined: Apr 2022
Posts: 1
London
P
paulk Offline
Guest
paulk  Offline
Guest
P

Joined: Apr 2022
Posts: 1
London
I'm trying to do same thing, just for UTC time (as I guess it's easier first step), but stuggling. Would you know how to Plot let's say JUST weekly Close or weekly Open based on UTC (at midnight)? For you might help code examples at the end of this https://zorro-project.com/manual/en/barperiod.htm.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1