Forex
Google
New signals service!

Go Back   Forex Trading > Programming > Metatrader Programming


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack (1) Thread Tools Display Modes
  #1321 (permalink)  
Old 10-06-2008, 03:51 AM
Junior Member
 
Join Date: Sep 2008
Posts: 16
bkr1969 is on a distinguished road
What is wrong with this code?

Can anyone tell me why I'm generating an error with this command in my EA?

HTML Code:
if(OrderSelect(bTicket,SELECT_BY_TICKET)==true)
      buyOrder=OrderType();
else
      Print("OrderSelect returned the error of ",GetLastError());
bTicket is assigned in this prior line:

HTML Code:
bTicket=OrderSend(Symbol(),OP_BUYSTOP,Lots,buyPoint,0,sl,buy_tp,"Script entry",0);
          if(bTicket<=0) Print("Error = ",GetLastError());
          else Print("ticket = ",bTicket);
My pending order is placed and returns the ticket number as assigned to bTicket, but then bTicket doesn't work in my OrderSelect(). I get an error 0 returned. I tried referencing by SELECT_BY_POS and assigning the returned ticket number to bTicket and it worked fine, but there's no way of knowing what the position number of all of my orders will be just be running the script. Any help is greatly appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1322 (permalink)  
Old 10-06-2008, 05:31 AM
Linuxser's Avatar
Moderator
 
Join Date: May 2006
Location: Helliconia (Spring)
Posts: 3,319
Blog Entries: 46
Linuxser has disabled reputation
Quote:
Originally Posted by bkr1969 View Post
I can't use magic number because I'm running the same EA on 8 different pairs. Where is my original post so I can follow it?
If a post is moved is for some reason, like maintain forum order.

Your posts where moved (to this thread) but you could follow easily because they have one day of redirection.

Maybe you need a bit of help trying to find your own posts.

If you feel lost, with vBulletin is not difficult at all. Just click on your own profile, "find all posts by..."
__________________
Elite Manual Trading | Portfolio | Calendar | Suggestions to improve the forum | My Blog

Remember: Signatures must have three lines as maximum

Last edited by Linuxser; 10-06-2008 at 05:33 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1323 (permalink)  
Old 10-06-2008, 10:01 AM
Member
 
Join Date: Dec 2005
Posts: 62
LazyForex is on a distinguished road
Instant Order vs Market Orders

Hello Fellow Programmers,

I received information from a friend that an EA with "Instant orders" will not work on the MT4 platforms that doesn't have a Dealing desk and this EA needs to be changed to "Market Orders". Is it true? Can someone verify this?

Thanks.

LF
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1324 (permalink)  
Old 10-06-2008, 10:15 AM
Senior Member
 
Join Date: Nov 2006
Posts: 215
luxinterior is on a distinguished road
They're the same thing.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1325 (permalink)  
Old 10-06-2008, 10:26 AM
Member
 
Join Date: Dec 2005
Posts: 62
LazyForex is on a distinguished road
Quote:
Originally Posted by luxinterior View Post
They're the same thing.

Lux
Are they? Hmmm...My friend was advised by the Broker to do just that; Change from "Instant" to "Market" Thanks.

Anyone else have different view?

LF
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1326 (permalink)  
Old 10-06-2008, 10:43 AM
Junior Member
 
Join Date: Jun 2007
Posts: 5
fxbeginner is on a distinguished road
Thanks to FerruFx

Quote:
Originally Posted by FerruFx View Post
An idea would be to not allow trading after the first order of the day. After the ordersend() function, place a "trade = false;"

Then reset the trade allowance each new day:

if(timeprev!=iTime(Symbol(),PERIOD_D1,0)) { //---- This is a new day
timeprev = iTime(Symbol(),PERIOD_D1,0);
trade = true; }

Then when you check your signal:

if(trade) { your trading condition here }

Just an example ...

FerruFx
Thanks FerruFx. I will code this and hope it will now run.
fxbeginner
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1327 (permalink)  
Old 10-06-2008, 01:58 PM
Senior Member
 
Join Date: Feb 2007
Posts: 947
FerruFx is on a distinguished road
Quote:
Originally Posted by fxbeginner View Post
Thanks FerruFx. I will code this and hope it will now run.
fxbeginner
You're welcome.

FerruFx
__________________
THE HEART of FOREX & THE PROBABILITY METER - Trade with 100% confidence and ... Stress Less!!!
Coding services: Experts Advisors, indicators, alerts, etc ... more info by PM
NEW: video presentation of the Probability Meter ... 24hrs action on the website
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1328 (permalink)  
Old 10-06-2008, 02:01 PM
Junior Member
 
Join Date: May 2006
Posts: 12
mach_one_man is on a distinguished road
Account History Problem

Hello All,

I have programmed an EA that uses Limit orders instead of Market orders. Whenever a moving average changes, it uses the OrderModify function to alter the opening price of the order.

This works fine, however each time the order is adjusted (fairly frequently) the Account History has a new entry saying the order has been closed. This almost hides the real trades and the reports are very hard to read. Is there a method of customising the reports or account history so that it will only show the actual trades that have taken place, rather than "modified" orders?

Thanks for any replies
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1329 (permalink)  
Old 10-06-2008, 10:20 PM
Junior Member
 
Join Date: Aug 2006
Posts: 11
callan300 is on a distinguished road
Buy at open of next bar

Hello everyone,

Would someone be able to provide some sample code on how to do this? I need to check if the bar is complete and if it is then place the order.
This is greatly appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1330 (permalink)  
Old 10-06-2008, 11:37 PM
Senior Member
 
Join Date: Apr 2006
Posts: 131
InTrance is on a distinguished road
Quote:
Originally Posted by callan300 View Post
Hello everyone,

Would someone be able to provide some sample code on how to do this? I need to check if the bar is complete and if it is then place the order.
This is greatly appreciated.
Its very simple. Just do something like:

if (iBars>Bars){

Code to execute when new bar arrives;

Bars=iBars;

}
__________________
Need a Professional Programmer? PM me!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
candle time, CHinGsMAroonCLK, coders guru, expert advisor, forex, how to code, I_XO_A_H, mechanical trading, trading

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

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/metatrader-programming/554-how-code.html
Posted By For Type Date
Need an experienced programmer? - Page 2 Post #0 Refback 09-24-2008 07:24 AM

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 09:44 AM.



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