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

OF ninjascript issue

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

    OF ninjascript issue

    Dear NT8 Support,


    Background: Trying to use some OF methods but am confused why some methods working well others don't. The code (strategy code) is run on a Volumetric chart. Below is my simplified codes:


    protected override void OnBarUpdate()
    {
    double poc;
    long bv, av;
    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe ofBars = Bars.BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
    if (State == State.Realtime)
    {
    if (kbTest){
    kbTest=false;
    ofBars.Volumes[CurrentBar].GetMaximumVolume(null, out poc);
    Print("poc at "+poc.ToString());
    try{
    bv=ofBars.Volumes[CurrentBar].GetBidVolumeForPrice(Close[0]);
    av=ofBars.Volumes[CurrentBar].GetAskVolumeForPrice(Close[0]);
    Print(string.Format("bv={0} av={2}",bv,av));
    }
    catch(Exception e){
    Print(e.Message);
    }
    }
    }
    } //============ End of code

    The bool var kbTest is set via keyboard. So when I press my KB key, the print output I get is:


    poc at 2796.25
    Index (zero based) must be greater than or equal to zero and less than the size of the argument list.


    .. which means the GetMaximumVolume is working (poc value tally with the chart display) but why the other OF methods generating exception? In the error print above, what is the "argument list"?


    Pls help me overcome this issue. Thanks,
    Tiang

    #2
    Hello Tiang,

    Thanks for the post.

    This line is what is causing the error:

    PHP Code:
    Print(string.Format("bv={0} av={2}",bv,av)); 
    You will need to reference 0 and 1 for two formatting arguments.

    Please let us know if we may be of any further assistance.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chris for your fast help. I feel silly to miss such an obvious mistake...must be the stress from those losing trades.

      Comment


        #4
        Dear Chris L.
        the output of av=barsType.Volumes[CurrentBar].GetBidVolumeForPrice(Close[0]);
        always gives 0
        could you let me know why?
        Thanks in advance

        Comment


          #5
          Hello xg5463,

          Thank you for the post.

          Did you make sure to add a 1 tick series in State.Configure? I have attached an example that uses all of the volumetric bars methods. This indicator must run on a chart that has volumetric bars as its primary series. If your primary series is not a volumetric bar, you must use AddVolumetric:



          Please let me know if I can assist further.,
          Attached Files
          Chris L.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mestor, 03-10-2023, 01:50 AM
          16 responses
          388 views
          0 likes
          Last Post z.franck  
          Started by rtwave, 04-12-2024, 09:30 AM
          4 responses
          31 views
          0 likes
          Last Post rtwave
          by rtwave
           
          Started by yertle, Yesterday, 08:38 AM
          7 responses
          29 views
          0 likes
          Last Post yertle
          by yertle
           
          Started by bmartz, 03-12-2024, 06:12 AM
          2 responses
          22 views
          0 likes
          Last Post bmartz
          by bmartz
           
          Started by funk10101, Today, 12:02 AM
          0 responses
          7 views
          0 likes
          Last Post funk10101  
          Working...
          X