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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    64 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    139 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X