Low and High - page 2

 

How far goes i? What is Bars-1 number?

 
if(Hour() == 17 && gethighlows == true)
{
gethighlows = false;
HighValue=High[iHighest(NULL,15,MODE_HIGH,8,1)]; // 8 M15 bars between 15.00-17.00
LowValue=Low[iLowest(NULL,15,MODE_LOW,8,1)]; // 8 M15 bars between 15.00-17.00
}
 
fxcourt:
if(Hour() == 17 && gethighlows == true)
{
gethighlows = false;
HighValue=High[iHighest(NULL,15,MODE_HIGH,8,1)]; // 8 M15 bars between 15.00-17.00
LowValue=Low[iLowest(NULL,15,MODE_LOW,8,1)]; // 8 M15 bars between 15.00-17.00
}

It doesn't work! I really don't know what to do...

 
01005379:

[...]

It doesn't work! I really don't know what to do...

It what way doesn't it work? Are the values wrong? Are they not getting calculated at all?

 
jjc:

It what way doesn't it work? Are the values wrong? Are they not getting calculated at all?

I can't figure it out. I have order to open buy when the price is bigger then HighValue and vice versa for sell.

How can write these values at monitor? With Print("High value: ",HighValue);

I think that is the only way to find what these values are, but they are not high/low between 15.00 and 17.00.

 
are you using an m15 chart?
 

Yes. I think that the best is to put code here an then maybe someone find a solution.


if(Hour() == 17 && gethighlows == true)
{
gethighlows = false;
TopRange=High[iHighest(NULL,15,MODE_HIGH,8,1)]; // 8 M15 bars between 15.00-17.00
LowRange=Low[iLowest(NULL,15,MODE_LOW,8,1)]; // 8 M15 bars between 15.00-17.00
}

//-----

if (Hour() ==0 && (Minute()==0 && (Seconds()==1)))
{
TopRange=0;
LowRange=0;
bought=false;
sold=false;
sessionfound=false;
}
//-----
bool TradeDayOK=(DayOfWeek()>=1) && (DayOfWeek()<=5);
if ((DayOfWeek()==1) && (Trade_on_Monday==true)) TradeDayOK=true;

//-----
total=OrdersTotal();
if(total<1)
{
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if(newbar==Time[0])return(0);
else newbar=Time[0];

if(TradeDayOK)
{
if(sessionfound && ( (Hour()>=17) && (Minute()>15) && Hour()<=23)
{
if ((bought==false) && (Low[1] > (TopRange+Point*3)))
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-(StopLoss*Point),Ask+(TakeProfit*Point),0,0,Blue);
bought=true;
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
if ((sold==false) && (High[1] < (LowRange-Point*3) ))
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+(StopLoss*Point),Bid-(TakeProfit*Point),0,0,Red);
sold=true;
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}
return(0);
}
}

 
so what happens when you run the ea
 
It opens buy and sell positions but not at the right levels.
 
01005379:

Yes. I think that the best is to put code here an then maybe someone find a solution.


if(Hour() == 17 && gethighlows == true)
{
gethighlows = false;
TopRange=High[iHighest(NULL,15,MODE_HIGH,8,1)]; // 8 M15 bars between 15.00-17.00
LowRange=Low[iLowest(NULL,15,MODE_LOW,8,1)]; // 8 M15 bars between 15.00-17.00
}

//-----

if (Hour() ==0 && (Minute()==0 && (Seconds()==1)))
{
TopRange=0;
LowRange=0;
bought=false;
sold=false;
sessionfound=false;
}
//-----
bool TradeDayOK=(DayOfWeek()>=1) && (DayOfWeek()<=5);
if ((DayOfWeek()==1) && (Trade_on_Monday==true)) TradeDayOK=true;

//-----
total=OrdersTotal();
if(total<1)
{
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if(newbar==Time[0])return(0);
else newbar=Time[0];

if(TradeDayOK)
{
if(sessionfound && ( (Hour()>=17) && (Minute()>15) && Hour()<=23)
{
if ((bought==false) && Ask >= TopRange)

{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-(StopLoss*Point),Ask+(TakeProfit*Point),0,0,Blue);
bought=true;
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
if ((sold==false) && Bid <= LowRange)
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+(StopLoss*Point),Bid-(TakeProfit*Point),0,0,Red);
sold=true;
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}
return(0);
}
}

Reason: