i would like to adding a code for this EA and make it opening only one position per one bar

 

//---- input parameters
extern int ReversPoint=50;
extern double TakeProfit = 25;
extern double Lots = 1;
extern double InitialStop = 20;

//---- buffers
int Trend,InTrend,ttime;
double Last_High, Last_Low;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{

return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted(),i,shift;

//---- TODO: add your code here
i=(Bars-counted_bars)-1;

for (shift=i; shift>=0;shift--)
{

if (Time[shift]!=ttime) InTrend=InTrend+1;
ttime=Time[shift];
if (High[shift+1]>Last_High && Trend==1) InTrend=1;
if (Low[shift+1]<Last_Low && Trend==0) InTrend=1;
if (High[shift+1]>Last_High) Last_High=High[shift+1];
if (Low[shift+1]<Last_Low) Last_Low=Low[shift+1];

if (Trend==1 && Low[shift+1]<Last_High-ReversPoint*Point && InTrend>1)
{
Trend=0;
Last_High=Low[shift+1];
Last_Low=Low[shift+1];
InTrend=1;
}

if (Trend==0 && High[shift+1]>Last_Low+ReversPoint*Point && InTrend>1)
{
Trend=1;
Last_Low=High[shift+1];
Last_High=High[shift+1];
InTrend=1;
}
//----
}
{
if (Trend==1 && Low[shift+1]<Last_High-ReversPoint*Point && InTrend>1)
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-InitialStop*Point,Ask+TakeProfit*Point, NULL,0,0,Green);
}
{
if (Trend==0 && High[shift+1]>Last_Low+ReversPoint*Point && InTrend>1)
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+InitialStop*Point,Bid-TakeProfit*Point, NULL,0,0,Green);
}
return(0);
}

 

Just use volume indication below or check current open orders datetime

if(Volume[0]>1) return(0);

This website uses cookies. Learn more about our Cookies Policy.