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 cmoran13, Yesterday, 01:02 PM
      0 responses
      28 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      18 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      160 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      95 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      148 views
      2 likes
      Last Post CaptainJack  
      Working...
      X