Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Syntax for multi time frame rising MACD

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

    Syntax for multi time frame rising MACD

    I want to check a condition in which the MACD(12,26,9) is rising on both the 1 hour and 4 hour charts. I have added the following to the Initialize() block
    // Add a 60 minute Bars object to the strategy
    Add(PeriodType.Minute, 60); // BarsArray[1]
    // Add a 240 minute Bars object to the strategy
    Add(PeriodType.Minute, 240); // BarsArray[2]
    Now in the OnBarUpdate() section
    // Checks if the MACD is rising on both the 1hr and 4hr charts
    if (Rising(MACD(12,26,9)(BarsArray[1]))) && (Rising(MACD(12,26,9)(BarsArray[2])))
    {
    do something;
    }
    I am getting a compilation error. What is the right syntax to use? Thanks in advance.

    #2
    Please try this winja -

    Code:
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] (Rising(MACD(BarsArray[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]], [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]12[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]26[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]9[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2])) && Rising(MACD(BarsArray[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]], [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]12[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]26[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]9[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2])))
    {
    Do something[/SIZE][/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]
    }
    [/SIZE][/FONT][/SIZE][/FONT]



    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    656 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    371 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    574 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    579 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X