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

How to know close price of specific instrument?

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

  • NinjaTrader_ChelseaB
    replied
    Hello Yevhenii,

    Add a secondary series of 1 day and call the Volumes[1][0] for that previous day.

    http://ninjatrader.com/support/helpGuides/nt7/add3.htm

    http://ninjatrader.com/support/helpG...t7/volumes.htm

    Leave a comment:


  • Yevhenii
    replied
    How to get close, high, volume of previous day?

    for example
    I need to get VOLUME of previous day. How to check it?

    Leave a comment:


  • Yevhenii
    replied
    Thank you so much)

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Yevhenii,

    Not all instruments are the same. You are attempting to load invalid contracts months.

    The CL does not have an 03-17 contract month. You will need to check each instrument and ensure that this is the proper front month.

    Leave a comment:


  • Yevhenii
    replied
    Thanks. But I have another problem...
    After choosing my strategy
    (
    with code where with ...Add("6A 03-17", PeriodType.Minute, 15)...
    )
    , when I want to add new strategy there are no changes on window form "New strategy". It happen when I add more than
    8 rows
    like this
    protected override void Initialize()
    {
    CalculateOnBarClose = true;

    Add("6A 03-17",PeriodType.Minute, 15);
    Add("6B 03-17",PeriodType.Minute, 15);
    Add("6C 03-17",PeriodType.Minute, 15);
    Add("6E 03-17",PeriodType.Minute, 15);
    Add("6J 03-17",PeriodType.Minute, 15);
    Add("6S 03-17",PeriodType.Minute, 15);
    Add("CL 03-17",PeriodType.Minute, 15);
    Add("ES 03-17",PeriodType.Minute, 15);
    Add("GC 03-17",PeriodType.Minute, 15);
    Add("ZW 03-17",PeriodType.Minute, 15);
    }

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Yevhenii,

    You must use the full instrument name which includes the expiry.
    Add("6A 03-17", PeriodType.Minute, 15);

    Each series is found by the BarsInProgress index.

    For example, if you wanted the close of the 6J 03-17 15 minute you would use the 5th BarsInProgress index.

    Print(Closes[5][0].ToString());

    This would print the close of the 6J 03-17 as the 6J 03-17 was the 5th added series. (The primary series is BarsInProgress 0).

    Leave a comment:


  • Yevhenii
    replied
    Thank you so much. You are right.

    When I have 9 instruments and I do the following:


    protected override void Initialize()
    {
    CalculateOnBarClose = true;

    Add("6A",PeriodType.Minute, 15);
    Add("6B",PeriodType.Minute, 15);
    Add("6C",PeriodType.Minute, 15);
    Add("6E",PeriodType.Minute, 15);
    Add("6J",PeriodType.Minute, 15);
    Add("6S",PeriodType.Minute, 15);
    Add("CL",PeriodType.Minute, 15);
    Add("ES",PeriodType.Minute, 15);
    Add("GC",PeriodType.Minute, 15);
    }

    How to get number of bar in "OnBarUpdate()" by needed instrument?

    I have next logic... I check open position in the "OnBarUpdate()" and if instrument of open position == equal any instrument of bars I use closes price of needed bar. but I don't know how to look through (check all instrument from bars)

    it can be smth like

    onBarUpdate() {
    foreach( InstrumentFromBar in ALLINSTRUMENTINBAR)
    if(myInstrument == InstrumentFromBar)
    ...
    Last edited by Yevhenii; 12-21-2016, 08:34 AM.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Yevhenii,

    Thank you for your note.

    From your inquiry, you may be trying to add additional data series to a NinjaScript strategy for referencing multiple instruments.

    You can do this in NinjaTrader 7 with the Add() method.
    Add(string instrumentName, PeriodType periodType, int period)
    http://ninjatrader.com/support/helpGuides/nt7/add3.htm

    For example if I wanted to add a secondary series of the NQ 03-17 with a 5 minute bar type I could add to Initialize():
    protected override void Initialize()
    {
    Add("NQ 03-17", PeriodType.Minute, 5);
    }

    Then in OnBarUpdate I could get the price of this with the Closes (plural) collection by supplying 1 as the BarsInProgress Index and 0 as the bars ago value.
    Closes[int barSeriesIndex][int barsAgo]
    http://ninjatrader.com/support/helpG...nt7/closes.htm

    For example:
    protected override void OnBarUpdate()
    {
    Print(Closes[1][0].ToString());
    }

    Please, let me know if I have misunderstood your inquiry.

    Leave a comment:


  • Yevhenii
    started a topic How to know close price of specific instrument?

    How to know close price of specific instrument?

    How to know close price of specific instrument from one strategy? I mean...
    I know only names of instruments. How to get close price only from one strategy?

    I need close price of 3 diff instrument only from one strategy
    Last edited by Yevhenii; 12-21-2016, 07:54 AM.

Latest Posts

Collapse

Topics Statistics Last Post
Started by Christopher Leggit, Today, 01:54 AM
0 responses
1 view
0 likes
Last Post Christopher Leggit  
Started by WHICKED, Yesterday, 11:12 PM
0 responses
5 views
0 likes
Last Post WHICKED
by WHICKED
 
Started by AdeptistJune, Yesterday, 08:08 PM
1 response
6 views
0 likes
Last Post bltdavid  
Started by GKbowen, Yesterday, 04:03 PM
3 responses
12 views
0 likes
Last Post bltdavid  
Started by bojim, Yesterday, 08:35 PM
0 responses
4 views
0 likes
Last Post bojim
by bojim
 
Working...
X