Gamestudio Links
Zorro Links
Newest Posts
folder management functions
by 7th_zorro. 04/16/24 13:19
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/11/24 14:56
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (rki, Ayumi), 475 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
11honza11, ccorrea, sakolin, rajesh7827, juergen_wue
19045 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Cocos Wave Strategy #417895
02/19/13 11:41
02/19/13 11:41
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Hi,

I just made this code but it is not working correctly.
Where is wrong?

The strategy is based on this.
http://www.forexisbiz.com/showthread.php/1530-Lets-try-this-cocos-wave


Code:
var GSMOOTH(var price_,vars arr,var alfa){
	 var ret = pow(alfa,4)*price_ + 4*(1-alfa)*arr[0+1] - 6*pow(1-alfa,2)*arr[0+2] + 4*pow(1-alfa,3)*arr[0+3] - pow(1-alfa,4)*arr[0+4];
    return (ret);
}
  
var getAlfa(var p){
       var pis = 3.1415926535;
       var w = 2*pis/p;
	    var beta = (1 - cos(w))/(pow(1.414,2.0/3) - 1);
	    var alfa = -beta + sqrt(beta*beta + 2*beta);
	    return (alfa);
}

function run(){
	
  set(TICKS);
  
  
 
	
  int Fast=13;
  int Slow=26;
  int Signal=3;
  
  vars Fastalfa=series(getAlfa(Fast));
  vars Slowalfa=series(getAlfa(Slow));
  vars Signalalfa=series(getAlfa(Signal));
  vars Close=series(priceClose());
  vars ma = series();
  ma = series(GSMOOTH(Close[0],ma,Slowalfa[0]));
  vars maf = series();
  maf=series(GSMOOTH(Close[0],maf,Fastalfa[0]));
  vars mains=series(ma[0]-maf[0]);
  vars signal = series();
  signal=series(GSMOOTH(mains[0],signal,Signalalfa[0]));
  vars tmp=series(mains[0]-signal[0]);
  
  int MA_Period=80;
  var Deviation=0.1;
  int sMA, upper, down;
  
 
   vars sMA = series(SMA(series(priceClose(20)),MA_Period));
  var upper = sMA[0] * (1+Deviation/100);
   var down = sMA[0] * (1-Deviation/100);
   vars Close = series(priceClose());
    
  TakeProfit = 25*PIP;


if(crossOver(Close,upper)) {
  Stop = down - 10*PIP;
  enterLong();
}
if(crossUnder(Close,down)) {
  Stop = upper + 10*PIP;
  enterShort();
}
}


Last edited by SFF; 02/20/13 10:33.
Re: Cocos Wave Strategy [Re: SFF] #417923
02/19/13 16:45
02/19/13 16:45
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Ok. When you copy a strategy from some forum thread, the first step is understanding the strategy. Simply copying the MQ4 code will normally not do, because very often the MQ4 code posted on forums is already wrong. So you must 100% understand what the strategy does.

I do not understand this strategy, so can you explain to me in a few words when it enters and exits a trade?

Re: Cocos Wave Strategy [Re: jcl] #417974
02/19/13 23:23
02/19/13 23:23
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
It is just simple as the image.
We enter a trade when closeprice cross over/under a shifted envelope with a filter GMACD.
Exit is TP 25 pips and SL is when closeprice +/- 10 pips a under or upper band.
I have the other exit too, it is dynamical exit, when a buy condition happens short closes and reverse.

I hope this helps.

Last edited by SFF; 02/19/13 23:32.
Re: Cocos Wave Strategy [Re: SFF] #417996
02/20/13 08:13
02/20/13 08:13
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Then I have some more questions, because your code does not match your description.

- When the entry is at a crossover, where is the crossOver() function?

- And what purpose has the tmp[] series?

Re: Cocos Wave Strategy [Re: jcl] #417997
02/20/13 08:28
02/20/13 08:28
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Insted of crossOver function I use this code. Is this identical to that function?
priceClose(1) < upper && priceClose(0) > upper

tmp[] series is just a line of GMACD to filter a signal.

Re: Cocos Wave Strategy [Re: SFF] #418001
02/20/13 09:32
02/20/13 09:32
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
"priceClose(1) < upper && priceClose(0) > upper" is identical to a crossover, but "priceClose(1) > down && priceClose(0) > down" is not.

- tmp is not a line of GMACD. Why do you filter the signal with it? What is tmp supposed to be?

- And where is the SL?

Re: Cocos Wave Strategy [Re: jcl] #418002
02/20/13 09:45
02/20/13 09:45
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
I misunderstand about GMACD, it is a bar not a line, so when it is up it only enters long break out signal.

This is a SL code but I think it is not working correctly from LOGFILE.
if(priceClose == upper + 10*PIP)
exitShort();

if(priceClose == down - 10*PIP)
exitLong();

I expect this code is identical to crossUnder.
"priceClose(1) > down && priceClose(0) < down"

Last edited by SFF; 02/20/13 09:48.
Re: Cocos Wave Strategy [Re: SFF] #418004
02/20/13 09:55
02/20/13 09:55
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Yes, this version is identical to a crossUnder.

Your SL code does not work. This would be a correct entry with SL:

Code:
if(tmp[0]>tmp[1] && crossOver(Close,upper)) {
  Stop = down - 10*PIP;
  enterLong();
}
if(tmp[0]<tmp[1] && crossUnder(Close,down)) {
  Stop = upper + 10*PIP;
  enterShort();
}



Re: Cocos Wave Strategy [Re: jcl] #418006
02/20/13 10:04
02/20/13 10:04
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Great, Thank you.
I will try this new code and I will let you know if I have more problems.

The correct code was updated above.

Last edited by SFF; 02/20/13 10:34.
Re: Cocos Wave Strategy [Re: SFF] #418007
02/20/13 10:22
02/20/13 10:22
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Here is a code without GMACD.
By viewing a trade log It is correct.
But a short trade should have been on 12/05/06 but not on the daily TF.
Could you check log and chart and explain why.

Code:
function run(){
  
  set(LOGFILE);
  int MA_Period=80;
  var Deviation=0.1;
  int sMA, upper, down;
  

 
   vars sMA = series(SMA(series(priceClose(20)),MA_Period));
  var upper = sMA[0] * (1+Deviation/100);
   var down = sMA[0] * (1-Deviation/100);
   vars Close = series(priceClose());
    
  TakeProfit = 25*PIP;


if(crossOver(Close,upper)) {
  Stop = down - 10*PIP;
  enterLong();
}
if(crossUnder(Close,down)) {
  Stop = upper + 10*PIP;
  enterShort();
}
}


Page 1 of 2 1 2

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