keylove:
[...] Pls what can i do?
You can do this: [...] Pls what can i do?
For large blocks of code please attach the file. For small blocks of code please use the SRC button.


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
Can someome help me on this matter? i want my ea to be placing order at the closing of candle (i.e formation of a new candle ) i have used this formular :
bool Fun_New_Bar()
{
static datetime New_Time=0;
bool New_Bar=false;
if(New_Time!=Time[0])
{
New_Time=Time[0];
New_Bar=true;
return(New_Bar);
}
return(false);
}
but it didnt work this formular places order while the candle has not closed. Pls what can i do?
I didnt get the way i will implement the code because i am a begiinner pls help direct me where to fix them or you can help me to edit it
//+------------------------------------------------------------------+
//| Easypips.mq4 |
//| Copyright © 2010, MetaQuotes Software Corp. |
//| https://www.metaquotes.net// |
//+------------------------------------------------------------------+
extern double Lots = 0.02;// you can adjust the lots
extern bool New_Bar=true;
extern double StopLoss=100;
extern double TakeProfit1=100;
extern double TP=0;
datetime bartime=0;
int bartick=0;
extern bool TradeAllowed=true;
extern bool TARGET_UPx=true;
extern bool TARGET_DNx=true;
extern bool ProfitMade=3;
extern int maxTradesPerPair=1;
extern int otstup1 = 1;
extern int otstup = 20 ;
extern int otstupy = 1 ;
extern bool buy=true;
extern bool sell=true;
datetime New_Time=0;
extern int stoplossbars =5;
extern string x1="for comment e-mail;fmidowu@yahoo.com";
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
if(bartime!=Time[0])
{
bartick++;
TradeAllowed=true;
}
if(Bar()==false)
return;
Pattern();
Manager();
easy();
Bar();
return(0);
}
bool Bar()
{
static datetime New_Time=0;
bool New_Bar=false;
if(New_Time!=Time[0])
{
New_Time=Time[0];
New_Bar=true;
return(New_Bar);
}
return(false);
}
/////////////////////////////////////////////
bool Pattern()
{
bool buy=false;
bool sell=false;
double tr=iATR(NULL,PERIOD_H1,14,0);
double sd=iStdDev(NULL,PERIOD_H1,14,0,MODE_SMA,PRICE_CLOSE,0);
double takeprofit=High[iHighest(NULL,0,MODE_HIGH,stoplossbars,1)]+otstup*Point;
double takeprofit1=Low[iLowest(NULL,0,MODE_LOW,stoplossbars,1)]-otstup*Point;
// check for long position (BUY) possibility
if (Ask<= takeprofit1&&tr<sd&&Bar()&&TradeAllowed)
{
buy=true;
return(true);
}
// check for short position (SELL) possibility
if (Bid>=takeprofit&&tr<sd&&Bar()&&TradeAllowed)
{
sell=true;
return(true);
}
}
bool Manager()
{
if(OpenOrdersForThisEA() > 0 )
{
{ double takeprofitt=High[iHighest(NULL,0,MODE_HIGH,stoplossbars,1)]+otstupy*Point;
double takeprofitt1=Low[iLowest(NULL,0,MODE_LOW,stoplossbars,1)]-otstupy*Point;
for( int cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY && OrderProfit()>1 &&(Bid-OrderOpenPrice()>=TakeProfit1*Point)&&OrderSymbol()==Symbol())
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
return(true); // close position
}
}
}
}
if(OrderType()==OP_BUY && OrderProfit()>1 &&Ask>= takeprofitt&&OrderSymbol()==Symbol())
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
return(true); // close position
}
if(OrderType()==OP_SELL && OrderProfit()>1 &&(OrderOpenPrice()-Ask>=TakeProfit1*Point) &&OrderSymbol()==Symbol())
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
return(true); // close position
}
if(OrderType()==OP_SELL && OrderProfit()>1 &&Bid<=takeprofitt1&&OrderSymbol()==Symbol())
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
return(true); // close position
}
}
}
return(true);
int OpenOrdersForThisEA()
{
for(int cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol())
{
cnt++;
}
}
return(cnt);
}
bool easy()
{double takeprofitt=High[iHighest(NULL,0,MODE_HIGH,stoplossbars,1)]+otstupy*Point;
double takeprofitt1=Low[iLowest(NULL,0,MODE_LOW,stoplossbars,1)]-otstupy*Point;
string PRC12="";
string PRCII2="";
PRC12= "Upper Entry Target [ "+(NormalizeDouble(TARGET_UPx,Digits))+" ] "+"";
PRCII2="Lower Entry Target [ "+(NormalizeDouble(TARGET_DNx,Digits))+" ] "+"";
double TARGET_UPx=((takeprofitt));
double TARGET_DNx=((takeprofitt1));
if(OpenOrdersForThisEA() < maxTradesPerPair )
{
if (buy==true)
{
if(ProfitMade==0) TP=0; else TP=( NormalizeDouble(TARGET_UPx,Digits));
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,TP,"femi",0,0,Green);
return(true);
}
}
}
if(sell==true)
{
if(ProfitMade==0) TP=0; else TP=( NormalizeDouble(TARGET_DNx,Digits));
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,TP,"femi",0,0,Green);
return(true);
}
}
}
return(true);