Strategic foresight systems - page 39

 
-Aleksey-:
Clarifying question: are the conditional indicator values needed for all candlesticks on the chart at any given time, or for a certain number of recent candlesticks?
Preferably, for the last ones set by some window.
 

Here is a piece of my working code. Never had a problem with closing (tweaked it a bit)

int i, total = OrdersTotal(), slippage = 50;

bool Ans;
for (i = total-1; i >=0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if(OrderType()==OP_BUY) {
Print("CLOSE BUY");
Ans = false;
while(Ans==false) {
Ans = OrderClose(OrderTicket(),OrderLots(),Bid, slippage, DodgerBlue);
Sleep(1000);
RefreshRates();
}
}
if(OrderType() == OP_SELL) {
Print("CLOSE SALE");
Ans = false;
while(Ans==false) {
Ans = OrderClose(OrderTicket(),OrderLots(),Ask, slippage, Orange);
Sleep(1000);
RefreshRates();
}
}
}
}

 
rulabs:

Here's a piece of my working code. Never had a problem with closing (tweaked it a bit)

...

Thanks so much!!! I'll give it a try.
 
Farnsworth:
Thank you so much!!! I'll give it a try.
Thank you for the thread. Ask if there is anything you need.
 
Farnsworth:
preferably for the latter, set by some kind of window.

I have it implemented like this:

//---начало блока глобальных переменных---------------
int GLOBAL_DATA_LIMIT;
bool first_run=true;
//---конец блока глобальных переменных
//++++++++++++++++++++++++++++++++++++
//---начало блока инициализации
void OnInit()
   {
      GLOBAL_DATA_LIMIT= расчет числа данных(длины окна данных), необходимых для расчета окна условного индикатора заданной длины
      ....инициализация
  }
//---конец блока инициализации индикатора
//+++++++++++++++++++++++++++++++++++++++
//---начало блока обновления индикатора--
int OnCalculate (
                  const int rates_total,      // current size of the timeseries array
                  const int prev_calculated,  // size of the timeseries array got by reurn value the last time
                  const datetime& time[],     // Time
                  const double& open[],       // Open
                  const double& high[],       // High
                  const double& low[],        // Low
                  const double& close[],      // Close
                  const long& tick_volume[],  // Tick Volume
                  const long& volume[],       // Real Volume
                  const int& spread[]         // Spread
                )
   {
      if(rates_total<0)
      {
         printf("На графике отсутствуют исторические данные");
         return(0);
      }
      if(rates_total<GLOBAL_DATA_LIMIT)
      {
         printf("Недостаточно исторических данных, необходимое количество: "+string(GLOBAL_DATA_LIMIT));
         return(0);
      }
      if(prev_calculated==0) // срабатывает при первом запуске, или когда история поменялась
      {
         if (first_run==true) первый расчет при запуске - в момент первого тика после инициализации
         *{
            ArrayCopy(cur_price_array, close, 0, (rates_total-1)-GLOBAL_DATA_LIMIT, GLOBAL_DATA_LIMIT); - копируем в массив необходимое количество значений цены
            ...
            Со скопированным массивом проводим расчет
            Отображаем результат
            ...   
            first_run=false;
         *}
         else расчет на каждом тике
         {
         в это место вставить код *(без first_run=false;), если считать на каждом тике. Если считать не на каждом тике, а по новому бару, то вставить * в функцию isNewBar
         }         
      }
      
      if(isNewBar(_Period)) расчет на каждом баре
      {
          *{
                      ArrayCopy(cur_price_array, close, 0, (rates_total-1)-GLOBAL_DATA_LIMIT, GLOBAL_DATA_LIMIT); - копируем в массив необходимое количество значений цены
                      ...
                      Со скопированным массивом проводим расчет
                      Отображаем результат
                      ...
         *}
      }
      return(rates_total);
   } 
//---конец блока обновления индикатора---
 

This is a scheme for calculating one or more n indicator values based on copied m(GLOBAL_DATA_LIMIT) price values on each bar or tick.

If the past values of the calculated value window do not change, then in the calculation(inside) you can proceed as follows

-calculate only the new value(one);

-shift the calculated value window (array with results) to the left by 1 index;

-write a new value in the last index of the results array.


I do not know if it is clear. The code is in MQL5, I don't know 4, but it should be similar I guess.

 
-Aleksey-:

...

Thanks, I'll look into it.
 
Risk:

Admins, absolute power leads to dictatorship. Even our politically correct timbo could not stand this marasmus and went somewhere :)

There must be an opposition that at least sometimes puts everything in its place, but here it is unclear who seriously defines sections of mathematics, while they cannot close the order without the help of schoolchildren. What will happen tomorrow?

If you are the opposition, I am the pope. You don't give the author a word to say and there is zero content in your posts. There is real opposition and it opposes constructively. And trolls cannot be the opposition, they are topic destroyers pure and simple.
You are presented for another ban.
 
rulabs:
Thank you for the thread. Please do ask if there is anything you need.
While arguing with a colleague, I almost missed a heartfelt post. Everyone on this site contributes something different, so I can't take "thank you" completely - if a thread turns out to be interesting, it's thanks to all its participants :o)
 

To keep the thread alive:)

On Monday at 11:15 am Moscow time, without any analysis, I opened pairs observed in MT5 (I should get used to it).

I didn't open EURUSD and GBPUSD because they were flat. I'll just hold it till Friday, though, I should properly look and possibly correct it every day.

If somebody is interested, you may watch it.

Login: 729566

Investor: iuj2seh


Reason: