Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 945 guests, and 8 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
MACD + Flat Market Detector #418084
02/20/13 22:34
02/20/13 22:34
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
I tried to convert this free indicator and my current code is below.
Zorro says that "Error in 'line 22:
'FextMapBuffer6' undeclared identifier".

Why this happen?
Thanks in advance.

The original indicator.
http://www.pointzero-trading.com/FreeMetatraderDownloads/view/5

Code:
function run(){
	
 
int    FastEMA             = 9;
int    SlowEMA             = 26;
int    AvPeriod            = 400;
var    Gamma               = 0.75;


vars med = series(MedPrice());

vars median = series(MACD(med,FastEMA,SlowEMA,4));
vars FextMapBuffer6 = series(median[0] - median[1]);
vars FextMapBuffer5 = series(abs(FextMapBuffer6[0]));

var flat = EMA(FextMapBuffer5,AvPeriod);
vars FextMapBuffer3 = series((flat * Gamma));
vars FextMapBuffer4 = series(0 - (flat * Gamma));
}

if(FextMapBuffer6 > FextMapBuffer3)
exitShort();
enterLong();

if(FextMapBuffer6 < FextMapBuffer4)
exitLong();
enterShort();
}


Re: MACD + Flat Market Detector [Re: SFF] #418092
02/21/13 06:55
02/21/13 06:55
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Actually all it was from what I can tell is some wrong brackets in your code.

Originally Posted By: "Code"

function run(){
LookBack = 500;


int FastEMA = 9;
int SlowEMA = 26;
int AvPeriod = 400;
var Gamma = 0.75;


vars med = series(MedPrice());

vars median = series(MACD(med,FastEMA,SlowEMA,4));
vars FextMapBuffer6 = series(median[0] - median[1]);
vars FextMapBuffer5 = series(abs(FextMapBuffer6[0]));

var flat = EMA(FextMapBuffer5,AvPeriod);
vars FextMapBuffer3 = series((flat * Gamma));
vars FextMapBuffer4 = series(0 - (flat * Gamma));

if(FextMapBuffer6 > FextMapBuffer3) {
exitShort();
enterLong();
}
if(FextMapBuffer6 < FextMapBuffer4) {
exitLong();
enterShort();
}
}


Updated code above. Though I do have one question for jcl, when we compare series for our entry codes do we use the pointers (FextMapBuffer) to the series or the last variable in our series in this case (FextMapBuffer6[0])?

Re: MACD + Flat Market Detector [Re: TankWolf] #418093
02/21/13 07:35
02/21/13 07:35
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Great, Thank you.

I viewed a plot and I think something is wrong.
Could you check if this conversion is identical to the original code?

Re: MACD + Flat Market Detector [Re: SFF] #418097
02/21/13 08:16
02/21/13 08:16
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Well in the interests of the community I had a go at creating the indicator & it looks right but you should all test it probably before relying on it & by all means please make changes where you see necessary.

Quote:

function run(){
set(PLOTPRICE+PLOTNOW);
BarPeriod = 15;
LookBack = 500;
StartDate = 20120201;
NumDays = 1;

int FastEMA = 9;
int SlowEMA = 26;
int AvPeriod = 400;
var Gamma = 0.75;

vars med = series(MedPrice());

vars median = series(MACD(med,FastEMA,SlowEMA,4));
vars FextMapBuffer6 = series(median[0] - median[1]);
vars FextMapBuffer5 = series(abs(FextMapBuffer6[0]));
vars FextMapBuffer1 = series(0);
vars FextMapBuffer2 = series(0);

var flat = EMA(FextMapBuffer5,AvPeriod);
vars FextMapBuffer3 = series((flat * Gamma));
vars FextMapBuffer4 = series(0 - (flat * Gamma));

int NewWindow = 0;
plot("NewWindow",NewWindow,NEW,BLACK);
if(FextMapBuffer6[0] < FextMapBuffer6[1]) {
FextMapBuffer2[0] = FextMapBuffer6[0];
FextMapBuffer1[0] = 0;
plot("FextMapBuffer2",FextMapBuffer2[0],BARS,RED);
}
else if(FextMapBuffer6[0] > FextMapBuffer6[1]) {
FextMapBuffer1[0] = FextMapBuffer6[0];
FextMapBuffer2[0] = 0;
plot("FextMapBuffer1",FextMapBuffer1[0],BARS,BLUE);
}
plot("FextMapBuffer3",FextMapBuffer3[0],0,BLACK);
plot("FextMapBuffer4",FextMapBuffer4[0],0,BLACK);
}


Enjoy.

Last edited by TankWolf; 02/21/13 08:21. Reason: Edited Code
Re: MACD + Flat Market Detector [Re: TankWolf] #418099
02/21/13 08:39
02/21/13 08:39
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Good script.Thanks.

I check a plot again with your script and it looks that by comparing in Zorro and MT4 chart they are not same.

Please compare MT4 daily chart for EUR/USD with Zorro plot on 2012/09.
You know what I mean.

Last edited by SFF; 02/21/13 08:41.
Re: MACD + Flat Market Detector [Re: TankWolf] #418101
02/21/13 08:45
02/21/13 08:45
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Lol I just read the description again...

Quote:
Description

This is the standard MACD indicator drawing two flat lines instead of a signal line. It allows you to detect and trade flat/range-bound markets. It is nothing fancy and was only created to run some test, but it might be useful to you.


