MQL4 Learning - page 13

 

Please not that I am not a coder so my opinion about how to code may be totally mistaken.

I just opened help in MetaEditor:

int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE) [/CODE]

where

- cmd - OP_BUY (buy), or OP_SELL (sell), and so on;

And also use MarketInfo.

Besices you may use some templates to create EAs:

Templates to create EAs and Indicators:

- some good templates are here;

- templates with some new codes are here.

- Programming Modules with many programming functions are here.

As to open the order at a certain time so you may use something like that:

datetime OpenOrder = StrToTime(TimeTrade)

and

[CODE]if(CurTime() >= OpenTime && TimeCurrent() <= OpenOrder+60)

where,

extern string TimeTrade = "11:31";

datetime, StrToTime and TimeCurrent - see help in MetaEditor;

 

MQL4,

I see that Codersguru replied already so forget about my post.

Just want to say that we are having this thread https://www.mql5.com/en/forum/174329 as well.

 
codersguru:
MODE_ASK?? who told you that the constant MODE_ASK means more than the number 10.

Well, MODE_ASK is used with the function MarketInfo to get the ask price of a currency not the one hosting the EA.

double ask =MarketInfo("EURUSD",MODE_ASK);

so, your code should be:

double ask =MarketInfo("EURUSD",MODE_ASK);

if(ask == 121.10)

{

//do whatever you want.

}[/php]

And about setting time to buy you can use:

[PHP]if (TimeHour(TimeCurrent()) == 12 && TimeMinute(TimeCurrent()) >= 30)

{

//place a buy order

}

The code above place an order at 12:30 PM

Thank You guys for Your kind help.

 

Thank You, guys, for Your helpful answers.

I have one more question:

if(bid == 122.15)

I want to replace 122.15 by current market price.

Is there any function that determines current market price?

Thank You.

 

MQL4 Learning

I have a question:

if(bid == 122.15)

I want to replace 122.15 by current market price.

Is there any function that determines current market price?

Thank You.

 

Can someone please answer this?

 
MQL4:
I have a question:

if(bid == 122.15)

I want to replace 122.15 by current market price.

Is there any function that determines current market price?

Thank You.

Try this:

if(bid == MarketInfo(Symbol(),MODE_BID))

Hope it helps.

 

Or this if(bid == Bid) ...

Be aware though that equality of floating point numbers is tricky, you might want something more like this... if (MathAbs(bid - Bid) < Point) (or something).

 

if(bid == MarketInfo(Symbol(),MODE_BID)+10)

Thank You guys, it works! May I ask You another?

if(bid == MarketInfo(Symbol(),MODE_BID)+10)

It is intended that in a certain time the market recognized the price which is for example, x. And will sell 10 pips above this x. I tried this code, and it doesn't work.

Question#2

If within certain seconds the trade is not activated, what is the code syntax for disabling the trade?

Please help!!!

Thank You.

 

Can someone please help me?

Reason: