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 Thread Tools Display Modes
  #411 (permalink)  
Old 08-06-2008, 04:31 PM
Junior Member
 
Join Date: Jul 2008
Posts: 2
whateveryouwant is on a distinguished road
Tester versus live trading

The EA I wrote runs well in the Tester and opens and closes transactions as required. However, when I use it on forward data by attaching it to a EURUSD graph and enable trading etc etc it never opens any trades. Anyone know what the reason is for that. Is there any function call necessary to switch on live trading?
By that I dont mean clicking the live trading box in the ea setup, I mean something you have to call in adition in your MT ea program.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #412 (permalink)  
Old 08-06-2008, 06:14 PM
Linuxser's Avatar
Moderator
 
Join Date: May 2006
Location: Helliconia (Spring)
Posts: 3,322
Blog Entries: 46
Linuxser has disabled reputation
whateveryouwant: it's hard to discover the problem whithout the code. It could be 20 reasons.
__________________
Elite Manual Trading | Portfolio | Calendar | Suggestions to improve the forum | My Blog

Remember: Signatures must have three lines as maximum
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #413 (permalink)  
Old 08-07-2008, 01:33 AM
Senior Member
 
Join Date: Feb 2007
Posts: 947
FerruFx is on a distinguished road
Quote:
Originally Posted by whateveryouwant View Post
The EA I wrote runs well in the Tester and opens and closes transactions as required. However, when I use it on forward data by attaching it to a EURUSD graph and enable trading etc etc it never opens any trades. Anyone know what the reason is for that. Is there any function call necessary to switch on live trading?
By that I dont mean clicking the live trading box in the ea setup, I mean something you have to call in adition in your MT ea program.

Thanks
Do you enable live trading in the common tab? Do you have smiley face on the top right corner? Do you have error message in your "journal" or "experts" tab?

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
  #414 (permalink)  
Old 08-07-2008, 02:18 AM
cja's Avatar
cja cja is offline
Senior Member
 
Join Date: Apr 2006
Posts: 579
cja is on a distinguished road
MA Signals

