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
  #741 (permalink)  
Old 03-01-2008, 06:38 AM
increase's Avatar
Senior Member
 
Join Date: May 2006
Posts: 690
increase is on a distinguished road
Need some help with arrayBsearch

Hi guys,

Still working on the Holy grail LOL I need some help with arrayBsearch if anyone can assist here, please PM me and send an email address so that I can forward yuo the two files that I need help on

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #742 (permalink)  
Old 03-01-2008, 07:48 AM
Junior Member
 
Join Date: Jul 2007
Posts: 19
PANNEK is on a distinguished road
plz...can anybary help me...

I have a expert advisor....
it's work very well in backtest,
bat it not run in demo account....
why...what is wrong???

Expert is heare...
Attached Files
File Type: mq4 MovingAv_EA (EURUSD-D1,ALPARI)v1.0.mq4 (6.1 KB, 15 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #743 (permalink)  
Old 03-01-2008, 10:29 PM
one800's Avatar
Junior Member
 
Join Date: Dec 2005
Posts: 2
one800 is on a distinguished road
Question Can anyone help me with my simple MA EA?

Hello everybody....This is my first post on this board and i am hoping to get some help with this, my first attempt at writing an EA. I am trying to keep it as simple as possible. It's just to learn the code.
But i have hit a snag. The EA compiles ok. But when i run it it never opens an order.
Can anyone tell me what lines to add to get an order to open.

The general idea is just to have an OP_BUY order to open when the simple ma of 1 closes above the sma of 10.
For the purpose of this EA i am not concerned with TP, SL, or short orders.
It's just supposed to open an order every time the sma1 closes above the sma 10.

Any help will be greatly appreciated. And thanks in advanced to Coder Guru and the rest of you guys.




extern double Lots = 0.1;



//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

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

//----
return(0);
}
int Crossed (double line1, double line2)
{
static int lastDirection = 0;
static int currentDirection = 0;

if (line1>line2) currentDirection = 1;
if (line1<line2) currentDirection = 2;

if (currentDirection !=lastDirection)
{
lastDirection=currentDirection;
return(lastDirection);
}
else
{
return(0);
}
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{

int ticket, total;
double shortSMA, longSMA;
double Crossed;


if(Bars<100)
{
Print("There is not enough data to analyze");
return(0);
}
shortSMA=iMA(NULL,0,1,0,MODE_SMA,PRICE_OPEN,0);
longSMA=iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,0);

int isCrossed=Crossed(shortSMA,longSMA);
total=OrdersTotal();
if(total<1)

if (Crossed ==1)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"M inute Chart",12345,0,Silver);
if (ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES ))
Print("Buy order opened on Minute Chart at: ",OrderOpenPrice());
}
else
Print("Encountered Error on Minute Chart ", GetLastError());
return(0);
}

//----

//----
return(0);
}
//+------------------------------------------------------------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #744 (permalink)  
Old 03-02-2008, 01:11 AM
one800's Avatar
Junior Member
 
Join Date: Dec 2005
Posts: 2
one800 is on a distinguished road
Red face Thank anyways, but i fixed my own problem..

The solution to my problem was easy...this new version works just fine. Take out the OrdersTotal line and run it on a 1 min timeframe and watch your account double or bust every single day practically.

Give me a break already, i've had no formal training!!!!

//+------------------------------------------------------------------+
//| OP_BUYonSMAcross.mq4 |
//| Copyright © 2008 |
//| Forex Facts |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008"
#property link "http://forexdynamics.blogspot.com/"

double Lots = 0.1;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

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

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int total, ticket;
double shortSMA, longSMA;

if(Bars<100)
{
Print("There is not enough data to analyze");
return(0);
}
shortSMA=iMA(NULL,0,1,0,MODE_SMA,PRICE_OPEN,0);
longSMA=iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,0);

total=OrdersTotal();
if(total<1)



if (shortSMA>longSMA)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,0,0,"M inute Chart",12345,0,Silver);
if (ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES ))
Print("Buy order opened on Minute Chart at: ",OrderOpenPrice());
}
else
Print("Encountered Error on Minute Chart ", GetLastError());
return(0);
}
//----

//----
return(0);
}
//+------------------------------------------------------------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #745 (permalink)  
Old 03-04-2008, 12:11 PM
Junior Member
 
Join Date: Feb 2008
Posts: 4
danielp is on a distinguished road
How to change alert into trading EA

Hi Guys,
How do you change an alert indicator into a trading EA?
I've tried changing the command Alert(Symbol()+" "+Period()+" XO Long ",Bid); into OrderSend(Symbol(),OP_BUY,0.01,Ask,3,20,20,"XO-CCI",1,0,Blue); at the start I chose menu to make EA, then content of my alert indicator, i copied to this EA, then I changed the command alert to trading command as above, then i compiled. But the compiled EA is not making any trade after i tried it on 1M chart for a day.

Please help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #746 (permalink)  
Old 03-05-2008, 12:34 AM
Junior Member
 
Join Date: May 2006
Posts: 3
myfx is on a distinguished road
Question my first ea based on fractal_dimension indicator

fractal_dimension indicator draw a line with the parameter e_ramdom_line= 1.5 I want my expert the stop trading when the fdi ( fractal dimension index) is >1.5, and continue trading when fdi is < 1.5.
I am looking for help writing an icustom to handle this condition inside my ea.
thanks
Attached Files
File Type: mq4 fractal_dimension.mq4 (15.9 KB, 11 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #747 (permalink)  
Old 03-05-2008, 09:49 AM
Junior Member
 
Join Date: May 2007
Posts: 16
cyberpasta is on a distinguished road
How work with requotes?

Hi!!

I'm writting my own EA. All seems ok in backtest but when I run it in forward I get some errors because of requotes. Curiously I've got this errors 3 times and the 3 times has been on GBPUSD (I'm testing the EA in 20 pairs). I've coded a maximum slippage of 5. I tink I get this errors even when the requote is less than 5, so I don´t understand.

Here is the error message:
2008.03.05 08:15:12 EA1 GBPUSD,M15: Error opening SELL order! invalid price

And the requote message:
2008.03.05 08:15:11 '5267460': requote 1.9803 / 1.9807 for open sell 0.10 GBPUSD at 1.9807 sl: 1.9957 tp: 1.9357
2008.03.05 08:15:11 '5267460': request was accepted by server
2008.03.05 08:15:11 '5267460': instant order sell 0.10 GBPUSD at 1.9807 sl: 1.9957 tp: 1.9357

So if the requote is 1.9803/1.9807 and the is trying open an order at 1.9807 and a slippage of 5 pips is accepted, why this error?

Finally the piece of the code for open position:

void BuscarAbrir()
{
int Slippage=10;
int MagicNumber;
string symbolo=Symbol();
if (symbolo=="GBPUSD"){MagicNumber=185258471411;}
if (symbolo=="EURUSD"){MagicNumber=458555788512;}
if (symbolo=="NZDUSD"){MagicNumber=129999996613;}
if (symbolo=="USDCAD"){MagicNumber=123456741814;}
if (symbolo=="USDCHF"){MagicNumber=111112225415;}
if (symbolo=="EURCHF"){MagicNumber=128588888216;}
if (symbolo=="EURJPY"){MagicNumber=745698523657;}
if (symbolo=="GBPJPY"){MagicNumber=555555555228;}
.
.
.
if (anterior && (comentar != -1))
{
if (Kumo == 1) Print("SELL signal");
enviar = "SELL signal";
int ticket = 0;
Arko = 0;
while ((ticket <= 0) && (Arko < Number))
{
while (!IsTradeAllowed()) Sleep(5000);
ticket = OrderSend(Symbol(),OP_SELL,LotsRisk(StopLoss),Bid, Slippage,Bid + StopLoss * Point,Bid - TakeProfit * Point,Version,MagicNumber,0,Red);
if (ticket < 0)
{
Print("Error opening SELL order! ",ErrorDescription(GetLastError()));
var_116 = "Error opening SELL order! " + ErrorDescription(GetLastError());
Arko++;
}
}
comentar = -1;
}
else
{
if (posterior && (comentar != 1))
{
if (Kumo == 1) Print("BUY signal");
enviar = "BUY signal";
ticket = 0;
Arko = 0;
while ((ticket <= 0) && (Arko < Number))
{
while (!IsTradeAllowed()) Sleep(5000);
ticket = OrderSend(Symbol(),OP_BUY,LotsRisk(StopLoss),Ask,S lippage,Ask - StopLoss * Point,Ask + TakeProfit * Point,Version,MagicNumber,0,Blue);
if (ticket < 0)
{
Print("Error opening BUY order! ",ErrorDescription(GetLastError()));
var_116 = "Error opening BUY order! " + ErrorDescription(GetLastError());
Arko++;
}
}
comentar = 1;
}
}
}


Thanks for your help and sorry if my english is no very good.

Last edited by cyberpasta; 03-05-2008 at 09:57 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #748 (permalink)  
Old 03-05-2008, 02:43 PM
Junior Member
 
Join Date: Mar 2008
Posts: 1
charlestrn is on a distinguished road
Question Expert Advisor

Please help...
How come the EA works with my Demo account but not with the Live account. (same set up, same broker, same everything...)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #749 (permalink)  
Old 03-05-2008, 02:55 PM
zupcon's Avatar
Senior Member
 
Join Date: Dec 2005
Location: Malta
Posts: 235
zupcon is on a distinguished road
I believe some brokers don't allow EA's to be run by default. It might be worth checking with your broker.

Its also possible within the EA to determine if the account is a demo, take a look at the source code and see if the EA uses the function IsDemo, it may be the developer only wanted it to run on demo accounts
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #750 (permalink)  
Old 03-05-2008, 04:16 PM
Junior Member
 
Join Date: May 2007
Posts: 16
cyberpasta is on a distinguished road
Quote:
Originally Posted by danielp View Post
Hi Guys,
How do you change an alert indicator into a trading EA?
I've tried changing the command Alert(Symbol()+" "+Period()+" XO Long ",Bid); into OrderSend(Symbol(),OP_BUY,0.01,Ask,3,20,20,"XO-CCI",1,0,Blue); at the start I chose menu to make EA, then content of my alert indicator, i copied to this EA, then I changed the command alert to trading command as above, then i compiled. But the compiled EA is not making any trade after i tried it on 1M chart for a day.

Please help.
Hi danielp!! Are you from fxreviews blog? I can help you for coding.
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 12:19 PM.



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