[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 284

 
hoz:
It doesn't matter. I'm returning an absolute value, modulo through MathAbs...


If you're looking for an input pointMathAbs() introduces a smudge. For me it should be specified from beginning to end, so it's clear when and with what tolerance!
 
borilunad:

If you are looking for input pointMathAbs() makes it smeared. To me it should be specified from beginning to end, so it's clear when and with what tolerance!


Corrected... None of the conditions are fulfilled anyway.

//+-------------------------------------------------------------------------------------+
//| Получение значений МА на указанном баре                                             |
//+-------------------------------------------------------------------------------------+
double GetMA(int index, int maPeriod)
{
   return (iMA(NULL, i_TF, maPeriod, 0, MODE_EMA, MODE_CLOSE, index));
}
//+-------------------------------------------------------------------------------------+
//| Имеет ли место отскок?                                                              |
//+-------------------------------------------------------------------------------------+
void IsRebound(int crossDir[], bool& returnSign[])
{
   for (int i = 0; i < 4; i++)
   {
      if (crossDir[i] == CROSS_NO)
         continue;

      returnSign[i] = false;
      double ema = GetMA(1, g_maPeriod[i]);

 //     VrPr (ND(MathAbs(ema - Ask)));
   //   VrPr (i_thresholdFromMa * pt);
      if (crossDir[i] == CROSS_UP)
      {
         if (ND(Ask - ema) <= i_thresholdFromMa * pt) // ..зазор между ценой покупки и машки, <= i_thresholdFromMa..
         {
         //   VrPr (ND(MathAbs(ema - Ask)) <= i_thresholdFromMa * pt);
            returnSign[i] = true;
            VrPr (" returnSign["+0+"]"+" = "+ returnSign[0]);
            VrPr (" returnSign["+1+"]"+" = "+ returnSign[1]);
            VrPr (" returnSign["+2+"]"+" = "+ returnSign[2]);
            VrPr (" returnSign["+3+"]"+" = "+ returnSign[3]);
         }
      }
      if (crossDir[i] == CROSS_DN)
      {
         if (ND(ema - Bid) <= i_thresholdFromMa * pt) // ..зазор между ценой продажи и машки, <= i_thresholdFromMa..
         {
            returnSign[i] = true;
            VrPr (" returnSign["+0+"]"+" = "+ returnSign[0]);
            VrPr (" returnSign["+1+"]"+" = "+ returnSign[1]);
            VrPr (" returnSign["+2+"]"+" = "+ returnSign[2]);
            VrPr (" returnSign["+3+"]"+" = "+ returnSign[3]);
         }
      }
   }
}

toreturnSign[i] = true; and consequently to theVrPr function(which is the function that outputs the data I monitor) is not used. Although, crossing down has already started. Here's a screenshot, you can see that arraycrossDir[] is filled as each fast machine crosses the slow one...

Notice that 2 wheels have crossed the thickest one, and 2 elements of the array have already assigned value 1. That means their value isCROSS_DN

Which means that the condition

 if (crossDir[i] == CROSS_DN)

and then...

 
borilunad:

If you are looking for an entry pointMathAbs() introduces fuzziness. I think it should be specified from beginning to end, so that it is clear when and with what tolerance!

Also with whom and why.
 
tara:

Who else and why.

Except visually it's easier to perceive without MathAbc() from habit, but... there is no difference. But we strayed from the topic. Are there any remarks on my code? After all, the question is still open...
 
I have no reservations about the code.
 
Then why is the condition not fulfilled? Any comment on the logic?
 

No.

 
Yep. It'll be better in the morning, hopefully something clears up tomorrow.
 

Good afternoon everyone!

I am testing USD/JPY in MT-4 from Alpari.

I have downloaded the USD/JPY 1-minute history

Note: After loading in archive of quotations of minute history at double click on "1 minute".

The list of one-minute quotes does not show up in the Quote Archive window of the Database for some reason.


1 hour TF.

All ticks

Period 01.01.2000. - 01.01.2013.

At the end of testing, the REPORTS tab shows a red bar and says that the modelling quality is 25%

I tested the same period with the same parameters ......but separately for each month

and for every month it shows green bar and 90% simulation quality

Then I tested the same period but split it into 2 equal parts 2000-2006 and 2006-2013.

For each part, the bar is green and the quality of simulation is 90%.


QUESTION

What should I do to make the quality of testing for a period of 13 years in general also was 90%?

Thank you

 

Right. I think I've finished. Here's the reworked tick collector with its packing them into second candles.

It was:

int start()
  {  
//----
if(flag == true)
  {
  if(tick.time.local == true)
    {
    time = TimeLocal();
    }
    else{
    time = TimeCurrent();
    }
  if(t < time)
    { 
         t = time; 
    }
    else{ 
         t ++;
    }   

  if(FileSeek(hand1e, fpos, SEEK_SET) == false)
           { 
           error = GetLastError();
           Print("out: error(",error,"): ",ErrorDescription(error));
           flag = false;
           return;
           }
           else{
           bid = MarketInfo(symbol, MODE_BID);
           ask = MarketInfo(symbol, MODE_ASK);
           
                FileWriteInteger(hand1e,    t,   LONG_VALUE);            
                FileWriteDouble (hand1e,  bid, DOUBLE_VALUE);          
                FileWriteDouble (hand1e,  bid, DOUBLE_VALUE);            
                FileWriteDouble (hand1e,  ask, DOUBLE_VALUE);    
                FileWriteDouble (hand1e,  ask, DOUBLE_VALUE);                            
                FileWriteDouble (hand1e, time, DOUBLE_VALUE);                   
      FileFlush       (hand1e);  

      fpos = FileTell (hand1e);

Became:

int i;//аналогично i=0
        while((TimeCurrent()-time)>1){//то заносим старые значения столько раз, сколько было пропущено секунд минус один
                if(FileSeek(hand1e, fpos, SEEK_SET) == false){//перемещаем указатель на новую позицию, которую мы запомнили в FileTell
                                error = GetLastError();//если ошибка
                                Print("out: error(",error,"): ",ErrorDescription(error));//записываем её в лог
                                flag = false;
                                return;//и выходим
                        }else{//выдумываем несуществующую свечу (т.к. тика в эту секунду не было)
                                time++;
                                FileWriteInteger(hand1e,  time,   LONG_VALUE);//TimeCurrent()
//выбор выдуманной свечи (секунда, при которой тика не было):
//прочерк на Close[]
/*
                                FileWriteDouble (hand1e,  ask[last.index], DOUBLE_VALUE);//Open[]
                                FileWriteDouble (hand1e,  ask[last.index], DOUBLE_VALUE);//High[]
                                FileWriteDouble (hand1e,  ask[last.index], DOUBLE_VALUE);//Low[]
                                FileWriteDouble (hand1e,  ask[last.index], DOUBLE_VALUE);//Close[]
                                FileWriteDouble (hand1e,  0, DOUBLE_VALUE);//Volume[]
*/
//свеча без теней
/*
                                FileWriteDouble (hand1e,  bid[0], DOUBLE_VALUE);//Open[]
                                FileWriteDouble (hand1e,  bid[0], DOUBLE_VALUE);//High[]
                                FileWriteDouble (hand1e,  ask[last.index], DOUBLE_VALUE);//Low[]
                                FileWriteDouble (hand1e,  ask[last.index], DOUBLE_VALUE);//Close[]
                                FileWriteDouble (hand1e,  last.index+1, DOUBLE_VALUE);//Volume[]
*/
//такая же свеча, как и была (не прочерк и не без теней)
                                FileWriteDouble (hand1e,  bid[0], DOUBLE_VALUE);//Open[]
                                FileWriteDouble (hand1e,  bid[ArrayMaximum(bid)], DOUBLE_VALUE);//High[]
                                FileWriteDouble (hand1e,  ask[ArrayMinimum(ask)], DOUBLE_VALUE);//Low[]
                                FileWriteDouble (hand1e,  ask[last.index], DOUBLE_VALUE);//Close[]
                                FileWriteDouble (hand1e,  last.index+1, DOUBLE_VALUE);//Volume[]
//конец выбора
                                FileFlush       (hand1e);
                                fpos = FileTell (hand1e);//запоминаем позицию записи в файле
                }
        }
ArrayResize(bid, 1);//урезаем и обнуляем использованные нмассивы
ArrayResize(ask, 1);
if(flag==true){
        if(tick.time.local==true){//если флаг работы с историей поднят
                        time = TimeLocal();//работаем с локальным временем
                        while(time==TimeLocal()){//пока секунда не прошла
                                bid[i]=MarketInfo(symbol, MODE_BID);//заносим в индикаторный массив данные тиков
                                ask[i]=MarketInfo(symbol, MODE_ASK);
                                i++;
                        }
                }else{//иначе
                        time = TimeCurrent();//работаем с временем сервера
                        while(time==TimeCurrent()){//пока секунда не прошла
                                bid[i]=MarketInfo(symbol, MODE_BID);//заносим в индикаторный массив данные тиков
                                ask[i]=MarketInfo(symbol, MODE_ASK);
                                i++;
                        }                       
        }
}
//Вышли из цикла, т.к. время изменилось. Заносим в файл:
if(FileSeek(hand1e, fpos, SEEK_SET) == false){//перемещаем указатель на новую позицию, которую мы запомнили в FileTell
                error = GetLastError();//если ошибка
                Print("out: error(",error,"): ",ErrorDescription(error));//записываем её в лог
                flag = false;
                return;//и выходим
        }else{
                int last.index=ArraySize(ask)-1;
                FileWriteInteger(hand1e,  time,   LONG_VALUE);//TimeCurrent()
                FileWriteDouble (hand1e,  bid[0], DOUBLE_VALUE);//Open[]
                FileWriteDouble (hand1e,  bid[ArrayMaximum(bid)], DOUBLE_VALUE);//High[]
                FileWriteDouble (hand1e,  ask[ArrayMinimum(ask)], DOUBLE_VALUE);//Low[]
                FileWriteDouble (hand1e,  ask[last.index], DOUBLE_VALUE);//Close[]
                FileWriteDouble (hand1e,  last.index+1, DOUBLE_VALUE);//Volume[]
                FileFlush       (hand1e);
                fpos = FileTell (hand1e);//запоминаем позицию записи в файле
}

Comments on the code.

1. Didn't make switch-case in virtual candlestick selection to save CPU time, instead commented out sections with selection (since selection is done for specific needs once before compilation).

2. On work with local time (off-line that is) not brought to mind. In the"while(time==TimeLocal()){//until one second has passed" loop, I suspect there must beMarketInfo in FileWriteDouble (sounds like the top of an idiot to me). If you tell me what would look more logical there, I will be grateful.

3. An author's construct

if(flag == true)
  {
  if(tick.time.local == true)
    {
    time = TimeLocal();
    }
    else{
    time = TimeCurrent();
    }

I've declared it at the very end of init().

4. At the beginning of init() dynamic arrays

   IndicatorBuffers(2);
   SetIndexBuffer(0, bid);
   SetIndexBuffer(1, ask);

instead of used variables.

5. For optimization, you can theoretically use WinAPI file functions and write to the history at once in block 44 bytes (length of MarketInfo structure or whatever it is in .hst).

6. Completely removed author's modeling of time for writing to the Time[] cell. For the same reason, in head while loop there is no check for TimeLocal(), only for TimeCurrent().

7. What else do you suggest to optimize the code?