Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling indicator on Range bars from a Strategy running on Unirenko Bars

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

    Calling indicator on Range bars from a Strategy running on Unirenko Bars

    Hello.

    I have a strategy that runs on Unirenko bars, I need to use the Momentum(EMA(ES-023,( x Range) EmaPeriod), MomentumPeriod) as a filter to enter/not enter orders. Both, the Momentum and EMA have to be calculated on Range Bars, and its value used by the strategy on the Unirenko chart.

    How can I do that from the strategy?



    Thanks,

    BobPerez
    Last edited by bobperez; 12-23-2022, 01:03 PM.

    #2
    Hello, thanks for writing in. The scripting library supports multi time frame scripts. The indicators can be set up to reference the secondary data series. We have a full guide on multi time frame scripts linked below. You should read the entire thing, but the important part about referencing indicator data is in the section "Using Bars Objects as Input to Indicator Methods​"



    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chris, I'll study the library.

      Comment


        #4
        Hi Chris, today is Dec 24th, so I don't expect an answer right away.

        I. MomentumSeries2
        I read all the help guides regarding my issue. I still don't know how to write the following command, so the momentum is calculated on the 2nd series also:

        EMA2 = EMA(BarsArray[1], 10)
        Mom2 = Momentum( EMA2, 3)

        I understand Momentum is taking its input from the EMA2 which is calculated on the 2nd series, but the momentum calculation is done on the primary series.

        I modified the SampleSecondarySeriesAsInputSeries developed by a Ninjatrader Support Member, to use it as a momentum indicator that makes calculations over the secondary series for both the EMA and Momentum indicators.

        Here it is: MomentumSeries2.zip

        Click image for larger version  Name:	MomentumSeries2.png Views:	0 Size:	114.7 KB ID:	1228877

        a. The chart on the left is a 4-Range chart. The chart on the right Is a Unirenko(T2O1R8) -Red/Green bars- chart with a 4Range second series - Black/white bars - chart added to it.

        b. I manually set up the yellow indicator on the Range chart. Momentum(EmaSecondarySeries, 2). Then I added the MomentumSeries2 (blue) indicator on top and the values match exactly.

        b. On the right chart, I added the MomentumSeries 2 to both the Unirenko and Range series on the chart.

        c. Please notice that the values on the range series (blue) match exactly the values on the left chart. The values on the Unirenko (Cyan) do not match the Range values in the same time slot.

        My strategy requires the values from the Range series, not those from the Unirenko series.

        I hope I made my point clear.

        II. Another doubt:

        The help guide states:
        Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to dynamically use an additional data series in an unsupported manner.​
        Does this mean that I cannot pass arguments such as the Range Period to the AddDataSeries?

        Code:
        if (State == State.Configure)
              {​
                        AddDataSeries("",Data.BarsPeriodType.Range, RangePeriod, Data.MarketDataType.Last);
        ​      }
        Happy Holiday
        Bob
        Attached Files
        Last edited by bobperez; 12-25-2022, 07:19 PM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,406 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        98 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        8 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        160 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        9 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X