Easy Language problems

stiv

Newbie
Messages
4
Likes
0
Hi, i wrote formula in EL but in forst line after "vars" compilation show me error, can you show me my mistake? My formula bellow:

vars: HH,LL,d;

HH=maxlist(H,H[1],H[2],H[3]);

LL=minlist(L,L[1],L[2],L[3]);

d[0]=C;

if C>HH[1] then d=LL; else

if C<LL[1] then d=HH; else

d=d[1];

if C crosses above d then buy( "sygnal long" ) 1 share this bar close ;


Thanks Stiv
 
FIrst you need to initialise the variables i.e. give them starting values which also tells EL what type of variable they are - numeric, alphanumeric etc.

Second, do not use d as a variable name. Although it will work d is a reserved word which means day or daily, so always check your variable names against the list of reserved words and avoid them. I suggest you call it dd for the time being.

Third, I assume you are trying to set the variable dd in line 4 to the closing price. If so this should read DD = close;

Fourth, you have semicolons in the wrong place in the IF statement.

I have not checked the logic of what you are trying to do but if you apply the above changes the code verifies. To check the logic it is worth putting in print statements at logical points in the code as in my example below. This output appears in the message log and helps testing logic errors in the code

vars: HH(0),LL(0),dd(0);

HH=maxlist(H,H[1],H[2],H[3]);

LL=minlist(L,L[1],L[2],L[3]);

dd = close;
Print (ELDateToString(date), " ", time, " dd at point A ", dd);

if C>HH[1] then dd=LL else
if C<LL[1] then dd=HH else
dd=dd[1];

Print (ELDateToString(date)," ", time, " dd at point B ", dd, " Close: ", C);

if C crosses above dd then buy( "sygnal long" ) 1 share this bar close ;
 
Top