Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 12,420 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Script crash #410743
11/08/12 00:50
11/08/12 00:50
Joined: Nov 2012
Posts: 19
B
Boris Offline OP
Newbie
Boris  Offline OP
Newbie
B

Joined: Nov 2012
Posts: 19
Zorro keeps crashing when I try to run this script and I have no idea why. I think the script is ok but any ideas would be appreciated:

I wanted to thank the responders to my HMA script. I am still trying to get it to work but hopefully we can get a copy of it into the indicators.c for the next version.


function run()
{
var *ClosePrice = series(priceClose());
var *EMA17 = series(EMA(ClosePrice,17));
var *EMA35 = series(EMA(ClosePrice,35));
var *EMABuySignal = series(0);
var *EMASellSignal = series(0);
var *RSIBuySignal= series(0);
var *RSISellSignal= series(0);



if(EMA17 > EMA35)
EMABuySignal=1;
else
EMABuySignal=0;

if(EMA17 < EMA35)
EMASellSignal=1;
else
EMASellSignal=1;

if(RSI(ClosePrice,16) > 50)
RSIBuySignal=1;
else
RSIBuySignal=0;

if(RSI(ClosePrice,16) < 50)
RSISellSignal=1;
else
RSISellSignal=0;


if((EMABuySignal[0] +RSIBuySignal[0] > 1.5) && (EMABuySignal[1] +RSIBuySignal[1] < 1.5))

enterLong();

if((EMASellSignal[0] +RSISellSignal[0] > 1.5) && (EMASellSignal[1] +RSISellSignal[1] < 1.5))

enterShort();
}

Re: Script crash [Re: Boris] #410744
11/08/12 02:03
11/08/12 02:03
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
The reason for the crash is because you have alot of coding errors in your script. Ive retyped out your code for you to see where Ive changed it.

Quote:

function run()
{
BarPeriod = 60;
NumWFOCycles = 8;
NumBarCycles = 4;
set(PARAMETERS+FACTORS+TESTNOW+LOGFILE);

var *ClosePrice = series(priceClose());
var *EMA17 = series(EMA(ClosePrice,17));
var *EMA35 = series(EMA(ClosePrice,35));
var *RSI16 = series(RSI(ClosePrice,16));

static int crossed = 0;
int Delay = 1;
if(crossOver(EMA17,EMA35))
crossed = Delay;
else if(crossUnder(EMA17,EMA35))
crossed = -Delay;

if(crossed > 0 && RSI16[0] > 50) {
enterLong();
crossed = 0;
}
else if(crossed < 0 && RSI16[0] < 50) {
enterShort();
crossed = 0;
}
else
crossed -= sign(crossed);
}


Basically Im still not an expert myself but from what I can tell with your script you created a pointer called EMABuySignal then you tried to fill it with an integer. Use the crossOver & crossUnder functions with a delay for checking to see whether EMAs have crossed.

Re: Script crash [Re: TankWolf] #410746
11/08/12 02:33
11/08/12 02:33
Joined: Nov 2012
Posts: 19
B
Boris Offline OP
Newbie
Boris  Offline OP
Newbie
B

Joined: Nov 2012
Posts: 19
Thanks I had this script before:

function run()
{
var *ClosePrice = series(priceClose());
var *EMA17 = series(EMA(ClosePrice,17));
var *EMA35 = series(EMA(ClosePrice,35));



if((crossUnder(EMA17,EMA35)) and (RSI(ClosePrice,16) < 50))

enterShort();

if(crossOver(EMA17,EMA35) and (RSI(ClosePrice,16) > 50))

{
enterLong();}

}

However, I did not know how to enter a trade if EMA's crossed and then the RSI turned positive after the cross.

You are saying that using the delay it will trigger a buy if RSI turns up after a positive ema cross has occurred in a prior period? What if I wanted to add one more condition and get executions only when all 3 are met? Thanks a lot for your help

Re: Script crash [Re: Boris] #410747
11/08/12 03:44
11/08/12 03:44
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Yes exactly you can set the delay longer than 1 bar, so if you changed delay to say 3 for example. The entry conditions would check to see if the EMAs have crossed in the last 3 bars & if they have and the other conditions are met then the trade will enter.

If you then say wanted to add a 3rd condition lets say for example the Stoch has to be above 20 or below 80 also.

Quote:

function run()
{
BarPeriod = 60;
NumWFOCycles = 8;
NumBarCycles = 4;
set(PARAMETERS+FACTORS+TESTNOW+LOGFILE);

var *ClosePrice = series(priceClose());
var *EMA17 = series(EMA(ClosePrice,17));
var *EMA35 = series(EMA(ClosePrice,35));
var *RSI16 = series(RSI(ClosePrice,16));
var *Stoch1 = series(Stoch(14,3,MAType_SMA,3,MAType_SMA));

static int crossed = 0;
int Delay = 1;
if(crossOver(EMA17,EMA35))
crossed = Delay;
else if(crossUnder(EMA17,EMA35))
crossed = -Delay;

if(crossed > 0 && RSI16[0] > 50 && Stoch1[0] > 20) {
enterLong();
crossed = 0;
}
else if(crossed < 0 && RSI16[0] < 50 && Stoch1[0] < 80) {
enterShort();
crossed = 0;
}
else
crossed -= sign(crossed);
}


Hope this helps, and if Ive advised incorrectly anyone please feel free to correct.

Re: Script crash [Re: TankWolf] #476712
03/25/19 14:07
03/25/19 14:07
Joined: Sep 2017
Posts: 164
TipmyPip Online
Member
TipmyPip  Online
Member

Joined: Sep 2017
Posts: 164
What has happened to NumBarCycles variable?


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1