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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    55 views
    0 likes
    Last Post CarlTrading  
    Working...
    X