Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, AndrewAMD), 822 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Highest value #436785
02/02/14 09:27
02/02/14 09:27

L
liftoff
Unregistered
liftoff
Unregistered
L



Are there math functions in zorro that returns the highest or minimum values in a series of values?

Re: Highest value [Re: ] #436795
02/02/14 16:51
02/02/14 16:51
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline
Serious User
DdlV  Offline
Serious User
D

Joined: Jun 2013
Posts: 1,609
You mean like MaxVal and MinVal? They're on the Signal Processing page in the manual...

Re: Highest value [Re: DdlV] #436807
02/02/14 19:18
02/02/14 19:18

L
liftoff
Unregistered
liftoff
Unregistered
L



Ok so this is what I am trying to do.
Code:
function run()
{
//	set(PARAMETERS);
	BarPeriod = 240; // 4 Hour bars
	StartDate = 2009;
//	EndDate =  2012;
	LookBack = 2880;
	Hedge = 0;
	
	//First Pig
	vars Price = series(price());
	vars SMAW = series(SMA(Price,1650)); // Weekly Trend (SMA 55)
	
	//Second Pig
	vars SMAD = series(SMA(Price,126));  // Daily Trend (SMA 21)
	
	//Third Duck
	vars SMA4H = series(SMA(Price,34));  // 4 Hour Trend (SMA 34)
	
	vars StopCal = series(ATR(14),14);
	var HighATR = MaxVal(StopCal,0);
	var LowATR =	MinVal(StopCal,0);
				
	Stop = ((HighATR-LowATR)*.25)+((abs(SMA4H[0]-Price[0]))*PIP);
	Trail = ((HighATR-LowATR)*.25)+((abs(SMA4H[0]-Price[0]))*PIP);
	
	
	if(Price[0]>SMAW[0] && Price[0]>SMAD[0] && Price[0]>SMA4H[0]){
		enterLong();
	} 
	else if(Price[0]<SMAW[0] && Price[0]<SMAD[0] && Price[0]<SMA4H[0]){
		enterShort();
	}
}



So any ideas on how I can get the stop to work?
The original strategy can be found here. Here

Re: Highest value [Re: ] #436814
02/03/14 07:10
02/03/14 07:10
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline
Serious User
DdlV  Offline
Serious User
D

Joined: Jun 2013
Posts: 1,609
Well, I've never tried TimePeriod=0 in MaxVal or MinVal, and don't see that there's any default in the manual. With TimePeriod=0, won't HighATR and LowATR always be 0? Have you tried any debug printf's to see what's going on?

Do you want the Max and Min over the 14? So it should be HighATR=MaxVal(StopCal,14) and similarly for LowATR?

Re: Highest value [Re: DdlV] #436825
02/03/14 12:03
02/03/14 12:03

L
liftoff
Unregistered
liftoff
Unregistered
L



I wanted to get the max and min of the 14 values in the StopCal series.

Re: Highest value [Re: ] #436839
02/03/14 18:10
02/03/14 18:10
Joined: Dec 2013
Posts: 11
J
Jeff_Raven Offline
Newbie
Jeff_Raven  Offline
Newbie
J

Joined: Dec 2013
Posts: 11
As DdIV said,

Code:
HighATR=MaxVal(StopCal,14);
LowATR=MinVal(StopCal,14);



will give you what you want. I just tried it with another indicator I was working on and it works fine.

And thanks for asking the question, liftoff, and also thanks to you DdIV for answering. I was looking for this exact function over the weekend and couldn't find it. laugh

Re: Highest value [Re: ] #436840
02/03/14 18:18
02/03/14 18:18
Joined: May 2013
Posts: 245
S
swingtraderkk Offline
Member
swingtraderkk  Offline
Member
S

Joined: May 2013
Posts: 245
Code:
vars StopCal = series(ATR(14));
var HighATR = MaxVal(StopCal,14);
var LowATR =	MinVal(StopCal,14);



but why add .25 of the difference between high and low atr values to the gap between price and sma:

(HighATR-LowATR)*.25

Not sure what this adds to your stop & trail, it's likely to be a very small % of ATR.

Re: Highest value [Re: swingtraderkk] #436845
02/03/14 20:56
02/03/14 20:56

L
liftoff
Unregistered
liftoff
Unregistered
L



thanks...was just working on idea from a forum. thanks for the input


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1