Difference between revisions of "API Timeframes constants"

From NakedMarkets
Jump to navigation Jump to search
 
(43 intermediate revisions by the same user not shown)
Line 3: Line 3:
The Timeframes constants are used to define the different timeframes.
The Timeframes constants are used to define the different timeframes.
<br>It represents the Timeframe value in minutes.
<br>It represents the Timeframe value in minutes.
 
<br>
=== Definition ===
=== Definition ===
<br>
{| class=wikitable cellpadding="10" style="border-style: solid; border-width: 2px"
'''PERIOD_CURRENT''' : Current Timeframe (value = 0)
|-
<br>'''PERIOD_M1''' : Timeframe M1 (value = 1)
! Constant name !! Value !! Value in minutes
<br>'''PERIOD_M5''' : Timeframe M5 (value = 5)
|-
<br>'''PERIOD_M15''' : Timeframe M15 (value = 15)
| '''Timeframe.PERIOD_CURRENT''' || Current Timeframe ||  0
<br>'''PERIOD_M30''' : Timeframe M30 (value = 30)
|-
<br>'''PERIOD_H1''' : Timeframe H1 (value = 60)
| '''Timeframe.PERIOD_M1''' || Timeframe M1 || 1
<br>'''PERIOD_H4''' : Timeframe H4 (value = 240)
|-
<br>'''PERIOD_D1''' : Timeframe D1 (value = 1440)
| '''Timeframe.PERIOD_M5''' || Timeframe M5 || 5
<br>'''PERIOD_W1''' : Timeframe W1 (value = 10080)
|-
<br>'''PERIOD_MN1''' : Timeframe MN1 (value = 43200)
| '''Timeframe.PERIOD_M15''' || Timeframe M15 || 15
 
|-
 
| '''Timeframe.PERIOD_M30''' || Timeframe M30 || 30
{| class="wikitable"
! <translate><!--T:5--> Group</translate>
! <translate><!--T:6--> Functions</translate>
|-
|-
| <translate><!--T:7--> Construct an array, (with unique, sort, print options)</translate>
| '''Timeframe.PERIOD_H1''' || Timeframe H1 || 60
| <code>[[#arraydefine]]</code>
|-
|-
| <translate><!--T:8--> Extract information from an array</translate>
| '''Timeframe.PERIOD_H4''' || Timeframe H4 || 240
| <code>[[#arrayprint]]</code>, <code>[[#arrayindex]]</code>, <code>[[#arraysize]]</code>, <code>[[#arraysearch]]</code>, <code>[[#arraysearcharray]]</code>, <code>[[#arrayslice]]</code>
|-
|-
| <translate><!--T:9--> Alter an array</translate>
| '''Timeframe.PERIOD_D1''' || Timeframe D1 || 1440
| <code>[[#arrayreset]]</code>, <code>[[#arrayunique]]</code>, <code>[[#arraysort]]</code>
|-
|-
| <translate><!--T:10--> Interaction between several arrays</translate>
| '''Timeframe.PERIOD_W1''' || Timeframe W1 || 10080
| <code>[[#arraymerge]]</code>, <code>[[#arrayunion]]</code>, <code>[[#arrayintersect]]</code>, <code>[[#arraydiff]]</code>
|-
|-
| <translate><!--T:11--> In case <tvar name=1>{{ll|Extension:HashTables}}</tvar> is installed, for array/hash-table interaction</translate>
| '''Timeframe.PERIOD_MN1''' || Timeframe MN1 || 43200
| <code>{{ll|Extension:HashTables#hashtoarray|<nowiki>#</nowiki>hashtoarray}}</code>, <code>{{ll|Extension:HashTables#arraytohash|<nowiki>#</nowiki>arraytohash}}</code>
|}
|}
=== Examples ===
C# code snippet :
<code>
        public override void OnCalculate(int index)
        {
            // Avoid the use of Timeframe equal and higher than D1
            if (index != 0 || Period() >= (int)Timeframe.PERIOD_D1)
                return;
            [...]
        }
</code>

Latest revision as of 04:24, 5 January 2023

Summary

The Timeframes constants are used to define the different timeframes.
It represents the Timeframe value in minutes.

Definition

Constant name Value Value in minutes
Timeframe.PERIOD_CURRENT Current Timeframe 0
Timeframe.PERIOD_M1 Timeframe M1 1
Timeframe.PERIOD_M5 Timeframe M5 5
Timeframe.PERIOD_M15 Timeframe M15 15
Timeframe.PERIOD_M30 Timeframe M30 30
Timeframe.PERIOD_H1 Timeframe H1 60
Timeframe.PERIOD_H4 Timeframe H4 240
Timeframe.PERIOD_D1 Timeframe D1 1440
Timeframe.PERIOD_W1 Timeframe W1 10080
Timeframe.PERIOD_MN1 Timeframe MN1 43200

Examples

C# code snippet :

       public override void OnCalculate(int index)
       {
           // Avoid the use of Timeframe equal and higher than D1
           if (index != 0 || Period() >= (int)Timeframe.PERIOD_D1)
               return;
           [...]
       }