Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

MultiTimeFrame Condition not working

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

    MultiTimeFrame Condition not working

    Hello,

    I am trying to create a condition in which it takes a price from a timeframe and submits an order once the price in a different timeframe crosses below. I think the code is good but it does not submit the order. (It does not annunciate any error)

    else if (State == State.Configure)
    {

    // Add a 45 minute Bars object to the strategy
    AddDataSeries(Data.BarsPeriodType.Minute, 1); // BarsArray[1]

    AddDataSeries(Data.BarsPeriodType.Second, 1); // BarsArray[2]
    }


    protected override void OnBarUpdate()
    {
    if ( TimeToTrade() && barNumberOfLongEntries == 0 && okToEnter )
    {
    if (LongSignal())
    {

    precioentrada2 = Close[0] - (Convert.ToInt32(Order02Offset) * TickSize); Print("precioentrada2 " +precioentrada2);

    CancelOpenEntries();
    CancelOpenOrders();
    barNumberOfLongEntries = CurrentBar;

    escalondos = 1;



    if (CrossBelow(Closes[2], (precioentrada2 - 5 * TickSize), 1) && CurrentBar < barNumberOfLongEntries + OrderActiveBars && escalondos > 0) //THIS IS THE PART NOT WORKING
    {
    EnterLongStopMarket(0, true, Convert.ToInt32(Order02LotSize), precioentrada2, "LE02"); Print("order 2 " +precioentrada2);
    escalondos = 0;
    }
    }
    }

    #2
    Hello Jorge.andres.o,

    To understand why the condition is not evaluating as true, print the values used in the condition to the output window.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.


    Print the time, print the value of Closes[2][1] and Closes[2][0], print all of the other values used in the condition.

    Save the output from the output window to a text file and provide this with your reply.
    I'll be happy to assist with analyzing the output.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chelsea. i will work on it

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by DJ888, 04-16-2024, 06:09 PM
      4 responses
      12 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by terofs, Today, 04:18 PM
      0 responses
      9 views
      0 likes
      Last Post terofs
      by terofs
       
      Started by nandhumca, Today, 03:41 PM
      0 responses
      7 views
      0 likes
      Last Post nandhumca  
      Started by The_Sec, Today, 03:37 PM
      0 responses
      3 views
      0 likes
      Last Post The_Sec
      by The_Sec
       
      Started by GwFutures1988, Today, 02:48 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Working...
      X