Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MTF Best Practice?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    MTF Best Practice?

    Hi Ninja Team,

    Is there a best practice for using BarsInProgress vs. BarsArray in a Strategy? For example, what is the difference between this:

    Code:
    [COLOR=blue]if[/COLOR] (EMA(BarsArray[0], eMAFastLength)[0] > EMA(BarsArray[0], eMASlowLength)[0]) baseTFLongOK = [COLOR=blue]true[/COLOR];
    [COLOR=blue]else[/COLOR] baseTFLongOK   = [COLOR=blue]false[/COLOR];
     
    [COLOR=blue]if[/COLOR] (EMA(BarsArray[0], eMAFastLength)[0] < EMA(BarsArray[0], eMASlowLength)[0]) baseTFShortOK = [COLOR=blue]true[/COLOR];
    [COLOR=blue]else[/COLOR] baseTFShortOK  = [COLOR=blue]false[/COLOR];
    and this:

    Code:
    [COLOR=blue]if[/COLOR] (BarsInProgress == 0)
                {
                    [COLOR=blue]if[/COLOR] (EMA(eMAFastLength)[0] > EMA(eMASlowLength)[0]) baseTFLongOK = [COLOR=blue]true[/COLOR];
                    [COLOR=blue]else[/COLOR] baseTFLongOK = [COLOR=blue]false[/COLOR];
     
                    [COLOR=blue]if[/COLOR] (EMA(eMAFastLength)[0] < EMA(eMASlowLength)[0]) baseTFShortOK = [COLOR=blue]true[/COLOR];
                    [COLOR=blue]else[/COLOR] baseTFShortOK = [COLOR=blue]false[/COLOR];
                }
    Is there a use case scenario where one is prefered over the other?

    Thanks.

    #2
    MXASJ, BarsInProgress is used to check with Bars object calls the OnBarUpdate(), while BarsArray just give you access to the dataseries values of the added objects (without an event based focus / context).
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rayyyu12, Today, 05:38 PM
    0 responses
    12 views
    0 likes
    Last Post rayyyu12  
    Started by xepher101, Yesterday, 12:19 PM
    2 responses
    30 views
    0 likes
    Last Post xepher101  
    Started by thumper57, Today, 04:30 PM
    0 responses
    8 views
    0 likes
    Last Post thumper57  
    Started by OllieFeraher, 05-09-2024, 11:14 AM
    5 responses
    16 views
    0 likes
    Last Post MisterTee  
    Started by jackiegils, Yesterday, 11:05 PM
    1 response
    11 views
    0 likes
    Last Post marcus2300  
    Working...
    X