I've got a Problem on running EAs. You can see my code below. It's a simple moving average strategy. But it does not work. I have tried this after a different strategie does not work either. I have run this on EURUSD with data I downloaded from the Internet (since 2001) on a intraday timeframes (before i used period converter) and on a daily timeframe with data my broker is providing me.
If I run my EA he is not making any trades. But he is sending me Errors in the journal: "unmatched data error [...]"
#property copyright "Copyright 2014, vk"
#property link "-"
#property version "1.00"
extern double PeriodFastMA = 20;
extern double PeriodSlowMA = 200;
extern double lots = 0.1;
double fastMA = iMA(Symbol(), PERIOD_CURRENT, PeriodFastMA, 0, MODE_SMA, PRICE_CLOSE, 0);
double slowMA = iMA(Symbol(), PERIOD_CURRENT, PeriodSlowMA, 0, MODE_SMA, PRICE_CLOSE, 0);
if(fastMA > slowMA && OrdersTotal() == 0)
int ticket1 = OrderSend(Symbol(), OP_BUY, lots, Bid, 0, 0, 0);
if(ticket1 > 0)
Alert("Order Sended Successfully. Order No.: ", ticket1);
Alert("Order Sending Error!");
if(slowMA > fastMA)
OrderClose(ticket1, lots, Ask, 0);
first I was quite sceptical. But you are absolutely right! Thanks man!I've took that out. Now it runs! But now I've got a lot of open order errors and order closing errors. Do you know what I can do against this?
Buy orders are opened at Ask and closed at Bid
MAs can cross and recross many times in a single bar, often it is best to only check on a new bar.
ticket1 is a local variable, so will not hold the ticket number on the next tick.
Alright 1. and 3. are done now. But how can 2. be a factor? MA are set to close prices. What I have done wrong? Do you know it?
alright guys I have found my mistake.
My question now is: How can I bring my ticket variable (at least the ticketnumber which was generated in the first if-condition) into the 2nd if-condition? See at the picture below.