How to code? - page 49

 

need coding: when GAP occurs..

Hello everyone,

Could someone give me the code to prevent EA opening new trades when there is a gap on 1H chart? cause i want to run this ea 24 hours. Please help me ... my EA almost finish. thank you

 
c14n6:
Hello everyone, Could someone give me the code to prevent EA opening new trades when there is a gap on 1H chart? cause i want to run this ea 24 hours. Please help me ... my EA almost finish. thank you

A gap means an absence of ticks, and that means the EA is not invoked during the gap. So, what do you mean? Do you mean to not trade during the first hour following a gap? Or maybe avoid the first tick following a gap, or more generally classify "this" hour as "slow" if there's "long time" between ticks?

 
BaasHarm:
Hi guys,

I've been following this forum for a while now and picked up a lot of valuable lessons already. Especially thanks to Coder Guru for the quickstart to MQL4.

I'm managed to build a few simple EA's just to get familar with MT4. Now I want to start a new project but I got stuck.

I want to enter a trade after a 10 pip move, not based on any indicator, just on the tick data, if price moves up 10 pips (eventually with a time limit), I want to enter long and and if it moves down, go short. I don't want to use the bar open or close as this may be late or miss some big moves. What I need is how to "freeze" the starting price to compare to the bid/ask to see when the condition is met.

Any suggestions?

Baas Harm

It is nice to see you learn how to code .There are some great coders here who can show you how to code and help you.

Regards

El cid

 

How to check the last position bar index

Hi,

I want to open a new trade only if there is no position that was opened (and is still opened) in the last 5 bars.

How can I do that?

Thanks!

 

Multiple Trades

How to open multiple trades on the same EA & same pair

how the EA can treat a open position independent from each other in the same pair?

Example if we use a moving average Like principal indicator for enter the market but at the time wen enter the market goes again us and moving average triger a different signal how to open a new position with out closing the previous trade regardless if loss or not.

 

Problem Statement

start() Disadvantage of a looped Expert Advisor is the impossibility to open the setup panel. Try to loop an EA - and you won't be able to set it up.

The same idea can be successfully realized using a script. This means an infinite loop can be organized in a script. But there are no parameters to be set up in scripts.

MagicNumber

extern int Expert_ID = 1234;

int _MagicNumber = 0;

int init()

{

int Period_ID = 0;

switch ( Period() )

{

case PERIOD_MN1: Period_ID = 9; break;

case PERIOD_W1: Period_ID = 8; break;

case PERIOD_D1: Period_ID = 7; break;

case PERIOD_H4: Period_ID = 6; break;

case PERIOD_H1: Period_ID = 5; break;

case PERIOD_M30: Period_ID = 4; break;

case PERIOD_M15: Period_ID = 3; break;

case PERIOD_M5: Period_ID = 2; break;

case PERIOD_M1: Period_ID = 1; break;

}

_MagicNumber = Expert_ID * 10 + Period_ID;

But how about in the same time frame??????

 
Files:
 
AQUILEZ:
How to open multiple trades on the same EA & same pair

how the EA can treat a open position independent from each other in the same pair?

Example if we use a moving average Like principal indicator for enter the market but at the time wen enter the market goes again us and moving average triger a different signal how to open a new position with out closing the previous trade regardless if loss or not.

Assign every order a unique ticket number and separate magic number. Only close orders by magic number.

You could then use Orderselect() to get the info of that specific ticket, when your criteria is met, close your order by magic number.

Hope this helps.

 

Time code help????????????

Can someone be so kind and tell me how to code the following code?:

If my Ea is turned on the M30 chart, I want the code to say:

if(on the M5 timeframe, today's close is>yesterday's close)

{

.........

}

 

Gidday I am slowly fixing the errors in some if my ea's ( and learning alot on the way) but what does this mean.

2007.10.24 21:22:24 1998.11.20 06:00 The Abyss GBPJPY,Daily: invalid double number as parameter 6 for OrderSend function

I can't find anything on that error what should I be looking at.

Reason: