Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi time frame decision with action only at close of bar

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

    Multi time frame decision with action only at close of bar

    I'm trying to design a strategy that compares price on a 1min time frame with an EMA on a 5 min time frame on a tick by tick basis. This decision will be acted upon only on the close of the 1 min candle. OnBarClose() and IsOnFirstTickOfBar() both are having method problems. What am I missing that my years of FORTRAN programming as a kid are not telling me?
    Here is some of the problematic code:

    protected override void OnBarUpdate()
    {

    if (CurrentBars[0] < 10)
    return;

    double fiveMinEma = EMA(BarsArray[2],21)[0];

    if (Close[0] < fiveMinEma && Close[1] >= fiveMinEma)
    {
    placeLong = true;
    }

    if (Close[0] > fiveMinEma && Close[1]<= fiveMinEma)
    {
    placeShort=true;
    }


    If (IsFirstTickOfBar);
    {
    if (placeLong())
    {
    if (!IsOrderActive())
    {
    orderEntryPrice = High[1] + 1*TickSize;

    // Place the limit order
    EnterLongLimit(DefaultQuantity,orderEntryPrice, "Long Entry​");

    getting error at IsFirstTickOfBar line

    #2
    Hello BrJessey,

    Thank you for your post.

    What is the error message you are receiving? One thing I notice is that placeLong seems to be a bool, and you have the following condition:

    if (placeLong())

    The extra set of parenthesis seems to imply something like placeLong is a method rather than a bool. You likely need to remove the () at the end of placeLong to evaluate your condition based on this variable as a type of bool.

    Please let me know if I may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    134 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    118 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X