Newbie needs some advise

 

Hello everyone,

1. I got stuck with a tiny issue... I work with 30m chart and I want to check if my last candle became the highest among last 20 candles in order to open BUY. For some reason this just doesn't work.

The tester returns the highest value only of the last tick of the test and simply doesn't want to check each candle... How should I fix it?


2. The second issue is I want to work only with candles not with ticks. When my order closes by SL it opens the new deal on next tick and I want it to wait until the current bar closes and then based

on assessment make signals. Is it possible? Don't say just to pick other testing option with open/closing points, because on real acount there are ticks and the EA will fail.


3. Finally, I want to i.e. open a position or close it 5 sec before candle closes (29.55, 59.55) based on indicators' assessment without waiting for the next tick, is it possible? The reason is I keep it as

it is in my buy signal, it waits for the next tick, which may not appear in the last 5 sconds and the moment is lost. The same goes for closing, because if the moment is lost the next signal for some

reason may appear after few more bars, which is extremely bad.


Thank you in advance :)


extern int     MAGIC             = 90324752;
extern int     START_HOUR        = 7;
extern int     FINISH_HOUR       = 18;
extern int     TRADE_LIMIT       = 3;
extern int     SMMA_PERIOD       = 100;
extern int     BB_PERIOD         = 50;
extern double  BB_DEV            = 1;
extern double  LOT               = 1;
extern double  StopLoss          = 400;
extern double  TakeProfit        = 2000;

void OnTick()
{
static int    TRADE_COUNT;
static int    TICKET;
static bool   ANS;  
static bool   POS_OPENED;  

double SMMA                 = iMA (Symbol(),0,SMMA_PERIOD,0,MODE_SMMA,PRICE_CLOSE,0);
double BB_UP                = iBands(Symbol(),0,BB_PERIOD,BB_DEV,0,PRICE_CLOSE,MODE_UPPER,0);       

double HIGHEST              = High[iHighest(Symbol(),0,MODE_HIGH,20,0)];

 if(OrdersTotal() == 0)
   {
      POS_OPENED = FALSE;
   }
 for(int POS = 0; POS < OrdersTotal(); POS++)
   {  
      if(OrderSelect(POS,SELECT_BY_POS,MODE_TRADES) == TRUE)
      {
         if(OrderSymbol() == Symbol() && OrderMagicNumber()== MAGIC)            
         {
//---- BUY CANCELATION ----//
 
            if(OrderType() == OP_BUY)
            {              
               if(Close[1] < SMMA || Close[1] < BB_UP)      
               {
                  ANS = OrderClose(TICKET,LOT,OrderClosePrice(),0,Blue);
                  if(ANS == TRUE)
                  {
                     Alert("The order closing has been completed!");
                     POS_OPENED = FALSE;
                  }
               }
            }   
}
}
}

if(Hour() >= START_HOUR && Hour() <= FINISH_HOUR && TRADE_COUNT < TRADE_LIMIT && POS_OPENED == FALSE && Seconds() >= 55)
if(Minute() == 29 || Minute() == 59)
{     
  if(Close[0] > SMMA && Close[0] > BB_UP && Close[0] >= HIGHEST)

  {
   TICKET = OrderSend(Symbol(),OP_BUY,LOT,Ask,0,Ask-StopLoss*Point,Ask+TakeProfit*Point,NULL,MAGIC,0,Blue);
   if(TICKET < 0)
      {
         Alert("Order Send failed, error # ", GetLastError() );
      } 
  }
}
}
 
Imminence:

Hello everyone,

1. I got stuck with a tiny issue... I work with 30m chart and I want to check if my last candle became the highest among last 20 candles in order to open BUY. For some reason this just doesn't work.

The tester returns the highest val..


if you were going to log the time based on your server time..

here's an example from the b-clock indi

double i;
int m,s;

m=Time[0]+Period()*60-TimeCurrent();
i=m/60.0;
s=m%60;
m=(m-m%60)/60;

Comment( m + " minutes " + s + " seconds left to bar end");
else wheres using the local time is best i would suppose
Reason: