Forex



Go Back   Forex Trading > Programming > MetaTrader
Forex Forum Register More recent Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #121 (permalink)  
Old 07-23-2007, 06:45 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Wink

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:

PHP Code:
double ask   =MarketInfo("EURUSD",MODE_ASK); 
if(
ask == 121.10)
{
    
//do whatever you want.

And about setting time to buy you can use:

PHP Code:
if (TimeHour(TimeCurrent()) == 12 &&  TimeMinute(TimeCurrent()) >= 30)
{
   
//place a buy order

The code above place an order at 12:30 PM


Quote:
Originally Posted by MQL4 View Post
I spent many hours, and I cannot solve the problem to this code:

if (MODE_ASK==121.10)
{
ticket=OrderSend(Symbol()..............


I want the USD\JPY to trigger a buy at this point. What's wrong with this code?

Also, can someone tell me a code syntax that will trigger a buy at a certain time?

Thank You. God bless You.
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #122 (permalink)  
Old 07-23-2007, 07:16 PM
Administrator
 
Join Date: Sep 2005
Posts: 20,083
Blog Entries: 243
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
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:

Code:
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)
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:

Code:
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;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #123 (permalink)  
Old 07-23-2007, 07:19 PM
Administrator
 
Join Date: Sep 2005
Posts: 20,083
Blog Entries: 243
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
MQL4,
I see that Codersguru replied already so forget about my post.

Just want to say that we are having this thread http://www.forex-tsd.com/general-dis...ing-forum.html as well.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #124 (permalink)  
Old 07-23-2007, 07:41 PM
Member
 
Join Date: Jul 2007
Posts: 41
MQL4 is on a distinguished road
Quote:
Originally Posted by codersguru View Post
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:

PHP Code:
double ask   =MarketInfo("EURUSD",MODE_ASK); 
if(
ask == 121.10)
{
    
//do whatever you want.

And about setting time to buy you can use:

PHP Code:
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #125 (permalink)  
Old 07-23-2007, 08:46 PM
Member
 
Join Date: Jul 2007
Posts: 41
MQL4 is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #126 (permalink)  
Old 07-24-2007, 12:17 AM
Member
 
Join Date: Jul 2007
Posts: 41
MQL4 is on a distinguished road
Exclamation 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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #127 (permalink)  
Old 07-24-2007, 12:54 AM
Member
 
Join Date: Jul 2007
Posts: 41
MQL4 is on a distinguished road
Can someone please answer this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #128 (permalink)  
Old 07-24-2007, 12:55 AM
Senior Member
 
Join Date: Nov 2005
Posts: 105
fxd01 is on a distinguished road
Quote:
Originally Posted by MQL4 View Post
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #129 (permalink)  
Old 07-24-2007, 01:04 AM
Senior Member
 
Join Date: Feb 2006
Location: New Zealand
Posts: 249
Craig is on a distinguished road
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).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #130 (permalink)  
Old 07-24-2007, 01:47 AM
Member
 
Join Date: Jul 2007
Posts: 41
MQL4 is on a distinguished road
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.

Last edited by MQL4; 07-24-2007 at 01:51 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
automated close order, close, eas, forex, learn mql4, learn mql4 video, learning mql4, mini std lotsize risk, mql4 ima, mql4 learning, mql4 video, OrderCloseBy, profit, reach, secure profit function, T101_v1.11_orest_IBFXm.mq4


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning Cycles For New Traders Dan7974 General Discussion 350 01-18-2008 07:04 PM
Learning to code for autotrading GoatT MetaTrader 8 01-10-2007 09:55 PM
Self learning expert mrtools Expert Advisors - Metatrader 4 32 10-22-2006 06:29 PM


All times are GMT. The time now is 07:05 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.