You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Good afternoon.
I am getting started writing and understanding code. So far I am overwhelmed.
I would like to start writing an ea using the MACD histogram and when the triger line crosses above and below the histogram.
does anybody have a simple program sugestion to start understanding the code and let it run to see how it trades?
Thanks-you
daniel
Trendline-Import from Excel/CSV=?
Hi, i have written some simple scripts the last days, specially ObjectCreate (OBJ_TREND with Ray=1) it's really nice how this works but how can i draw Objects from a ready csv-File, where i have some history Close-Data for my Close-Lines, because i want to be able to delete my Template und import the data everytime i need them with a script,
has anyone a idee how this could work?
CSV has a date (without time) & Close-Value (i would not need more data for the Lines)
and the Script should draw a Line from this date with Ray=1 and customize color
maybe the script could also check the open chart (symbol) and take the correct csv-file, if a have more than one ;-)
Please can anyone help me
Error for OrderDelete(OrderTicket())
Hi all!
I'm new in MQL4 programming but on the others side I'm know C++.
But I've some problems with trading functions.
This is my problem :
I create a pending order with :
ticket = OrderSend(Symbol(),OP_SELLSTOP,Lots,Bid-5*Point,slippage,0,0,"",0,0,Green);
and in an other point of the program I want delete it :
if (OrderSelect(ticket,SELECT_BY_TICKET)) OrderDelete(OrderTicket());
ERROR 4108! Why ? Ticket number is correct, I print it.
But if I use :
if (OrderSelect(position, SELECT_BY_POS))OrderDelete(OrderTicket());
is OK!
Why ?
Thank you for your support and for the forum.
Code to Terminate EA ???
Hi Everyone,
I'm looking for code that will Terminate an EA. I've posted a little martingale I wrote. I have it where it will Close all Pending and Open Orders when it reaches a Percent of Account Drawdown. I've also been able to make it stop trading when a Daily Profit Goal is reached. It starts trading again the next day. (Thanks to whoever wrote SWB Grid, since I used their code.)
However, I would like to have the EA terminate when it hits a certain condition. Say, it hits Max Percentage Drawdown and closes all pending orders and open positions. At that point, I want the EA to terminate itself so it won't start trading again until I remove the EA from the chart and put it back on.
Here's the EA. Any suggestions or help is greatly appreciated!!
Thanks,
Joe
Need Help on "'\end_of_program' - unbalanced left parenthesis"
Hi, I've been working on an EA and I keep getting an error message when compiling: "'\end_of_program' - unbalanced left parenthesis." Usually this error message is related to uneven number of left and right parenthesis. However, I checked my codes high and low and found that I have equal number of left and right parenthesis. So it really drives me nuts that I cann't figure out where it went wrong. Can anyone check my codes and tell me how to fix it ? Thanks a million. My codes are posted below:
//+------------------------------------------------------------------+
//| Breakout.mq4 |
//| Pooh |
//| |
//+------------------------------------------------------------------+
#property copyright "Pooh"
#property link ""
//--- input parameters
extern int LengthI=23;//for enter market
extern int LengthO=7;//for exit
extern double Lots=0.1; //for order size
extern int N1=14; //period for ATR
extern int NLots=1; //number of increased order lot
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
double HLong,LLong,HShort,LShort;
HLong=iHigh(NULL,0,iHighest(NULL,0,2,LengthI,2));
LLong=iLow(NULL,0,iLowest(NULL,0,1,LengthO,2));
LShort=iLow(NULL,0,iLowest(NULL,0,1,LengthI,2));
HShort=iHigh(NULL,0,iHighest(NULL,0,2,LengthO,2));
int cnt, cot,ticket, total;
total=OrdersTotal();
if (total<1)
{
if (iClose(NULL,0,1)>HLong)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,LLong,300000,"EA Long",123,0,Green);
if (ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("Long order opened : ",OrderOpenPrice());
}
else
Print("Error opening Long order : ",GetLastError());
return(0);
}
if (iClose(NULL,0,1)<LShort)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,HShort,0.0001,"EA Short",123,0,Red);
if (ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("Short order opened:",OrderOpenPrice());
}
else Print("Error opening SHORT order:",GetLastError());
return(0);
}
return(0);
}
for(cnt=0;cnt<total;cnt++)
{ //10
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY) // long position is opened
{
// should it be closed?
if(Bid<=LLong)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);//close position
return(0);
}
//modify trailing stop
OrderModify(OrderTicket(),OrderOpenPrice(),LLong,OrderTakeProfit(),0,Green);
return(0);
}
else
{
if(Ask>=HShort)
{OrderClose(OrderTicket(),OrderLots(),Ask,3,Purple);//close position
return(0);
}
//modify trailing stop
OrderModify(OrderTicket(),OrderOpenPrice(),HShort,OrderTakeProfit(),0,Red);
return(0);
}
}
}
//get long and short order lots total
double LOrderLots=0;
double SOrderLots=0;
for(cnt=0,cnt<=total,cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderType()==OP_BUY)
LOrderLots=LOrderLots+OrderLots();
if(OrderSymbol()==Symbol()&&OrderType()==OP_SELL)
SOrderLots=LOrderLots+OrderLots();
}
//increase open order
for(cot=0,cot<=total,cot++)
{ //1
//add position for long order
if(OrderSelect(cot,SELECT_BY_POS,MODE_TRADES)==true) //if there are open orders
{ if(OrderMagicNumber==123 && OrderSymbol()==Symbol()&&OrderType()==OP_BUY) //2- if open order was opened by EA pooh abd type is Long
{ //3
for(int i=1;i<=15;i++)
{ if(Bid>=OrderOpenPrice()+i*0.5*iATR(NULL,0,N1,0)&&(Bid<(OrderOpenPrice()+(i+1)*0.5*iATR(NULL,0,N1,0))&&LOrderLots<Lots*(i+1)) //4
{ ticket=OrderSend(Symbol(),OP_BUY,NLots*Lots,Ask,3,LLong,300000,"EA Long",123,0,Green); //5
if (ticket>0)
{ //6
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("Long order opened : ",OrderOpenPrice());
} //6
else
Print("Error opening Long order : ",GetLastError());
break;
} //5
} //4
return(0);
//add position for short order
if(OrderMagicNumber()==123 && OrderSymbol()==Symbol() && OrderType()==OP_SELL)
{ //7
for(int n2=1;n2<=15;n2++)
{ if(Ask(OrderOpenPrice()-(n2+1)*0.5*iATR(NULL,0,N1,0))&&SOrderLots<Lots*(n2+1)) //8
{ ticket=OrderSend(Symbol(),OP_SELL,NLots*Lots,Bid,3,HShort,0.0001,"EA Short",123,0,Red); //9
if (ticket>0)
{ // 10
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("Short order opened : ",OrderOpenPrice());
} // 10
else
Print("Error opening Short order : ",GetLastError());
break;
} //9
} //8
return(0);
} //7
} //3
} //2
} //1
return(0)
}
NEED a coder to code a simple indicator
I need someone to code a indicator that does this:
On a simple Fibonacci using only the 0,50,100 lines. When a bar closes above 50% or below 50% but having the option to pick if I am looking for a close above or below, not both. So if i am looking for a close below 50% I don't want every time it closes above 50 the alert going off. I want it to alert me by a sound and send me a email and/or text. Is this possible? Thank you!!
PICTURE: http://tinypic.com/r/dhbu6v/5
Trying to code simple logic, unable!
Hello Forum,
I believe this is very simple thing to code for you who are good enough at MQL4, but I am beginner and I have problems, I read all lessons here but still could not figure it out
so I want to make automated trading
lot size 0.1
stoploss = 30 pips
profit target 50 pips
pair AUDUSD
If (highprice - lowprice) < 60 pips between 02:00 GMT and 10:00 GMT then sell AUDUSD at lowprice - 5pips or buy AUDUSD at highprice + 5pips, otherwise no trade
Hello Forum,
I believe this is very simple thing to code for you who are good enough at MQL4, but I am beginner and I have problems, I read all lessons here but still could not figure it out
so I want to make automated trading
lot size 0.1
stoploss = 30 pips
profit target 50 pips
pair AUDUSD
If (highprice - lowprice) < 60 pips between 02:00 GMT and 10:00 GMT then sell AUDUSD at lowprice - 5pips or buy AUDUSD at highprice + 5pips, otherwise no trade[lang=pl]Hi i think thats is no problem to code this EA but i have question.
When you want to buy/sell ? Do you need pending orders on the low-5 high+5 levels?
regards,
Grzesiek[/lang]
[lang=pl]Hi i think thats is no problem to code this EA but i have question.
When you want to buy/sell ? Do you need pending orders on the low-5 high+5 levels?
regards,
Grzesiek[/lang]Hello,
thanks for helping
Yes, so more precisely AUDUSD trade range (difference between high price and low price) between 02:00 GMT and 10:00 GMT times (this is very important in code) is less than 60 pips so this is tradable signal. So you sell if prices reaches low price (between 02:00 and 10:00) - 5 pips and you buy if prices reaches high price + 5 pips.
example
between 02:00 and 10:00 GBPUSD low price was 1.6000, high was 1.6050, so if prices reaches 1.5995 sell automatically and if price reaches 1.6055 buy automatically placing 30 pips stop loss order automatically and 50 pips take profit.
if you don't have time just give me indication how to begin, I read lesson but I don't have practice to do the work
thanks
Hi, I've been working on an EA and I keep getting an error message when compiling: "'\end_of_program' - unbalanced left parenthesis." Usually this error message is related to uneven number of left and right parenthesis. However, I checked my codes high and low and found that I have equal number of left and right parenthesis. So it really drives me nuts that I cann't figure out where it went wrong. Can anyone check my codes and tell me how to fix it ? Thanks a million. My codes are posted below:
//+------------------------------------------------------------------+
//| Breakout.mq4 |
//| Pooh |
//| |
//+------------------------------------------------------------------+
#property copyright "Pooh"
#property link ""
//--- input parameters
extern int LengthI=23;//for enter market
extern int LengthO=7;//for exit
extern double Lots=0.1; //for order size
extern int N1=14; //period for ATR
extern int NLots=1; //number of increased order lot
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
double HLong,LLong,HShort,LShort;
HLong=iHigh(NULL,0,iHighest(NULL,0,2,LengthI,2));
LLong=iLow(NULL,0,iLowest(NULL,0,1,LengthO,2));
LShort=iLow(NULL,0,iLowest(NULL,0,1,LengthI,2));
HShort=iHigh(NULL,0,iHighest(NULL,0,2,LengthO,2));
int cnt, cot,ticket, total;
total=OrdersTotal();
if (total<1)
{
if (iClose(NULL,0,1)>HLong)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,LLong,300000,"EA Long",123,0,Green);
if (ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("Long order opened : ",OrderOpenPrice());
}
else
Print("Error opening Long order : ",GetLastError());
return(0);
}
if (iClose(NULL,0,1)<LShort)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,HShort,0.0001,"EA Short",123,0,Red);
if (ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("Short order opened:",OrderOpenPrice());
}
else Print("Error opening SHORT order:",GetLastError());
return(0);
}
return(0);
}
for(cnt=0;cnt<total;cnt++)
{ //10
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY) // long position is opened
{
// should it be closed?
if(Bid<=LLong)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);//close position
return(0);
}
//modify trailing stop
OrderModify(OrderTicket(),OrderOpenPrice(),LLong,OrderTakeProfit(),0,Green);
return(0);
}
else
{
if(Ask>=HShort)
{OrderClose(OrderTicket(),OrderLots(),Ask,3,Purple);//close position
return(0);
}
//modify trailing stop
OrderModify(OrderTicket(),OrderOpenPrice(),HShort,OrderTakeProfit(),0,Red);
return(0);
}
}
}
//get long and short order lots total
double LOrderLots=0;
double SOrderLots=0;
for(cnt=0,cnt<=total,cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderType()==OP_BUY)
LOrderLots=LOrderLots+OrderLots();
if(OrderSymbol()==Symbol()&&OrderType()==OP_SELL)
SOrderLots=LOrderLots+OrderLots();
}
//increase open order
for(cot=0,cot<=total,cot++)
{ //1
//add position for long order
if(OrderSelect(cot,SELECT_BY_POS,MODE_TRADES)==true) //if there are open orders
{ if(OrderMagicNumber==123 && OrderSymbol()==Symbol()&&OrderType()==OP_BUY) //2- if open order was opened by EA pooh abd type is Long
{ //3
for(int i=1;i<=15;i++)
{ if(Bid>=OrderOpenPrice()+i*0.5*iATR(NULL,0,N1,0)&&(Bid<(OrderOpenPrice()+(i+1)*0.5*iATR(NULL,0,N1,0))&&LOrderLots<Lots*(i+1)) //4
{ ticket=OrderSend(Symbol(),OP_BUY,NLots*Lots,Ask,3,LLong,300000,"EA Long",123,0,Green); //5
if (ticket>0)
{ //6
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("Long order opened : ",OrderOpenPrice());
} //6
else
Print("Error opening Long order : ",GetLastError());
break;
} //5
} //4
return(0);
//add position for short order
if(OrderMagicNumber()==123 && OrderSymbol()==Symbol() && OrderType()==OP_SELL)
{ //7
for(int n2=1;n2<=15;n2++)
{ if(Ask(OrderOpenPrice()-(n2+1)*0.5*iATR(NULL,0,N1,0))&&SOrderLots<Lots*(n2+1)) //8
{ ticket=OrderSend(Symbol(),OP_SELL,NLots*Lots,Bid,3,HShort,0.0001,"EA Short",123,0,Red); //9
if (ticket>0)
{ // 10
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("Short order opened : ",OrderOpenPrice());
} // 10
else
Print("Error opening Short order : ",GetLastError());
break;
} //9
} //8
return(0);
} //7
} //3
} //2
} //1
return(0)
}[lang=pl]Hi there was few mistake, two unbalanced ")" in function OrderMagicNumer you should use () at the end. In the for loop you should use ";" instead of ",".
If you need to find unbalanced parenthesis i recomend you Notepad ++ [/lang]