Ask! - page 85

 
cico707:
I have tried this Ea on the currency GBP/USD and I think that he can give good results with a trailing stop.

Who helps me to insert a trailing stop?

THANKS

BACKTEST GBPJPY

 

How do I express the following in MQL:-

if(boolean_condition_is_true AND (this_is_true OR that_is_true))

That is to say if boolean_condition is true AND (either this_is_true OR that_is_true) THEN do_something.

Anyone?

 

In MQL, to change the sign of an identifier from positive to negative the syntax is: A = - A However, the reverse doesn;t seem to work out ie: A = + A. How can I change the sign of a negative value into a positive?

 
Sadly:
In MQL, to change the sign of an identifier from positive to negative the syntax is: A = - A However, the reverse doesn;t seem to work out ie: A = + A. How can I change the sign of a negative value into a positive?

A = -A; //Always works ...

Or :

A *= -1;

 
Sadly:
How do I express the following in MQL:-

if(boolean_condition_is_true AND (this_is_true OR that_is_true))

That is to say if boolean_condition is true AND (either this_is_true OR that_is_true) THEN do_something.

Anyone?

if(b1 && (b2 || b3))

{

do_something

}

 

Thank you Michel. Using what you've suggested A *= + A does indeed give a positive sign ie: changes -A to +A.

 
Michel:
if(b1 && (b2 || b3))

{

do_something

}

Here;s what I am doing ...

if(Alarm_Reset && (stepSignalBuffer[shift] Upr_level ))

{

if(stepSignalBuffer[shift] < Lwr_level)

{

PlaySound("twank.wav");

}

else

{

PlaySound("tick.wav");

}

Alarm_Reset = false;

}

else

{

Alarm_Reset = true;

}

}

That is,ifthe alarm has been reset (to true) and either signalbuffer < lwr_level orsignalbuffer > upr_level

Play one sound if the signalbuffer is below the lower level or another sound if above the upper level. Set the alarm to false (don't want another alarm going off if it's already the done.

else

Reset the alarm (ie: signalbuffer is outside of the lower_level and the upper_level)

Unfortunately that's not what's happening but at least I know that the code is correct and it's probably down to the logic.

Thank you again Michel.

EDIT: I've just commented stepSignalBuffer[shift] and it's value is always ZERO! I feel such an idiot.

 
Sadly:
Thank you Michel. Using what you've suggested A *= + A does indeed give a positive sign ie: changes -A to +A.

No, this is wrong, I said: A *= -1; not A *= +A;

This flipflop the sign; but if you need to have a positive number, use the MathAbs() function : A = MathAbs(A); Wathever is A , it will become positif.

 

Weekend test code

Hi guru,

Are there any server can feed price to give us chance test our code at Saturday and Sunday ?

I mean if there possible to make simulator server to give chance to test at weekend ?

This idea come because of :

1. While at workdays, we are seriously to watch our chart,

at that time, can't seriously type code.

2. We have more time at weekend, then we can seriously test our code atm.

Maybe some one can give me information about this idea ?

Best regards,

BornToWin

 
Michel:
No, this is wrong, I said: A *= -1; not A *= +A; This flipflop the sign; but if you need to have a positive number, use the MathAbs() function : A = MathAbs(A); Wathever is A , it will become positif.

I was after trying t flipflip the sign which appeared to work. I tired the MathsAbs() function too and indeed the number is positive.

Thank you Michel, you have been a great help to me.