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

Re plotting

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

    Re plotting

    AddPlot(new Stroke(brushecolor, linestyle, LineThickness), PlotStyle.Bar, "MyPlot");


    is there a way to replot. for example

    MyPlot[5] = 10;

    Can I go to MyPlot[5] = - 10

    I have tried to loop through

    ie

    for(int x = 0;, x< CurrentBar; x++)
    MyPlot[x] = -10;

    I keep on getting Errors

    even if i try for(int x = 0;, x< CurrentBar-2; x++)

    i get the same results

    I event tried a time loop

    for example

    Time[0] was the beginning of the chart
    and Time[5] was out of the chart going farther back in time than the chart itself.

    is it because it is the weekend and no live data is running?

    #2
    Hello, thanks for your note.

    I was able to replot with this test:

    Code:
    protected override void OnBarUpdate()
            {
                if(State == State.Historical)
                    return;
    
                Value[0] = 0;
    
                counter++;
    
                if(counter > 4)
                {
                    for(int i = 4; i >= 0; i--)
                    {
                        Value[i] = 1;
                    }
                }
            }
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      I think it is not in on bar update. I found the data I want to change. All I want to do is invert the data so if it is a -5 i want to change it to a 5 etc.

      this is what I have done so far I can not use onBarUpdate so I used on Render

      protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
      {

      if(bIsInverted == true || bIsNotInverted == true)
      {

      bIsInverted = false;
      bIsNotInverted = false;


      // for(int x = 0; x< Range1.Count-5; x++) //THIS AREA WILL CAUSE AN ERROR
      // Range1[x] = -1*Range1[x];
      Print(Range1.Count);
      ////////////// for(int x = 0; x< Range1.Count-20; x++)
      ////////////// Print(Range1[x]);
      ///





      //this areal works for retrieval of the data using GetValueAt(x), BUT now how do I set the value at this location
      for(int x = 0; x< Range1.Count ; x++)
      {
      Print(Range1.GetValueAt(x));
      Print(x);
      }

      }

      // custom render logic
      }



      I think I have to use this

      // First, synchronize the index value used in via Series[barsAgo]
      // to the NinjaScriptBase.CurrentBar being currently being processed in OnBarUpdate
      TriggerCustomEvent(o =>
      {
      // For debugging, check the previous value
      Print("Before value which was set in OnBarUpdate(): " + SomeVolumeData[20]);

      SomeVolumeData[20] = 5; // set to our new custom value

      // For debugging, check the updated value
      Print("After value which was updated later in OnRender(): " + SomeVolumeData[20]);
      }, null);


      But how do I create and call a TriggerCustomEvent??????

      Comment


        #4
        Hi, thanks for your reply.

        Trigger custom even will let you access a series index and make sure it's in sync with OnBarUpdate. TriggerCustomEvent takes a delegate method; its the code you want to run synchronously with OnBarUpdate. See here for more info on delegate methods:

        A delegate in C# is a type that refers to methods with a parameter list and return type. Delegates are used to pass methods as arguments to other methods.


        TriggerCustomEvent(o => { // code added here will run as if its a method} ...

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by giulyko00, Today, 12:03 PM
        0 responses
        2 views
        0 likes
        Last Post giulyko00  
        Started by AttiM, 02-14-2024, 05:20 PM
        12 responses
        213 views
        0 likes
        Last Post DrakeiJosh  
        Started by cre8able, 02-11-2023, 05:43 PM
        3 responses
        238 views
        0 likes
        Last Post rhubear
        by rhubear
         
        Started by frslvr, 04-11-2024, 07:26 AM
        8 responses
        117 views
        1 like
        Last Post NinjaTrader_BrandonH  
        Started by stafe, 04-15-2024, 08:34 PM
        10 responses
        47 views
        0 likes
        Last Post stafe
        by stafe
         
        Working...
        X