API Timeframes constants: Difference between revisions

From NakedMarkets
Jump to navigation Jump to search
Created page with "=== Summary === The Timeframes constants are used to define the different timeframes.<br> === Definition === * PERIOD_CURRENT = 0,<br>* PERIOD_M1 = 1,<br>* PERIOD_M5 = 5,..."
 
No edit summary
 
(51 intermediate revisions by the same user not shown)
Line 1: Line 1:
=== Summary ===
=== Summary ===


The Timeframes constants are used to define the different timeframes.<br>
The Timeframes constants are used to define the different timeframes.
 
<br>It represents the Timeframe value in minutes.
 
<br>
 
=== Definition ===
=== Definition ===
 
{| class=wikitable cellpadding="10" style="border-style: solid; border-width: 2px"
* PERIOD_CURRENT = 0,<br>* PERIOD_M1 = 1,<br>* PERIOD_M5 = 5,<br>* PERIOD_M15 = 15,<br>* PERIOD_M30 = 30,<br>* PERIOD_H1 = 60,<br>* PERIOD_H4 = 240,<br>* PERIOD_D1 = 1440,<br>* PERIOD_W1 = 10080,<br>* PERIOD_MN1 = 43200
|-
! 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 :
<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 11: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;
           [...]
       }