Coding help - page 309

 
Mimicri20z:
Hey, I also Need coding help.

I want to put a delay between 2 alerts "down" and "downdel" of 1-5s. It is inside an if condition.

How can I do it best?

if(dClose < dLastClose) {

// down

if (!bTestMode){

Alert ("down");

...

x Seconnds DELAY HERE

...

Alert ("downdel");

rest of IF condition;

}

Try like this :

static datetime lastAlert = 0;

if ((TimeCurrent()-lasteAlert)>=pauseBetweenAlerts)

{

lastAlert = TimeCurrent();

//

// the rest of alerting code

//

}

You can not use sleep() (which is usually used to inserted for a delay) in indicators that is why the upper solution

If you make a loop that waits some time, the rest of your stuff (indicators, EAs, scripts) will not work until the loop is exited and normal processing is resumed. If, on the other hand, that is an Ea, simply put Sleep(number of miliseconds) in the place of "x Seconnds DELAY HERE"

 
mladen:
Try like this : If you make a loop that waits some time, the rest of your stuff (indicators, EAs, scripts) will not work until the loop is exited and normal processing is resumed. If, on the other hand, that is an Ea, simply put Sleep(number of miliseconds) in the place of "x Seconnds DELAY HERE"

Thanks MLADEN, such a Loop would be exactly what I Need between the 2 alerts. If alert "down" comes it can wait 1-5s after that without doing anything, then alert "downdel" and continue.

I dont want to wait between trades, it is one sequence... first alert > wait > second alert ... continue.

Thanks again!

 
mladen:
The code is correct Are the magic numbers for all symbols always the same?

No i have different magic number for buy or sell basket.

Exemple :

Basket 1: Buy Eurusd / Buy Usdchf : magic number 1

Basket 2 : Sell Eurusd / Sell Usdchf : magic number 2

So, i close the basket when in profit.

Tell me where i made the mistake ?

Thanks !

 
Big Joe:
No i have different magic number for buy or sell basket.

Exemple :

Basket 1: Buy Eurusd / Buy Usdchf : magic number 1

Basket 2 : Sell Eurusd / Sell Usdchf : magic number 2

So, i close the basket when in profit.

Tell me where i made the mistake ?

Thanks !

Joe

You are adding up only profits for one magic number (this line

if (OrderMagicNumber() == MagicNumber)

Yo can simply leave that line out if all the orders of your account are a part of the same basket

 

mladen,

Thank you so much for your response. However, what caught my eye, was your comment at the end, "It would be something else then". This "something else", by re-writing it, would it give me what I'm looking for? Meaning the signal would alert on the opening of the next bar? Thank you for your time.

Genesisman,

 
Genesisman:
mladen,

Thank you so much for your response. However, what caught my eye, was your comment at the end, "It would be something else then". This "something else", by re-writing it, would it give me what I'm looking for? Meaning the signal would alert on the opening of the next bar? Thank you for your time.

Genesisman,

It is simple : when you change the way how something is calculated you get something completely different a lot of time. Classical example : when people ask to make solar wind non repainting and they expect that when it is done the results are going to be exactly the samem while they do not look anything similar any more

 
hullsy:
Can someone please tell me if what I want is possible.

On a H1 chart I am using 1 x Hull MA40 with 1 x MA MTF 240 and 1 x MA MTF 1440.

Can the Hull be made to alert only when the 3 MA's are moving in the same direction?

Cheers, Steve.

I just noticed the three indicators im using are mladen files.

Maybe he can help.

Thanks in advance for any input.

 

mladen,

Thank you my friend.

 

delete it please

 

I will be very thankful if somebody will make these indicators working on new MT4