Wartość MA i czas .

O jezykach programowania w platformach i nie tylko.
dulf
Pasjonat
Pasjonat
Posty: 399
Rejestracja: 24 kwie 2010, 15:13

Wartość MA i czas .

Nieprzeczytany post autor: dulf »

Witam .
Chciałem wyznaczyć wartość MA o danej godzinie .
Pierwszy pomysł to wyznaczenie indeksu świecy :

Kod: Zaznacz cały

// niby kod
datetime t = "06:00" ; // + data  ?

    int count = 0 ;
    while(t != Time[count])
   {
          count++ ;

          if(count > 100)
          {
                  break ;
                 // error 
         }
   }
    double    ma = iMA(......., count /*shift*/ ) ;
Ale to na piechotę , jest jakaś funkcja która zwraca indeks świecy po podaniu argumentu datetime ?
Są jakieś inne metody ?
Nie spiesz się , zawsze zdążysz stracić .

Awatar użytkownika
Pierz Andrzej
Przyjaciel Forum
Przyjaciel Forum
Posty: 1200
Rejestracja: 02 lip 2006, 14:17

Nieprzeczytany post autor: Pierz Andrzej »

pewnie ze jest ;)

Kod: Zaznacz cały

int iBarShift( string symbol, int timeframe, datetime time, bool exact=false) 
Search for bar by open time. The function returns bar shift with the open time specified. If the bar having the specified open time is missing, the function will return -1 or the nearest bar shift depending on the exact.

Parameters:
symbol   -   Symbol the data of which should be used to calculate indicator. NULL means the current symbol. 
timeframe   -   Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe. 
time   -   value to find (bar's open time). 
exact   -   Return mode when bar not found. false - iBarShift returns nearest. true - iBarShift returns -1. 

Sample:
  datetime some_time=D'2004.03.21 12:00';
  int      shift=iBarShift("EUROUSD",PERIOD_M1,some_time);
  Print("shift of bar with open time ",TimeToStr(some_time)," is ",shift);

 
pozdrawiam
Andrzej Pierz
z poważaniem
Andrzej Pierz
FOREX-SERVICE

dulf
Pasjonat
Pasjonat
Posty: 399
Rejestracja: 24 kwie 2010, 15:13

Nieprzeczytany post autor: dulf »

Dziękuję bardzo , o to mi chodziło . :)
Nie spiesz się , zawsze zdążysz stracić .

ODPOWIEDZ