Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, ChrstphFr), 941 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
can SAR() be more fully implemented? #439126
03/27/14 09:54
03/27/14 09:54
Joined: Jul 2013
Posts: 522
D
dusktrader Offline OP
User
dusktrader  Offline OP
User
D

Joined: Jul 2013
Posts: 522
I am working with SAR() and I noticed the manual says "Provisionally implemented; uses the current asset price series and supports a single asset only"

Is it difficult to adjust SAR() to work in a multi-asset loop? Otherwise, do you know of a workaround or similar indicator?

Thanks

Re: can SAR() be more fully implemented? [Re: dusktrader] #439141
03/27/14 15:37
03/27/14 15:37
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
It can not be adjusted because it's sloppy implemented in the TA-Lib, using a static variable. Thus it can never support more than one asset. But of course, the SAR can be rewritten in lite-C and included in the indicators.c library. Maybe a user can do this?

Re: can SAR() be more fully implemented? [Re: jcl] #439197
03/28/14 12:50
03/28/14 12:50
Joined: May 2013
Posts: 245
S
swingtraderkk Offline
Member
swingtraderkk  Offline
Member
S

Joined: May 2013
Posts: 245
is this any better?

Code:
var PSAR(var AF, var Max)
{

static var	psar0;
static var	psar1;
static int	lng;
static var	af;
static var	ep;
static var	hp;
static var	lp;

if (is(INITRUN))
	{
		lng		= 1;						//assume long for initial conditions
		af 		= AF;						//init acelleration factor
		psar0		= 0;
		psar1		= 0;
		ep			= 0;
		hp			= 0;
		lp			= 0;
		
		return;								// do not run on bar 0
	}

if (Bar == 1)
	{
		psar0		= priceClose(0);		// initialise
		psar1		= priceClose(0);
		ep 		= priceHigh(0);		// init extreme point as assuming long
		hp 		= priceHigh(0);
		lp 		= priceLow(0);
		
		return psar0;	
	}

if (lng == 1)	psar0 = psar1 + af * (hp - psar1);
else				psar0 = psar1 + af * (lp - psar1);
  
int reverse =  0;     
     
if (lng == 1)								//check for reversal
     {
         if (priceLow(0) < psar0)
         	{
            	lng		= 0;
            	reverse	= 1;			//reverse position to short
            	psar0		= hp;			
            	lp			= priceLow(0);
            	af			= AF;
         	}
     }
else
     {
         if (priceHigh(0) > psar0)
         	{
            	lng		= 1;
            	reverse	= 1;        //reverse position to long
            	psar0		= lp;
            	hp			= priceHigh(0);
            	af			= AF;
         	}
     }

if (reverse == 0)
     {
         if (lng == 1)
         {
         	if (priceHigh(0) > hp)
            	{
             		hp  = priceHigh(0);
             		af += AF;
             		af  = min(af,Max); 
					}
            psar0 = min(psar0, min(priceLow(1),priceLow(2)));
         }
         else
         {
         	if (priceLow(0) < lp)
            	{
             		lp  = priceLow(0);
             		af += AF;
             		af  = min(af,Max); 
					}
            psar0 = max(psar0,max(priceHigh(1),priceHigh(2)));
         }
     	}
psar1	= psar0;
     	
return psar0;

}


Re: can SAR() be more fully implemented? [Re: swingtraderkk] #439202
03/28/14 16:08
03/28/14 16:08
Joined: Jul 2013
Posts: 522
D
dusktrader Offline OP
User
dusktrader  Offline OP
User
D

Joined: Jul 2013
Posts: 522
I'm thinking not, though I haven't had time to play with this yet. The issue, as I understand, is that the static variables need to be linked to the asset. When you use static vars inside the function, that would imply every time the function is called, it refers back to the same static history (regardless of the asset -- which is a problem because every iteration of Zorro would be flipping through multiple assets)

So to fix it, I think the function either needs to somehow be re-written not to use static vars (if even possible), or use static storage that is linked to the asset. AlgoVar is one potential option (those are statics linked to each asset) but since they are in limited supply (only 8 i think)... then it doesn't seem ideal.

Thanks for posting this code. It's a good starting point. Perhaps I can play around with this and see if I can come up with anything.

Re: can SAR() be more fully implemented? [Re: dusktrader] #439205
03/28/14 16:43
03/28/14 16:43
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You can either use AlgoVar, or a series. Both are asset linked. As far as I can see from the above code, most of those variables need not be static anyway.

Re: can SAR() be more fully implemented? [Re: jcl] #446483
10/17/14 03:52
10/17/14 03:52
Joined: Sep 2014
Posts: 24
M
mustang Offline
Newbie
mustang  Offline
Newbie
M

Joined: Sep 2014
Posts: 24
Thank you everyone for your suggestions and effort.
Zorro team, any news on the PSAR?
I think it's very important for any serious trading platform to have a proper implementation of the Parabolic SAR.

Alternatively, is there a way to use the PSAR from MT4 through the bridge if Zorro does not make it available natively?

Re: can SAR() be more fully implemented? [Re: mustang] #446541
10/20/14 17:27
10/20/14 17:27
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
It's certainly easier to write a PSAR in lite-C than using the MT4 bridge for it. But for us there was no reason for implementing a PSAR in lite-C so far. We have not yet seen that it could be used for a profitable system.

Re: can SAR() be more fully implemented? [Re: jcl] #446546
10/20/14 18:03
10/20/14 18:03
Joined: Sep 2014
Posts: 24
M
mustang Offline
Newbie
mustang  Offline
Newbie
M

Joined: Sep 2014
Posts: 24
A succesfull trader wrote in a book that amongst his methods, was the use of conventional indicators in a non-conventional way.

Could we make the request that Zorro team implements PSAR in Lite-C and let traders use it the they want?

Re: can SAR() be more fully implemented? [Re: mustang] #446547
10/20/14 18:20
10/20/14 18:20
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Sure. Use the ta-lib SAR, do a profitable system with it, and we'll implement at once a lite-C SAR. If an indicator can be shown to be useful in any way, you'll normally get it.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1