By the sounds of this its just MACD with these flat lines drawn Ive reattached code to show the difference please note Ive just got all the bars red on normal MACD not sure how you change them with the built in indicator to show blue for accelerating.

Quote:

function run(){
set(PLOTPRICE+PLOTNOW);
BarPeriod = 15;
LookBack = 500;
StartDate = 20120201;
NumDays = 1;

int FastEMA = 9;
int SlowEMA = 26;
int AvPeriod = 400;
var Gamma = 0.75;

vars med = series(MedPrice());

vars median = series(MACD(med,FastEMA,SlowEMA,4));
vars MACDHistory = series(rMACDHist);
vars FextMapBuffer6 = series(median[0] - median[1]);
vars FextMapBuffer5 = series(abs(FextMapBuffer6[0]));
vars FextMapBuffer1 = series(0);
vars FextMapBuffer2 = series(0);

var flat = EMA(FextMapBuffer5,AvPeriod);
vars FextMapBuffer3 = series((flat * Gamma));
vars FextMapBuffer4 = series(0 - (flat * Gamma));

int NewWindow2 = 0;
plot("NewWindow2",NewWindow2,NEW,BLACK);
plot("MACD",MACDHistory[0],BARS,RED);
plot("FextMapBuffer3",FextMapBuffer3[0],0,BLACK);
plot("FextMapBuffer4",FextMapBuffer4[0],0,BLACK);

int NewWindow = 0;
plot("NewWindow",NewWindow,NEW,BLACK);
if(FextMapBuffer6[0] < FextMapBuffer6[1]) {
FextMapBuffer2[0] = FextMapBuffer6[0];
FextMapBuffer1[0] = 0;
plot("FextMapBuffer2",FextMapBuffer2[0],BARS,RED);
}
else if(FextMapBuffer6[0] > FextMapBuffer6[1]) {
FextMapBuffer1[0] = FextMapBuffer6[0];
FextMapBuffer2[0] = 0;
plot("FextMapBuffer1",FextMapBuffer1[0],BARS,BLUE);
}
plot("FextMapBuffer3",FextMapBuffer3[0],0,BLACK);
plot("FextMapBuffer4",FextMapBuffer4[0],0,BLACK);
}



Re: MACD + Flat Market Detector [Re: TankWolf] #418102
02/21/13 09:40
02/21/13 09:40
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Why there is difference when the code is correctly converted?

Re: MACD + Flat Market Detector [Re: SFF] #418110
02/21/13 10:23
02/21/13 10:23
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Been playing some more there was still some errors Ive got it close but it still doesnt look exact though I think that may be because of the way the daily bars are grouped for FXCM and Zorro differently.

Quote:

function run(){
set(PLOTPRICE+PLOTNOW);
BarPeriod = 1440;
LookBack = 500;
StartDate = 20120901;
NumDays = 100;

int FastEMA = 9;
int SlowEMA = 26;
int AvPeriod = 400;
var Gamma = 0.75;

vars FextMapBuffer1 = series(0);
vars FextMapBuffer2 = series(0);

//Median
vars Price = series(price());
vars MedianPrice = series(SMA(Price,500));

vars median = series(MACD(MedianPrice,FastEMA,SlowEMA,4));
vars median1 = series(MACD(MedianPrice+1,FastEMA,SlowEMA,4));

//Difference
vars FextMapBuffer6 = series(median[0] - median1[0]);

//Save current absoulte value
vars FextMapBuffer5 = series(abs(FextMapBuffer6[0]));

//Flat lines
vars flat = series(EMA(FextMapBuffer5,AvPeriod));
vars FextMapBuffer3 = series((flat[0] * Gamma));
vars FextMapBuffer4 = series(0 - (flat[0] * Gamma));

int NewWindow = 0;
plot("NewWindow",NewWindow,NEW,BLACK);

//Deceleration
if(FextMapBuffer6[0] < FextMapBuffer6[1]) {
FextMapBuffer2[0] = FextMapBuffer6[0];
FextMapBuffer1[0] = 0;
plot("FextMapBuffer2",FextMapBuffer2[0],BARS,RED);
}
//Acceleration
else if(FextMapBuffer6[0] > FextMapBuffer6[1]) {
FextMapBuffer1[0] = FextMapBuffer6[0];
FextMapBuffer2[0] = 0;
plot("FextMapBuffer1",FextMapBuffer1[0],BARS,BLUE);
}
plot("FextMapBuffer3",FextMapBuffer3[0],0,BLACK);
plot("FextMapBuffer4",FextMapBuffer4[0],0,BLACK);
}



Re: MACD + Flat Market Detector [Re: TankWolf] #418155
02/21/13 15:34
02/21/13 15:34
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
How MT4 daily charts look depends on when the MT4 was started and to which broker it was connected. So you can not compare an MT4 chart to a chart of another platform.

There are several reasons for this. MT4 bars depend on the broker's time zone, while Zorro bars are time zone independent. Zorro's EMA and MACD are window length independent, while the MT4 EMA and MACD return different values dependent on the previous length of the chart.

So you will most likely not get the same signals from Zorro and from MT4 even when the algorithm is completely identical. You can also not load an MT4 EA from a forum and expect to get exactly the same trade signals as the guy who posted it.

Re: MACD + Flat Market Detector [Re: jcl] #418193
02/22/13 00:16
02/22/13 00:16
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Thank you for explaining JCL.

I will test both platforms and take a (more)profitable one.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1