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
  #271 (permalink)  
Old 07-11-2007, 02:18 AM
iscuba11's Avatar
Senior Member
 
Join Date: May 2006
Location: Houston
Posts: 400
iscuba11 is on a distinguished road
Quote:
Originally Posted by Willis11of12 View Post
I've had this problem before and here's what I did:
Up at the top where you declare your veriables put


static bool ITradedOnThisBar;


then where you send your order put


if(your critera && ITradedOnThisBar!=Bars)
{
ticket=OrderSend(Symbol(),OP_BUY,... );
ITradedOnThisBar = Bars;
}


Doing This will keep you from opening a trade on the same bar that you already opened a trade on, but more importantly you want to keep it from closing on the same bar so I would also add this code where you close your trade, for example:

if(Your Criteria && ITradedOnThisBar != Bars)
{
OrderClose(OrderTicket(),... ); // close position
}

This is probably the most simple way to do what you are trying to do.
Thanks for the coding. I have installed it in my ea (hopefully in the right spots), and will find out if it will work once the moving averages cross.

Thanks!

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #272 (permalink)  
Old 07-12-2007, 05:27 PM
Junior Member
 
Join Date: Mar 2007
Posts: 14
Vman is on a distinguished road
Is there such a code ?

I wonder if there is such a code (w/ below description).

What would the basic code be w/ the following parameters ? (w/ an understanding that any indicator w/ a value could be plugged in)

(Opening trades)
1. A long trade is placed when an indicator's current value goes higher than previous bar's close value. (intrabar, not close)

2. A short trade is placed when an indicator's current value goes lower than previous bar's close value. (intrabar, not close)

(Closing trades)
1. Long trades are closed when short trades are opened.

2. Short trades are closed when long trades are opened.

thanks

Last edited by Vman; 07-12-2007 at 07:24 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #273 (permalink)  
Old 07-12-2007, 05:58 PM
Junior Member
 
Join Date: Oct 2006
Posts: 6
MadAero is on a distinguished road
I do not know how to code, but I have made several EA's simillar to what you describe using the expert advisor builder. I'm not sure if thats what you are looking for but you might check it out if you haven't already.

Expert Advisor Builder for MetaTrader 4
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #274 (permalink)  
Old 07-12-2007, 06:31 PM
Junior Member
 
Join Date: Mar 2007
Posts: 14
Vman is on a distinguished road
I will check it out. thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #275 (permalink)  
Old 07-13-2007, 01:43 AM
ajk's Avatar
ajk ajk is offline
Senior Member
 
Join Date: Dec 2005
Posts: 229
ajk is on a distinguished road
try some of these
Index of /_MT4_Experts
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #276 (permalink)  
Old 07-13-2007, 05:17 PM
Junior Member
 
Join Date: Mar 2007
Posts: 14
Vman is on a distinguished road
Thanks AJK. That is quite a list !

Last edited by Vman; 07-13-2007 at 05:46 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #277 (permalink)  
Old 07-15-2007, 05:13 PM
islandrock's Avatar
Member
 
Join Date: Jan 2007
Posts: 87
islandrock is on a distinguished road
code help

i'm sure someone has asked this already but i cannot find it when i search the threads.
i would like to know how to code for an EA to place a trade only when the price is between to levels -I.E.

if (price=>1.0000 && price< 1.0050) sell
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #278 (permalink)  
Old 07-15-2007, 05:58 PM
Member
 
Join Date: Apr 2006
Posts: 73
ejoi is on a distinguished road
Here...

PHP Code:
string price = (DoubleToStr(iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0),Digits));

if (
price=>1.0000 && price1.0050
{
sell order here

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #279 (permalink)  
Old 07-15-2007, 06:13 PM
islandrock's Avatar
Member
 
Join Date: Jan 2007
Posts: 87
islandrock is on a distinguished road
thanks

thank you for the quick response.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #280 (permalink)  
Old 07-15-2007, 09:21 PM
islandrock's Avatar
Member
 
Join Date: Jan 2007
Posts: 87
islandrock is on a distinguished road
Quote:
Originally Posted by ejoi View Post
Here...

PHP Code:
string price = (DoubleToStr(iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0),Digits));

if (
price=>1.0000 && price1.0050
{
sell order here

when i try to compile this it get diff types in comparison
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 07:20 AM.



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