• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddDataSeries not working as I expect.

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

    AddDataSeries not working as I expect.

    Hello all,

    The indicator I programed works perfect with the the default dataseies instrument. Based on the default instrument, Volume variable works as a trigger to make all the extra calculations.

    The problem I have is if I add an extra instrument dataseries to calculate only the Volume variable, reamaining the default instrument for the extra calculations.

    I added in bold this lines to the code:

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    ...
    ...
    ...

    else if (State == State.Configure)
    {
    AddDataSeries("NAME OF ADDITIONAL INSTRUMENT", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    }

    else if (State == State.Historical)
    {
    if (Calculate == Calculate.OnPriceChange)
    {
    Draw.TextFixed(this, "NinjaScriptInfo", string.Format(Custom.Resource.NinjaScriptOnPriceCh angeError, Name), TextPosition.BottomRight);
    Log(string.Format(Custom.Resource.NinjaScriptOnPri ceChangeError, Name), LogLevel.Error);
    }
    }
    }

    protected override void OnBarUpdate()
    {
    //this is the default value for Vlolume calculation with default instrument
    Value[0] = Instrument.MasterInstrument.InstrumentType == InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume((long)Volume[0]) : Volume[0];


    In the example below in the condition if (Value[1] >= VolRelev1) // "Value[1] is the "defalult instrument" volume and if condition is true then wil draw a fibo based on "defalult instrument" data.


    if (Value[1] >= VolRelev1)
    {
    Draw.FibonacciRetracements(this, "FiboUp", true, 10, Low[Math.Max(0, Swing(SwingVRUp).SwingLowBar(0, 1, 100))], -10, High[1]);

    }



    But the problen is in the exmple below. If the condition if (Volumes[1][1] >= VolRelev1) // Volumes[1][1] is the "added instrument" volume and I expect that if condition is true then will draw a fibo based in "default intrument" data. But it is drawing the fibo based in the added instrument too, and I do not want that.


    if (Volumes[1][1] >= VolRelev1)
    {
    Draw.FibonacciRetracements(this, "FiboUp", true, 10, Low[Math.Max(0, Swing(SwingVRUp).SwingLowBar(0, 1, 100))], -10, High[1]);


    }



    Please could you help me?

    Kind regards,

    Marcos L.



    #2
    Hi Marcos; Thank you for your post.

    In this statement:

    Code:
    if (Volumes[1][1] >= VolRelev1)
    {
    Draw.FibonacciRetracements(this, "FiboUp", true, 10, Low[Math.Max(0, Swing(SwingVRUp).SwingLowBar(0, 1, 100))], -10, High[1]);
    }
    You reference the Volumes[][] array and properly target the secondary series, but the Low[] series used in the Draw statement could be either in the context of the primary series or the secondary series. Use the Lows[][] series to target your primary series when needed e.g. Lows[0][Math.Max(0, Swing(SwingVRUp).SwingLowBar(0, 1, 100))].

    To reference the correct series for the Swing indicator, use this override: Swing(ISeries<double> input, int strength) e.g. Swing(BarsArray[0], SwingVRUp)

    Please let me know if this does not resolve your inquiry.
    Last edited by NinjaTrader_ChrisL; 05-27-2019, 08:53 AM.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello ChrisL,

      Your solution worked perfect.

      Thank you for your assistance.

      Kind Regards,

      Marcos L.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by indy73, Today, 10:52 PM
      0 responses
      3 views
      0 likes
      Last Post indy73
      by indy73
       
      Started by martyn73, Today, 07:04 PM
      0 responses
      5 views
      0 likes
      Last Post martyn73  
      Started by sergey_z, Today, 02:56 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by samir, Today, 02:46 PM
      1 response
      20 views
      0 likes
      Last Post NinjaTrader_Kate  
      Started by neoikon, Today, 02:24 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Working...
      X