Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multy Instrument Strategy: deals are not opening

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

    Multy Instrument Strategy: deals are not opening

    Hello. I made simple multy-instrument strategy ( $AUDJPY, $CHFJPY, $EURJPY, $GBPJPY - 60 Min).

    It must unconditional open positions on all instruments at 02:00 and close all at 22:00 every day.

    I backtest it on 04.06.2010 - 20.08.2010 an get only 1 deal.

    My history is OK - It clear on chart screenshot.

    Help me, please, to let this strategy work correct.

    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// GBPJPY only
    /// </summary>
    [Description("USDJPY only")]
    public class sMultuCurrencySimple : Strategy
    {
    #region Variables
    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {
    Add("$AUDJPY", BarsPeriod.Id, BarsPeriods[0].Value);
    Add("$CHFJPY", BarsPeriod.Id, BarsPeriods[0].Value);
    Add("$EURJPY", BarsPeriod.Id, BarsPeriods[0].Value);
    Add("$GBPJPY", BarsPeriod.Id, BarsPeriods[0].Value);

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // ------------------ Open positions -----------------------------------------------------------
    //
    if (BarsInProgress == 1 || Time[0].Hour == 2 ) { EnterLong(DefaultQuantity, ""); return; }
    if (BarsInProgress == 2 || Time[0].Hour == 2 ) { EnterLong(DefaultQuantity, ""); return; }
    if (BarsInProgress == 3 || Time[0].Hour == 2 ) { EnterLong(DefaultQuantity, ""); return; }
    if (BarsInProgress == 4 || Time[0].Hour == 2 ) { EnterLong(DefaultQuantity, ""); return; }
    if ( Time[0].Hour == 2 ) EnterLong(DefaultQuantity, "");
    // ---------------------------------------------------------------------------------------------

    // ------------------------------------ Close positions---------------------
    //
    if ( Time[0].Hour == 22)
    {
    ExitLong( "", ""); ExitShort( "", "");
    ExitLong(1, "", ""); ExitShort(1, DefaultQuantity, "", "");
    ExitLong(2, "", ""); ExitShort(2, DefaultQuantity, "", "");
    ExitLong(3, "", ""); ExitShort(3, DefaultQuantity, "", "");
    ExitLong(4, "", ""); ExitShort(4, DefaultQuantity, "", "");
    }
    // --------------------------------------------------------------------------
    }

    #region Properties
    #endregion
    }
    }
    Attached Files
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    Hello fx.practic,

    All your orders are submitted to the primary series. You will need to use the advanced overload that supports entering on a specific BarsInProgress.

    EnterLong(int barsInProgressIndex, int quantity,string signalName)

    You also are defining your conditions with ||. Most likely you will want to use && and also refer to the Time object of the specific series you want to enter on.

    This is accessed with Times

    Example submitting on second series.

    if (BarsInProgress == 1 && Times[1][0].Hour == 2)
    EnterLong(1, DefaultQuantity, "");

    Your exit statements also need to use the advanced overload.
    ExitLong(int barsInProgressIndex, int quantity,string signalName,string fromEntrySignal)
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      It's work now!

      Everything works now.

      If "Entries Per Dials" = 1, deals are opening only on primary instrument.
      If "Entries Per Dials" = 5, deals are opening on all 5 instruments.

      Thank You very march!

      P.S. About "&&" and "||" - may be, I need to sleep more
      Attached Files
      fx.practic
      NinjaTrader Ecosystem Vendor - fx.practic

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      633 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      567 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X