EA Time based help

 

Hello,

some standard time based buy/sell. for example at 10:00:00 he buys/sells that is easy

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; 

 
jens1211: time based buy/sell. .. that is easy. i dont know how to put a pending order with that high of that previous 1hour bar,
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Same way you open an order except you don't use OP_BUY, you use OP_BUYSTOP if the price is above the current market (by at least MODE_STOPLEVEL points.)
 
WHRoeder:

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Same way you open an order except you don't use OP_BUY, you use OP_BUYSTOP if the price is above the current market (by at least MODE_STOPLEVEL points.)

 ok yes if time is 00:00 then he puts a buystop , that is correct but he doesnt go in on the right moment it is so weird lol,

for example buy stop 3 : 1.24305 he needs to go buy , but he goes in at 00:40 already , but when i watch the 1hour bar and i watch 00:00 the high is 1.24266 

also with the buystop5 he goes in too early , not at the exact price that i gave.

I tried to put slippage etc on 0 , but no nothing helped,

i cant see a mistake in the code, at 00hour he makes a buystop 10pips above the price , but he enters too early not my price that i gave 

if ((TradeHour==Hour())&&(TradeMinutes==Minute())&&(TradeSeconds>=Seconds())) //Signal Buy
 {
    double point;
   double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
   double takeprofit=NormalizeDouble(Bid+minstoplevel*Point,Digits);
//----
   point=MarketInfo(Symbol(),MODE_POINT);
   int expiration=CurTime()+PERIOD_D1*60;
   
   int openbuy=OrderSend(Symbol(),OP_BUYSTOP,Lots,Bid+100*point,Slippage,slb,Bid+120*point,"time trader buy order ",BuyMagicNumber,0,Blue);
   if(openbuy<1){int buyfail=1;}
 }
 

when i make a script and i run this code with Buystop examples , he puts perfect pending orders , and perfect timing when he hits the buy stop line he goes in not earlier

//+------------------------------------------------------------------+
//|                                                 send_pending.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"
#property show_confirm

//+------------------------------------------------------------------+
//| script "send pending order with expiration data"                 |
//+------------------------------------------------------------------+
int start()
  {
   int    ticket,ticket2,ticket3,ticket4,ticket5,ticket6,ticket7,ticket8,ticket9,ticket10,ticket11,ticket12,ticket13,ticket14,ticket15,ticket16,ticket17,ticket18,ticket19,ticket20,ticket21,ticket22,ticket23,ticket24,ticket25,ticket26,ticket27,ticket28,expiration;
   double point;
   double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
   double takeprofit=NormalizeDouble(Bid+minstoplevel*Point,Digits);
//----
   point=MarketInfo(Symbol(),MODE_POINT);
   expiration=CurTime()+PERIOD_D1*60;
//----
   while(true)
     {
      ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-40*point,0,0,Bid-60*point,"4-2",16384,expiration,Green);
      ticket2=OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid+80*point,0,0,Bid+100*point,"4-2",16384,expiration,Green);
      ticket4=OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid+70*point,0,0,Bid+90*point,"3-2",16384,expiration,Green);
      ticket5=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-50*point,0,0,Bid-70*point,"5-2",16384,expiration,Green);
      ticket6=OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid+90*point,0,0,Bid+110*point,"5-2",16384,expiration,Green);
      ticket7=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-40*point,0,0,Bid-50*point,"4-1",16384,expiration,Green);
      ticket8=OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid+80*point,0,0,Bid+90*point,"4-1",16384,expiration,Green);
      ticket9=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-20*point,0,0,Bid-30*point,"2-1",16384,expiration,Green);
      ticket10=OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid+60*point,0,0,Bid+70*point,"2-1",16384,expiration,Green);
      ticket11=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-50*point,0,0,Bid-60*point,"5-1",16384,expiration,Green);
      ticket12=OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid+90*point,0,0,Bid+100*point,"5-1",16384,expiration,Green);
      ticket13=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-100*point,0,0,Bid-120*point,"10-2",16384,expiration,Green);
      ticket14=OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid+140*point,0,0,Bid+160*point,"10-2",16384,expiration,Green);
      ticket19=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-100*point,0,0,Bid-110*point,"10-1",16384,expiration,Green);
      ticket20=OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid+140*point,0,0,Bid+150*point,"10-1",16384,expiration,Green);
      ticket21=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-80*point,0,0,Bid-90*point,"8-1",16384,expiration,Green);
      ticket22=OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid+120*point,0,0,Bid+130*point,"8-1",16384,expiration,Green);

      
      if(ticket<=0) Print("Error = ",GetLastError());
      else { Print("ticket = ",ticket); break; }
      //---- 10 seconds wait
      Sleep(10000);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
Reason: