Помогите!! [В тестере есть профит. А на демо счёте сразу идёт в лосс]

 

Тестирую советник всё работает и есть профит!! А на Демо счёте сразу идёт в лосс!!!

может гдето есть ошибка!?? подскажите!!!

 

#define MAINSEEK 148

#define BARSIZE 44  // LONG_VALUE + 5 * DOUBLE_VALUE


 int Pips = 50;

 double Lots = 0.01;


int handle;

bool MainError;


int GetTime( int Pos )

{

  int PosTime;

  

  FileSeek(handle, MAINSEEK + Pos, SEEK_SET);

  PosTime = FileReadInteger(handle);


  return(PosTime);

}


bool FindTimePlace( int SearchTime )

{

  int LeftTime, RightTime, PosTime;

  int Left, Right, Pos;

  

  Left = 0;

  Right = FileSize(handle) - MAINSEEK - BARSIZE;

  

  LeftTime = GetTime(Left);

  RightTime = GetTime(Right);

  

  while ((LeftTime < SearchTime) && (SearchTime < RightTime))

  {    

    Pos = (Left + Right) / 2;

    Pos -= Pos % BARSIZE;

    

    if (Pos == Left)

      break;

    

    PosTime = GetTime(Pos);

    

    if (SearchTime >= PosTime)

    {

      Left = Pos;

      LeftTime = GetTime(Left);

    }

    else // if (SearchTime < PosTime)

    {

      Right = Pos;

      RightTime = GetTime(Right);

    }

  }

  

  if (SearchTime <= RightTime)

  {

    FileSeek(handle, Left + MAINSEEK, SEEK_SET);

    return(TRUE);

  }

  else

    return(FALSE);

}


void init()

{

  handle = FileOpenHistory(Symbol() + Period() + ".hst", FILE_BIN|FILE_READ);

  

  if (handle > 0)

    MainError = TRUE;

  else

  {

    MainError = FALSE;

    

    return;

  }


  MainError = FindTimePlace(Time[0]);

  

  if (!MainError)

    FileClose(handle);

    

  return;

}


void deinit()

{

  if (MainError)

    FileClose(handle);

  

  return;

}


bool GetPrices( int& PriceTime, int& PriceLow, int& PriceHigh)

{

  PriceTime = FileReadInteger(handle);

  FileSeek(handle, DOUBLE_VALUE, SEEK_CUR);

  PriceLow = FileReadDouble(handle) / Point + 0.01;

  PriceHigh = FileReadDouble(handle) / Point + 0.01;

  FileSeek(handle, 2 * DOUBLE_VALUE, SEEK_CUR);


  if (FileTell(handle) + BARSIZE <= FileSize(handle))

    return(TRUE);

  else

    return(FALSE);

}


int GetTimeTrade()

{

  static bool FlagUP = TRUE;

  static int Min = 999999;

  static int Max = 0;

  static int NTime;

  int ResTime;

  

  int PriceTime, PriceLow, PriceHigh;

    

  while (TRUE)

  {

    if (!GetPrices(PriceTime, PriceLow, PriceHigh))

      return(-1);


    if (FlagUP)

    {

      if (PriceHigh > Max)

      {

        Max = PriceHigh;

        NTime = PriceTime;

      }

      else if (Max - PriceLow >= Pips)

      {

        FlagUP = FALSE;

        Min = PriceLow;

        

        break;

      }

    }

    else // (FlagUP == FALSE)

    {

      if (PriceLow < Min)

      {

        Min = PriceLow;

        NTime = PriceTime;

      }

      else if (PriceHigh - Min >= Pips)

      {

        FlagUP = TRUE;

        Max = PriceHigh;

        

        break;

      }

    }

  }

  

  ResTime = NTime;

  NTime = PriceTime;


  return(ResTime);

}


void CloseOrder( int Ticket )

{

  OrderSelect(Ticket, SELECT_BY_TICKET);

  

  if (OrderType() == OP_BUY)

    OrderClose(Ticket, OrderLots(), Bid, 0);

  else  // (OrderType() == OP_SELL)

    OrderClose(Ticket, OrderLots(), Ask, 0);


  return;  

}


int ReverseOrder( int Ticket)

{

  if (Ticket == 0)

    Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 0, 0, 0);

  else

  {

    OrderSelect(Ticket, SELECT_BY_TICKET);

  

    if (OrderType() == OP_BUY)

    {

      OrderClose(Ticket, OrderLots(), Bid, 0);

      Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 0, 0, 0);

    }

    else  // (OrderType() == OP_SELL)

    {

      OrderClose(Ticket, OrderLots(), Ask, 0);

      Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 0, 0, 0);

    }

  }

  

  return(Ticket);

}


void System()

{

  static int Ticket = 0;

  static int NewTime = 0;

  

  if (NewTime < 0)

    return;

    

  if (Time[0] < NewTime)

    return;


  Ticket = ReverseOrder(Ticket);

  

  NewTime = GetTimeTrade();

  

  if (NewTime < 0)

    CloseOrder(Ticket);

}


void start()

{

  if (!MainError)

    return;


  System();

    

  return;

 
egor_smf:

Тестирую советник всё работает и есть профит!! А на Демо счёте сразу идёт в лосс!!!

может гдето есть ошибка!?? подскажите!!!

 

#define MAINSEEK 148

#define BARSIZE 44  // LONG_VALUE + 5 * DOUBLE_VALUE

 int Pips = 50;

 double Lots = 0.01;

int handle;

bool MainError;

int GetTime( int Pos )

{

  int PosTime;

  

  FileSeek(handle, MAINSEEK + Pos, SEEK_SET);

  PosTime = FileReadInteger(handle);

  return(PosTime);

}

bool FindTimePlace( int SearchTime )

{

  int LeftTime, RightTime, PosTime;

  int Left, Right, Pos;

  

  Left = 0;

  Right = FileSize(handle) - MAINSEEK - BARSIZE;

  

  LeftTime = GetTime(Left);

  RightTime = GetTime(Right);

  

  while ((LeftTime < SearchTime) && (SearchTime < RightTime))

  {    

    Pos = (Left + Right) / 2;

    Pos -= Pos % BARSIZE;

    

    if (Pos == Left)

      break;

    

    PosTime = GetTime(Pos);

    

    if (SearchTime >= PosTime)

    {

      Left = Pos;

      LeftTime = GetTime(Left);

    }

    else // if (SearchTime < PosTime)

    {

      Right = Pos;

      RightTime = GetTime(Right);

    }

  }

  

  if (SearchTime <= RightTime)

  {

    FileSeek(handle, Left + MAINSEEK, SEEK_SET);

    return(TRUE);

  }

  else

    return(FALSE);

}

void init()

{

  handle = FileOpenHistory(Symbol() + Period() + ".hst", FILE_BIN|FILE_READ);

  

  if (handle > 0)

    MainError = TRUE;

  else

  {

    MainError = FALSE;

    

    return;

  }

  MainError = FindTimePlace(Time[0]);

  

  if (!MainError)

    FileClose(handle);

    

  return;

}

void deinit()

{

  if (MainError)

    FileClose(handle);

  

  return;

}

bool GetPrices( int& PriceTime, int& PriceLow, int& PriceHigh)

{

  PriceTime = FileReadInteger(handle);

  FileSeek(handle, DOUBLE_VALUE, SEEK_CUR);

  PriceLow = FileReadDouble(handle) / Point + 0.01;

  PriceHigh = FileReadDouble(handle) / Point + 0.01;

  FileSeek(handle, 2 * DOUBLE_VALUE, SEEK_CUR);

  if (FileTell(handle) + BARSIZE <= FileSize(handle))

    return(TRUE);

  else

    return(FALSE);

}

int GetTimeTrade()

{

  static bool FlagUP = TRUE;

  static int Min = 999999;

  static int Max = 0;

  static int NTime;

  int ResTime;

  

  int PriceTime, PriceLow, PriceHigh;

    

  while (TRUE)

  {

    if (!GetPrices(PriceTime, PriceLow, PriceHigh))

      return(-1);

    if (FlagUP)

    {

      if (PriceHigh > Max)

      {

        Max = PriceHigh;

        NTime = PriceTime;

      }

      else if (Max - PriceLow >= Pips)

      {

        FlagUP = FALSE;

        Min = PriceLow;

        

        break;

      }

    }

    else // (FlagUP == FALSE)

    {

      if (PriceLow < Min)

      {

        Min = PriceLow;

        NTime = PriceTime;

      }

      else if (PriceHigh - Min >= Pips)

      {

        FlagUP = TRUE;

        Max = PriceHigh;

        

        break;

      }

    }

  }

  

  ResTime = NTime;

  NTime = PriceTime;

  return(ResTime);

}

void CloseOrder( int Ticket )

{

  OrderSelect(Ticket, SELECT_BY_TICKET);

  

  if (OrderType() == OP_BUY)

    OrderClose(Ticket, OrderLots(), Bid, 0);

  else  // (OrderType() == OP_SELL)

    OrderClose(Ticket, OrderLots(), Ask, 0);

  return;  

}

int ReverseOrder( int Ticket)

{

  if (Ticket == 0)

    Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 0, 0, 0);

  else

  {

    OrderSelect(Ticket, SELECT_BY_TICKET);

  

    if (OrderType() == OP_BUY)

    {

      OrderClose(Ticket, OrderLots(), Bid, 0);

      Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 0, 0, 0);

    }

    else  // (OrderType() == OP_SELL)

    {

      OrderClose(Ticket, OrderLots(), Ask, 0);

      Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 0, 0, 0);

    }

  }

  

  return(Ticket);

}

void System()

{

  static int Ticket = 0;

  static int NewTime = 0;

  

  if (NewTime < 0)

    return;

    

  if (Time[0] < NewTime)

    return;

  Ticket = ReverseOrder(Ticket);

  

  NewTime = GetTimeTrade();

  

  if (NewTime < 0)

    CloseOrder(Ticket);

}

void start()

{

  if (!MainError)

    return;

  System();

    

  return;

Смотрите в журнале, логах или звоните с претензиями на Демо! И ещё, тестер пользуется прошлыми котировками, демо настоящими, переходящими в прошлое. Отличие есть?!
 
2013.02.28 19:48:06 '184472793': order was opened : #120451086 sell 0.10 EURUSD at 1.3089 sl: 0.0000 tp: 0.0000
2013.02.28 19:48:05 '184472793': request in process
2013.02.28 19:48:05 '184472793': request was accepted by server
2013.02.28 19:48:04 '184472793': instant order sell 0.10 EURUSD at 1.3089 sl: 0.0000 tp: 0.0000
2013.02.28 19:48:04 '184472793': order #120451069 buy 0.10 EURUSD at 1.3092 sl: 0.0000 tp: 0.0000 closed at price 1.3089
2013.02.28 19:48:03 '184472793': request in process
2013.02.28 19:48:03 '184472793': request was accepted by server
2013.02.28 19:48:03 '184472793': close order #120451069 buy 0.10 EURUSD at 1.3092 sl: 0.0000 tp: 0.0000 at price 1.3089
2013.02.28 19:47:51 '184472793': order was opened : #120451069 buy 0.10 EURUSD at 1.3092 sl: 0.0000 tp: 0.0000
2013.02.28 19:47:50 '184472793': request in process
2013.02.28 19:47:50 '184472793': request was accepted by server
2013.02.28 19:47:50 '184472793': instant order buy 0.10 EURUSD at 1.3092 sl: 0.0000 tp: 0.0000
2013.02.28 19:29:46 '184472793': order #120448972 buy 0.10 EURUSD at 1.3081 sl: 0.0000 tp: 0.0000 closed at price 1.3077
2013.02.28 19:29:45 '184472793': request in process
2013.02.28 19:29:45 '184472793': request was accepted by server
2013.02.28 19:29:44 '184472793': close order #120448972 buy 0.10 EURUSD at 1.3081 sl: 0.0000 tp: 0.0000 at price 1.3077
2013.02.28 19:29:15 '184472793': previous successful authorization performed from 95.215.116.160
2013.02.28 19:29:15 '184472793': login
2013.02.28 19:29:13 '184472793': login
2013.02.28 19:29:11 Expert Money Sistem V EURUSD,H1: loaded successfully

2013.02.28 19:29:10 MetaTrader - E-Global TFG build 478 started (E-Global Trade and Finance Group,

 

Вот это пишет
 
https://www.mql5.com/ru/code/9234 внимательно прочтите описание
 
хм...ясно спасиб!!
Причина обращения: