Forex



Go Back   Forex Trading > Programming > MetaTrader
Forex Forum Register More recent Blogs 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
  #1561 (permalink)  
Old 02-05-2009, 12:05 AM
Junior Member
 
Join Date: Jun 2008
Posts: 4
wolfboy is on a distinguished road
Time fixing of an object

I wondered if anyone could tell me how to time fix an object (such as an arrow) so when I change the chart TF the arrow would remain at the original time. Similar to drawing a vertical line and then changing chart TF. Thanks.

Last edited by wolfboy; 02-07-2009 at 09:29 PM.
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
  #1562 (permalink)  
Old 02-05-2009, 09:21 AM
Junior Member
 
Join Date: Aug 2008
Posts: 1
sbolten is on a distinguished road
Angry EA stops trading but still shows a smiley

Hi,

I have a strange problem over here. I am running an EA (using one custom indicator). Sometimes it happens that the EA stops working (although the smiley is still there, but output on the chart for example is not printed any more). This happens without any warning and is very unpredictable.

Last time it occured I found the following in the EA log which shows that at 03:08:06 the EA was removed because the chart was closed (uninit reason 4). Thing is, I was sleeping at this time, definitely not thinking about closing charts. Since I publish the account to an FTP site every 5 mins and the last update was around 3AM I decided that this must be related. Unfortunately I do not have any clue on how to approach the problem.

Any ideas.

Best regards,

Stephan
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
  #1563 (permalink)  
Old 02-05-2009, 10:25 AM
primajaya's Avatar
Senior Member
 
Join Date: Aug 2006
Posts: 213
primajaya is on a distinguished road
Quote:
Originally Posted by mike360 View Post
What would be the code to modify an order ( adjust the take profit of it ) after X amount of minutes has passed since the order has opened ? Thanks in advance to anyone who responds to this.
first you have to select the order using OrderSelect function,
then check the the order open time and compare it with time current,
you can change the Stop Loss and Take Profit

You might use the following code

PHP Code:

for (int i=0;i<OrdersTotal();i++)
{
   
OrderSelect(i,SELECT_BY_POS,MODE_TRADES)
   if(
TimeCurrent()-OrderOpenTime()>= after_X_amaount_of_time_in_seconds)
   {
      
OrderModify(OrderTicket(),OrderOpenPrice(),New_SL,New_TP,0,CLR_NONE);
   }

__________________
You said "why?".. I said "why not?!"
Broker for 5$ Free
Trading system 4free
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
  #1564 (permalink)  
Old 02-05-2009, 07:41 PM
Junior Member
 
Join Date: Jan 2009
Posts: 2
ecousins25 is on a distinguished road
programmer newbie help

hello i am new to the programming world. i just read through the tutorial put out by Codersguru its a very nice tutorial. i also have the MetaQuotes Language 4 manual a 162 page pdf manual that apears to be a better reference manual for after a get a better grasp of the concepts. i am still having some trouble with understanding the basics. are there any recomended reading that goes more indepth than the standard mt4 reference manual. i need a bit more background description for how to use such things as OrderOpen() OrderSend() OrderSelect() OrderTicket() OrderTicket()

i have a general goal for an EA i want to program. but i want to better learn the language so i am starting my learning experience in a series of small steps

the first step i completed. i created this code to print my name on the chart lol i know, sound simple but... "you have to learn to crawl before you can walk"

here is the code for my first completed ea

//+------------------------------------------------------------------+
//| print test ver 1.mq4 |
//| Copyright © 2009, Eric |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Eric"
#property link ""

//---- input parameters
extern string MyString="name";

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
Comment ("hello ", MyString);
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+

the next step i want to learn is how to program my ea to identify open orders
can i use the OrderTicket() (or do i have to use a magic number to identify a trade and where does the magicnumber show up on the mt4 platform) somehow in the code to allow my next ea to
print on the chart
first: my name (i did that allready)
second: below my name (not to replace the first chart comment)
the ticket number (or other identifying number) of the order
and to be able to store and recall this identifyer for the next step in
my learning process.

any help would be much appreciated
thanks!!
Eric
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
  #1565 (permalink)  
Old 02-06-2009, 01:44 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Study the OrderSelect() function. Get to know it well, it is important.


bool OrderSelect( int index, int select, int pool=MODE_TRADES)
The function selects an order for further processing. It returns TRUE if the function succeeds. It returns FALSE if the function fails. To get the error information, one has to call the GetLastError() function.
The pool parameter is ignored if the order is selected by the ticket number. The ticket number is a unique order identifier. To find out from what list the order has been selected, its close time must be analyzed. If the order close time equals to 0, the order is open or pending and taken from the terminal open positions list. One can distinguish an open position from a pending order by the order type. If the order close time does not equal to 0, the order is a closed order or a deleted pending order and was selected from the terminal history. They also differ from each other by their order types.
Parameters:
index - Order index or order ticket depending on the second parameter.
select - Selecting flags. It can be any of the following values:
SELECT_BY_POS - index in the order pool,
SELECT_BY_TICKET - index is order ticket.
pool - Optional order pool index. Used when the selected parameter is SELECT_BY_POS. It can be any of the following values:
MODE_TRADES (default)- order selected from trading pool(opened and pending orders),
MODE_HISTORY - order selected from history pool (closed and canceled order).

Sample:
if(OrderSelect(12470, SELECT_BY_TICKET)==true)
{
Print("order #12470 open price is ", OrderOpenPrice());
Print("order #12470 close price is ", OrderClosePrice());
}
else
Print("OrderSelect returned the error of ",GetLastError());
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
  #1566 (permalink)  
Old 02-06-2009, 01:48 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Download this also if you haven't found it already:

http://www.mql4.com/files/mql4bookenglish.chm
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
  #1567 (permalink)  
Old 02-06-2009, 03:37 AM
Junior Member
 
Join Date: Jan 2009
Posts: 2
ecousins25 is on a distinguished road
thanks wolfe!

thanks for your answer and the book! its new to me so i will dig in to it and learn some more. i will then post the next version of my ea or anouther question if i hit a road block.

Eric
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
  #1568 (permalink)  
Old 02-09-2009, 12:18 PM
darkkiller's Avatar
Senior Member
 
Join Date: Jul 2007
Location: Malaysia
Posts: 258
darkkiller is on a distinguished road
how to change or remove .00

Quote:
double HiPrice2 = iHigh(NULL,NULL,1);
double LoPrice2 = iLow (NULL,NULL,1);
double Rangehilo= (HiPrice2-LoPrice2);
if (Digits < 4) Rangehilo = Rangehilo * 100; else Rangehilo = Rangehilo * 10000;
Comment("\n","Range: ",DoubleToStr(Rangehilo,2)+" pip","\n");
I try to create range PIP between high and low,but it show like this

->> Range: 37.00 pip

My question is,how to remove .00?so it will just show 37pip only?

thanks
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
  #1569 (permalink)  
Old 02-09-2009, 02:20 PM
Senior Member
 
Join Date: Nov 2006
Posts: 308
luxinterior is on a distinguished road
NormalizeDouble(var1,0);

Lux

PS: Just noticed your code: DoubleToStr(Rangehilo,0) - change the 2 to 0
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This

Last edited by luxinterior; 02-09-2009 at 02:23 PM.
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
  #1570 (permalink)  
Old 02-09-2009, 02:44 PM
darkkiller's Avatar
Senior Member
 
Join Date: Jul 2007
Location: Malaysia
Posts: 258
darkkiller is on a distinguished road
Quote:
Originally Posted by luxinterior View Post
NormalizeDouble(var1,0);

Lux

PS: Just noticed your code: DoubleToStr(Rangehilo,0) - change the 2 to 0
Ohohhh,just a small mistake..thanks luxinterior!
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
#include, candle time, CHinGsMAroonCLK, code, coders guru, conditionally, dll, eli hayun, Eur_harvester.ex4, expert adviser, expert advisor, forex, higher high, how to code, indicator, I_XO_A_H, kehedge, mechanical trading, metatrader command line, mt4, MT4-LevelStop-Reverse, OrderReliable.mqh, programming, rectangle tool, trading, volty channel stop


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
How to code this? iscuba11 Metatrader 4 mql 4 - Development course 1 08-03-2007 05:22 PM


All times are GMT. The time now is 04:38 AM.



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