How to code? - page 193

 

Need help for a alert

hello,

first: sorry for my english. iam realy bad in english.

so, but my question ist: how can i programm a alert signal if tenkan and senkou cruise each other? long and short.

can somebody help me, please!!!

thanks a lot,

bye benjamin

Files:
ichimoku.mq4  5 kb
 

Small problem..

Can anyone help me to make function to act fallowing-

I have: A=0

When indicator hits certain point nr1: A=1.

And when indicator left this certain point: A=1 (A still holds his value).

When indicator hits certain point nr2: A=0.

Any ideas are very welcome!

Thanks.

 
ohir:
Can anyone help me to make function to act fallowing-

I have: A=0

When indicator hits certain point nr1: A=1.

And when indicator left this certain point: A=1 (A still holds his value).

When indicator hits certain point nr2: A=0.

Any ideas are very welcome!

Thanks.

It's hard to know exactly what you want with so little to go on.

How about

A=0;

if (Bid >= nr1 && Bid < nr2) A=1;

if (Bid >= nr2) A=0;

Replace Bid with O,H,L,C or any any other variable you want.

But you also have to think about what happens if price hits nr1 then falls instead of going to nr2.

Just remember I am only guessing what you want.

hope it was some help

 

How can I access a file on my hard drive which is not in /experts/files folder?

btw, is it possible to execute windows commands (e.g. copy) in mql4? maybe with a dll file?

Thank you in advance :-)

 

Re swgman1

Thanks, swgman1!

... but its still problem for me.

What I am trying to say-

Beginning

Indicator1 value is 0

Indicator2 value is 0

A=0

Step1

Indicator1 value is 1

Indicator2 value is 0

A=1

Step2

Indicator1 value is 0

Indicator2 value is 0

A=1

Step3

Indicator1 value is 0

Indicator2 value is 1

A=0

Hope its more clear

Thanks.

 

Weird loop..

I made some weird loop in my test program:

int A=1

for(A=0, A=1; A==(buy condition); A++)

Buy if(A=1)

Close if(Bid>0)

It trades after contition disappears... BUT, it does not close trades right after opening (like it should- Bid>0). Now my pogram closes all trades only if buy condition appears.

What does this loop actually doing?

 
ohir:
I made some weird loop in my test program:

int A=1

for(A=0, A=1; A==(buy condition); A++)

Buy if(A=1)

Close if(Bid>0)

It trades after contition disappears... BUT, it does not close trades right after opening (like it should- Bid>0). Now my pogram closes all trades only if buy condition appears.

What does this loop actually doing?

Hey ohir,

I have never really looked into the writing of EA's, I have only done indicators, so I'm not the best person to ask.

However with a for loop you state the starting point (bar number), then your condition to keep the loop running, then increment your starting point for next loop.

for (x=bars-1;x>0;x--) this will loop though all bars on the chart from the first to the last.

for (x=0;x<bars-1;x++) loops back the other way

x is just the counter of the loop

yours starts at bar 0 or 1 (not sure how it works with the comma there) then while your counter equals buy condition (impossible me thinks) continue the loop, then increment counter.

Try something like

for (x=0;x<=bars-1;x++)

{

if (A[x]==1) OrderSend(blah,blah,blah)

if (Bid[x]>0) OrderClose(blah,.....)

}

I dont know if any of that helps but its the best I can do. Maybe someone with more knowledge may be able to help more.

Good Luck

Swagman

 

Help Please

Ok got it --discard this post

Files:
trenddetect.mq4  14 kb
 

Metatrader and neg numbers

Anyone know a better way to code this???? Cant get metatrader to read the exact numbers some are positive and others are neg numbers.

if (Use_Entry_Delay == true) {

//if (trendis == 0 || trendis == -0) {

//EntryAllowed= True;

//Print ("Entry Allowed");

//}

if (trendis == 0.0010){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0011){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0012){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0013){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0014){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0015){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0016){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0017){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0018){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0019){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0020){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0021){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0022){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0023){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0024){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0025){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0026){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0010){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0011){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0012){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0013){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0014){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0015){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0016){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0017){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0018){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0019){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0020){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0021){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0022){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0023){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0024){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0025){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0026){ EntryAllowed= true; Print ("Entry Allowed"); }

}else{

EntryAllowed= false;

Print ("Entry Not Allowed");

}

}

-----------------------------------------

so basically if its -0.0010 or lower dont do it

if its above 0.0026 or above -0.0026 don't do it.

Tried many things cant get it to do it.

Any HELP please please please.

 
niteuser:
Anyone know a better way to code this???? Cant get metatrader to read the exact numbers some are positive and others are neg numbers.

if (Use_Entry_Delay == true) {

//if (trendis == 0 || trendis == -0) {

//EntryAllowed= True;

//Print ("Entry Allowed");

//}

if (trendis == 0.0010){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0011){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0012){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0013){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0014){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0015){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0016){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0017){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0018){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0019){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0020){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0021){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0022){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0023){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0024){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0025){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == 0.0026){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0010){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0011){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0012){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0013){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0014){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0015){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0016){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0017){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0018){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0019){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0020){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0021){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0022){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0023){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0024){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0025){ EntryAllowed= true; Print ("Entry Allowed"); }

if (trendis == -0.0026){ EntryAllowed= true; Print ("Entry Allowed"); }

}else{

EntryAllowed= false;

Print ("Entry Not Allowed");

}

}

-----------------------------------------

so basically if its -0.0010 or lower dont do it

if its above 0.0026 or above -0.0026 don't do it.

Tried many things cant get it to do it.

Any HELP please please please.
if ((trendis = 0.0026)) { EntryAllowed= true; Print ("Entry Allowed"); }