Quote:
Originally Posted by Dave137 View Post
I need your help! How do I read the color change in this indicator for my ea?? The buffers seem to only describe how to create the candle and wick. The condition to change the color is in the indicator (Highlighted with arrows - //<<<< - in the program coding), but no values seem to be connected to the buffers (I do not believe).

Can somebody modify this indicator so that a buffer or 2 buffers will indicate a value change that I can sense in my ea I am trying to create. Please help me if you can - Thanks!



Dave

Indicator attached! Very frustrating. I can create ea's, but indicators still puzzle me at times.

Take these 2 lines of code


double MA_1 (int i = 0){return(iMA(NULL,0,MA1,MA1_SHIFT,MA1_MODE, MA1_PRICE,i));}
double MA_2 (int i = 0){return(iMA(NULL,0,MA2,MA2_SHIFT,MA2_MODE, MA2_PRICE,i));}

and these conditions

if(Ma1 > Ma2) SetCandleColor(1,i);

else if(Ma1 < Ma2) SetCandleColor(2,i);

and rewrite them into your EA with the same inputs from the candle indicator and either paste in the MA extern functions from the candle indicator or hard code them straight into these lines of code.


double Ma1 = iMA(NULL,0,MA1,MA1_SHIFT,MA1_MODE, MA1_PRICE,0);
double Ma2 = iMA(NULL,0,MA2,MA2_SHIFT,MA2_MODE, MA2_PRICE,0);


if(Ma1 > Ma2) BUY
if(Ma1 < Ma2) SELL
__________________
My Disadvantage is that I am not a Trained Programmer - My Advantage is that I am not a Trained Programmer.
http://cjatradingtools.com/

Last edited by cja; 08-07-2008 at 06:00 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #415 (permalink)  
Old 08-07-2008, 02:53 AM
Junior Member
 
Join Date: Jul 2008
Posts: 2
whateveryouwant is on a distinguished road
Tester versus live trading

Yes I havd live trading enabled and allows DLL calls etc as required for all EA's to trade live. That is why I stated that that section is set up correctly.
However my EA runs in the tester and is very good, but I must be missing some function call; that enables trading that has nothing to do with the EA setup from Metatrader interface.
Is there any Function call in the code preamble necessary to enable live trading?
It is really weird... it works in the tester but not in Live trading and yes I have a smiley face.


Quote:
Originally Posted by FerruFx View Post
Do you enable live trading in the common tab? Do you have smiley face on the top right corner? Do you have error message in your "journal" or "experts" tab?

FerruFx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #416 (permalink)  
Old 08-07-2008, 09:55 AM
Senior Member
 
Join Date: Feb 2007
Posts: 947
FerruFx is on a distinguished road
Quote:
Originally Posted by whateveryouwant View Post
Yes I havd live trading enabled and allows DLL calls etc as required for all EA's to trade live. That is why I stated that that section is set up correctly.
However my EA runs in the tester and is very good, but I must be missing some function call; that enables trading that has nothing to do with the EA setup from Metatrader interface.
Is there any Function call in the code preamble necessary to enable live trading?
It is really weird... it works in the tester but not in Live trading and yes I have a smiley face.
If you don't have error messages in "journal" and "expert" tabs, then all indicators/files called by the EA are loaded correctly and nothing is wrong.

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
  #417 (permalink)  
Old 08-07-2008, 09:43 PM
Senior Member
 
Join Date: Oct 2007
Posts: 224
Dave137 is on a distinguished road
Smile

Quote:
Originally Posted by cja View Post
Take these 2 lines of code


double MA_1 (int i = 0){return(iMA(NULL,0,MA1,MA1_SHIFT,MA1_MODE, MA1_PRICE,i));}
double MA_2 (int i = 0){return(iMA(NULL,0,MA2,MA2_SHIFT,MA2_MODE, MA2_PRICE,i));}

and these conditions

if(Ma1 > Ma2) SetCandleColor(1,i);

else if(Ma1 < Ma2) SetCandleColor(2,i);

and rewrite them into your EA with the same inputs from the candle indicator and either paste in the MA extern functions from the candle indicator or hard code them straight into these lines of code.


double Ma1 = iMA(NULL,0,MA1,MA1_SHIFT,MA1_MODE, MA1_PRICE,0);
double Ma2 = iMA(NULL,0,MA2,MA2_SHIFT,MA2_MODE, MA2_PRICE,0);


if(Ma1 > Ma2) BUY
if(Ma1 < Ma2) SELL
Thank you ever so kindly! You made my week!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #418 (permalink)  
Old 08-08-2008, 12:19 AM
Junior Member
 
Join Date: Aug 2007
Posts: 8
dan5767 is on a distinguished road
Is there anyway to stop trading for a certain amount of time after a trade has been closed?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #419 (permalink)  
Old 08-08-2008, 09:26 AM
Member
 
Join Date: Feb 2008
Posts: 31
Berkis is on a distinguished road
I have a problem with this EA. It does close a position when a candle closes, and does not close when to 2 Ma's cross with each other. For example if i have a long candle when two MA's cross, i loose some pips because it closes position later than two MA's cross each other. Maybe someone can solve this ?
//+------------------------------------------------------------------+
//| Closer on mas.mq4 |
//| Shingami |
//| Forex Trading Software: Forex Trading Platform MetaTrader 4 |
//+------------------------------------------------------------------+
#property copyright "Shinigami© 2007"
#property link "Shini1984@gmail.com"
#define ORDER_ID 2016
extern int MA1.period =0;
extern int MA1.shift=0;
extern int MA1.method=0;
extern int MA1.price=0;
extern int MA2.period=0;
extern int MA2.shift=0;
extern int MA2.method=0;
extern int MA2.price=0;


int start()
{
if(CheckMACross()==1)
CloseOrders();
return(0);
}


int CheckMACross()
{
if(iMA(Symbol(),0,MA1.period,MA1.shift,MA1.method, MA1.price,2)<iMA(Symbol(),0,MA2.period, MA2.shift,MA2.method,MA2.price,2))
{
if(iMA(Symbol(),0,MA1.period,MA1.shift,MA1.method, MA1.price,1)>=iMA(Symbol(),0,MA2.period,MA2.shift, MA2.method,MA2.price,1))
return(1);
}
else if(iMA(Symbol(),0,MA1.period ,MA1.shift,MA1.method,MA1.price,2)>iMA(Symbol(),0, MA2.period,MA2.shift,MA2.method,MA2.price,2))
{
if(iMA(Symbol(),0,MA1.period,MA1.shift,MA1.method, MA1.price,1)<=iMA(Symbol(),0,MA2.period,MA2.shift, MA2.method, MA2.price,1))
return(1);
}
else return(0);
}


int CloseOrders()
{
for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
//if(OrderMagicNumber()!=MagicNumber)
//continue;
if(OrderSymbol()!=Symbol())
continue;
if(OrderType()==OP_BUY)
OrderClose(OrderTicket(),OrderLots(),Bid,3);
if(OrderType()==OP_SELL)
OrderClose(OrderTicket(),OrderLots(),Ask,3);
}
return(0);
}
Attached Images
File Type: jpg 1.JPG (95.7 KB, 70 views)

Last edited by Berkis; 08-08-2008 at 01:59 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #420 (permalink)  
Old 08-12-2008, 06:52 AM
ichanz's Avatar
Junior Member
 
Join Date: Mar 2008
Posts: 14
ichanz is on a distinguished road
REQUEST: OP on Multiple Currencies Code

Friends,

I have been learning to code MQL4 on the past few weeks, it's not easy I thought, but it's really worth to try ( hopefully will paid off soon )

Right now, I am stuck on coding for openning position of multiple currencies, since sendorder() function only knows symbol() for the running chart.
Please someone give me some sample on how to code that subject.

The Idea of my EA is to open position of several pairs on particular time ( ie. EURUSD, USDJPY at 4AM ).

Thanks before.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

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

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 Programming 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 12:08 PM.



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