• 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

OF ninjascript issue

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

  • Tiang
    started a topic OF ninjascript issue

    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

  • NinjaTrader_ChrisL
    replied
    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:

    https://ninjatrader.com/support/help...volumetric.htm

    Please let me know if I can assist further.,
    Attached Files

    Leave a comment:


  • xg5463
    replied
    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

    Leave a comment:


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

    Leave a comment:


  • NinjaTrader_ChrisL
    replied
    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.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by tgn55, Today, 08:57 PM
0 responses
1 view
0 likes
Last Post tgn55
by tgn55
 
Started by chartish, Today, 04:43 PM
1 response
10 views
0 likes
Last Post NinjaTrader_EricB  
Started by Trader17, Today, 04:07 PM
0 responses
6 views
0 likes
Last Post Trader17  
Started by GussJ, Today, 01:30 PM
2 responses
20 views
0 likes
Last Post GussJ
by GussJ
 
Started by GARZONJ, Today, 12:25 PM
3 responses
18 views
0 likes
Last Post NinjaTrader_PaulH  
Working...
X