Low and High - page 2 12345 New comment jurcekmpt 2009.08.25 10:16 #11 How far goes i? What is Bars-1 number? raphael 2009.08.25 11:51 #12 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} jurcekmpt 2009.08.25 13:36 #13 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... JC 2009.08.25 13:56 #14 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? jurcekmpt 2009.08.25 14:06 #15 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. How and where best [ARCHIVE!] Any rookie question, iHigh w/Arrays raphael 2009.08.25 14:11 #16 are you using an m15 chart? jurcekmpt 2009.08.25 14:13 #17 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); } } [Archive!] Any rookie question, [ARCHIVE!] Any rookie question, Any rookie question, so raphael 2009.08.25 14:15 #18 so what happens when you run the ea jurcekmpt 2009.08.25 14:20 #19 It opens buy and sell positions but not at the right levels. raphael 2009.08.25 14:28 #20 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); } } 12345 New comment
How far goes i? What is Bars-1 number?
It doesn't work! I really don't know what to do...
[...]
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?
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.
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);
}
}
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);
}
}