Hello,
below you can see some standard time based buy/sell. for example at 10:00:00 he buys/sells,
but i wonder if you can put a pending order buy/sell the moment that the time is 10:00 with the high/low bar from previous 1hour bar,
i guess with this code you can get the the high from the previous bar but i dont know how to put a pending order with that high of that previous 1hour bar,
hope someone can help :)
datetime curTime;
curTime=Time[0];
double getal2 = High[1];
double getal3 = High[1]-0.00045;
#property copyright "Copyright © 2011, www.FxAutomated.com"
#property link "http://www.FxAutomated.com"
extern double Lots=0.1;
extern int TakeProfit=20;
extern int StopLoss=20;
extern int Slip=5;
extern int BuyMagicNumber =10001;
extern int SellMagicNumber =10002;
extern string TradeSettings="Mt4 time(min-max): hours 0-23, minutes 0-59, seconds 0-59";
extern bool AllowBuy=true;
extern bool AllowSell=true;
extern int TradeHour=0;
extern int TradeMinutes=0;
extern int TradeSeconds=0;
extern string OurSite="www.FxAutomated.com";
extern string SignalsAndManagedAccounts="www.TradingBug.com";
int start()
{
int StopMultd,Sleeper=1;
int digits=MarketInfo("EURUSD",MODE_DIGITS);
if(digits==5){StopMultd=10;} else{StopMultd=1;}
double TP=NormalizeDouble(TakeProfit*StopMultd,Digits);
double SL=NormalizeDouble(StopLoss*StopMultd,Digits);
int Slippage=Slip*StopMultd;
double slb=NormalizeDouble(Ask-SL*Point,Digits);
double sls=NormalizeDouble(Bid+SL*Point,Digits);
double tpb=NormalizeDouble(Ask+TP*Point,Digits);
double tps=NormalizeDouble(Bid-TP*Point,Digits);
if(OrdersTotal()>0){
for(int i=1; i<=OrdersTotal(); i++)
{
if (OrderSelect(i-1,SELECT_BY_POS)==true)
{
if(OrderMagicNumber()==BuyMagicNumber) {int halt1=1;}
if(OrderMagicNumber()==SellMagicNumber) {int halt2=1;}
}
}
}
if((halt1!=1)&&(AllowBuy==true)){
if ((TradeHour==Hour())&&(TradeMinutes==Minute())&&(TradeSeconds>=Seconds()))
{
int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,slb,tpb,"time trader buy order ",BuyMagicNumber,0,Blue);
if(openbuy<1){int buyfail=1;}
}
}
if((halt2!=1)&&(AllowSell==true)){
RefreshRates();
if ((TradeHour==Hour())&&(TradeMinutes==Minute())&&(TradeSeconds>=Seconds()))
{
int opensell=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,sls,tps,"time trader sell order ",SellMagicNumber,0,Green);
if(opensell<1){int sellfail=1;}
}
}
if(buyfail==1||sellfail==1){
int Error=GetLastError();
if(Error==130){Alert("Wrong stops. Retrying."); RefreshRates();}
if(Error==133){Alert("Trading prohibited.");}
if(Error==2){Alert("Common error.");}
if(Error==146){Alert("Trading subsystem is busy. Retrying."); Sleep(500); RefreshRates();}
}
return(0);
}