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

Signal on EOD RTH and enter trade in ETH

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

    Signal on EOD RTH and enter trade in ETH

    Could someone provide an example of how I can calculate signals on close of daily timeframe and execute a trade in the time after the RTH close?

    #2
    Hello RandyT,

    Thanks for your question.

    This would involve writing a multi series NinjaScript. Our Multi Time Frame and Instruments documentation provides a complete walk through for creating multi series NinjaScripts, and I would highly recommend referencing it as you develop this strategy.

    For a rough demonstration on how this could be set up, please consider the following:
    Code:
    private SMA mySMA;
    protected override void OnStateChange()
    {
    	if (State == State.SetDefaults)
    	{
    		...
    	}
    	else if (State == State.Configure)
    	{
    		AddDataSeries("AAPL", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, "US Equities RTH"); 
    	}
    	else if (State == State.DataLoaded)
    	{
    		mySMA = SMA(BarsArray[1], 14); // Use BarsArray[1] to reference the first data series that is added by the NinjaScript
    	}
    }
    
    protected override void OnBarUpdate()
    {
    	if (BarsInProgress == 0)
    	{
    		// Calculate off the primary data series here
    		if(Close[0] > mySMA[0]); // Checks if the last seen Close price for the Primary data series is greater than the last value of the SMA on the secondary series.
    			EnterLong();
    		if(Time[0] > Times[1][0]) // Checks if the Timestamp of the current iterating bar is greater than the timestamp of the last bar on the secondary series.
    			EnterLong();
    	}
    	else if (BarsInProgress == 1)
    	{
    		// Calculate off the added data series here.
    	}
    }
    A 1440 minute data series is added with the RTH trading hours template. We will need to add our daily RTH series this way because regular daily bars will be in ETH format. Calculations for the daily RTH series would be done in BarsInProgress 1 since this is the first data series added by the script. BarsInProgress 0 will be used for calculations on the primary data series that the script is applied to. TimeSeries and PriceSeries objects can be referenced for data series other than the current data series that is iterating by using the plural reference. I.E. Times[1][0] for the secondary data series.

    I'll include publicly available documentation on Multi Series NinjaScripts, and I will include a link to some example strategies that demonstrate time filters and entering on different time frames.

    Multi Time Frame and Instruments (Important Read!) - https://ninjatrader.com/support/help...nstruments.htm

    Using a Time Filter to limit trading hours - https://ninjatrader.com/support/help...to_limit_t.htm

    Entering on a different time frame - https://ninjatrader.com/support/help..._frame_and.htm

    Please let us know if you have any additional questions.
    Last edited by NinjaTrader_Jim; 07-25-2018, 08:27 AM.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks Jim, that should get me well down the path.

      Question regarding the AddDataSeries() call.

      Code:
      AddDataSeries("AAPL", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, "US Equities RTH");
      I'm dealing with Futures contracts in this strategy. Is there another way to do this without the reference to the symbol name since that will change for me? Or a way to refer to a continuous contract? I'm not seeing a way to refer to the Timeframe string without also including a symbol name.

      Comment


        #4
        Hello RandyT,

        Yes, you could use a continuous contract symbol if your data provider supports continuous contracts. You could also pass null as the instrument name and the primary data series will be used to define the instrument.

        Please let us know if there is anything else we could do to help.
        JimNinjaTrader Customer Service

        Comment


          #5
          I use Continuum. Does it support a continuous contract symbol and if so, what is it? I've asked platform support that question and have not gotten an answer.

          Comment


            #6
            Hello RandyT,

            Real-Time data is not provided from CQG/Continuum for Continuous Contracts. NinjaTrader 7 would synthetically create a Continuous Contract. This was left out as NinjaTrader 8 will offer the same behavior using the front month and the default Merge Policy of MergeBackAdjusted.

            Substituting null for the Instrument Name will use the symbol of the primary data series for the Instrument Name. For example:
            Code:
            AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, "US Equities RTH");
            Continuous Contracts are noted as ES ##-##. I've also included information on NinjaTrader's merge policies for further reading.

            Merge Policy - https://ninjatrader.com/support/help...rge_policy.htm
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Rapine Heihei, 04-23-2024, 07:51 PM
            2 responses
            30 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by Shansen, 08-30-2019, 10:18 PM
            24 responses
            943 views
            0 likes
            Last Post spwizard  
            Started by Max238, Today, 01:28 AM
            0 responses
            9 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by rocketman7, Today, 01:00 AM
            0 responses
            7 views
            0 likes
            Last Post rocketman7  
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            28 views
            0 likes
            Last Post wzgy0920  
            Working...
            X