Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsArray[0].GetHigh(0) and High[0] values different?

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

  • waltS
    replied
    Just a quick thank you for the last NT update... This seems to have addressed the issues I was having and have now successfully made the transition from MC to Ninja with promising back-test results...
    So far so good...
    .... Running my strategies this week with my IB demo account.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello waltS,

    From the given details it sounds like you ran into a forum post with some bad information, you should not delete the custom project if you are having problems using the platform.

    To fix the install problem here you can use the following steps:
    1. Exit NinjaTrader
    2. Open the documents folder
    3. Rename NinjaTrader 8 to NinjaTrader 8 old
    4. Run the installer, choosing the default install location of C. This will also generate a new user folder.

    If you need to reference old data it is in the NinjaTrader 8 old folder.

    If you are having trouble with VS in some way I would likely suggest breaking that off into a separate post so we can collect some details and see if that can be resolved.

    For the analyzer issue I would suggest testing the SampleMACrossOver any time the analyzer stops giving results or is not working in some way, that script is known to work and is a valid test to check if something in your script is causing an issue or if something is happening in the analyzer. If you see that is not working then you would need to backtrack and find what is not working, for example is the historical data present for the test?




    Leave a comment:


  • waltS
    replied
    So, my SA just decide to stop working and attempting to use the VS debugger just froze the OPT and/or Backtest..

    So, scanning the forum, it was indicated that the custom project should be erased; Did that and NINJA said it could not find the backup!
    Turns out that even though I had installed NT on my "D:" disk, it insisted on looking at "C:" for the backup...

    So, I ran the installer and selected "Repair" and NOTHING changed.

    Sooo, I uninstalled NT and reinstalled on the "C:" drive, thinking that would make it happy...
    I opened the script editor and attempted to re-compile my strat and got errors saying 6 support DLL's were not found IN THE "D" DIRECTORIES!!!

    Soooo, I got my trusty NotePad++ and found that the config XML file was still pointing to "D" FOR SOME FILES!
    After changing them to "C", I then was able to re-compile BUT, the SA still would not work (and I tried the simple strats supplied with NT); No joy...

    NOTE: The data was there...

    Many thanks for your help bitdavid, but after wasting HOURS attempting to get the strategy tester to start working again with no success, (and fighting the install inconsistencies), I cannot justify continuing any development in NT as it seems Ninja has just as many "un-documented features" as MC (if not more).

    I'm done with Ninja...

    Leave a comment:


  • waltS
    replied
    I browsed the forum and noticed similar issues were solved by deleting the "DB" folder...
    This seems to have worked... but I am a bit concerned as when I go live, my system runs from 5pm Sunday to 5pm Friday...
    >> I have already had issues with the IB gateway disconnecting at least once and have created an "auto-it" applet to monitor and reconnect... hope I don't have to build another to fix the data...

    I'll look at those settings you mentioned and hope that it helps prevent issues down-the-line... ...
    Thanks for the "heads-up"!

    Leave a comment:


  • bltdavid
    replied
    Originally posted by waltS View Post
    Nope; Single script..
    When I spec a start & end of 3/30 to 6/3; Calculates as expected... Then I changed the start to 5/20 and starts calculating but then just stops with no results.
    >> a similar issue with another symbol where it only worked with a five day period...
    This could happen ...
    if you don't have enough historical data, and you're
    not connected to your data provider.

    For me, I always disconnect before running SA.
    But, just before I disconnect, I manually download
    all the historical data I might need via,
    CC -> Tools -> Historical Data -> Load tab

    Since you're trying to use bid and ask data, you might
    need to deliberately download bid/ask historical data.

    See also CC -> Tools -> Options -> Market Data
    Not sure if 'Global merge policy' impacts SA's use
    of historical data, but mine is always set to
    'Merge back adjusted'.

    Last edited by bltdavid; 06-06-2022, 08:23 AM.

    Leave a comment:


  • waltS
    replied
    Nope; Single script..
    When I spec a start & end of 3/30 to 6/3; Calculates as expected... Then I changed the start to 5/20 and starts calculating but then just stops with no results.
    >> a similar issue with another symbol where it only worked with a five day period...
    Debugged with VS and nothing was thrown...
    Also, Opened a chart with the data and all looks OK...and re-loaded the history (just in case); no better...
    >> I suspect there is a history cache somewhere that is confused... But it's a cross between and elephant & a rhino: Elll - if - I- no.


    Leave a comment:


  • bltdavid
    replied
    Originally posted by waltS View Post
    weird issues with the Optimizer not working with the full range of data specified...
    Do you mean Optimization testing in Strategy Analyzer?

    From AddDataSeries,
    "Should your script be the host for other scripts that are creating indicators and series dependent resources in State.DataLoaded, please make sure that the host is doing the same AddDataSeries() calls as those hosted scripts would."

    Is your strategy doing that?

    Leave a comment:


  • waltS
    replied
    Thank for that confirmation that I'm on the right track..
    Also, it seems as I can now get the High (or Low) ask;
    BarsArray[1].GetHigh(CurrentBar)..

    Running into some weird issues with the Optimizer not working with the full range of data specified...
    I'm hoping it's just "user-ignorance" vs software "un-documented features"

    Leave a comment:


  • bltdavid
    replied
    Ah, I see, looking good.

    Some final thoughts...

    If you clicked through and read all the links, you'll note that I mentioned
    that the series are kept as 'parallel' to each other. That is, for any value
    of 'n',

    Open[n]
    High[n]
    Low[n]
    Close[n]
    Volume[n]
    Time[n]
    ask[n] <--- user-defined series
    bid[n] <--- user-defined series


    the values in each series at each 'n' are all from the same(*) bar.

    The point is:
    This axim is true for all series, even user-defined series.

    That means when you defined your ask and bid series, you are
    adding to the parallel data NinjaScript maintains on a per bar basis.

    And it doesn't matter what type, series<double> and series<int>
    and series<string> ... etc, these will all become parallel data.

    You can also think of the BarsAgo index as a slot number to
    retrieve data from historical bars. Looking backwards, the
    first historical bar is at Close[1], the 2nd historical bar is at
    Close[2], and so on. The key design of a series is that you
    are looking backwards (not forward like an array).

    Let's discuss your 'slap forehead' moment,

    ask[0] = BarsArray[1].GetClose(CurrentBar);

    Your 'ask' series is now part of the parallel data structures that are
    automatically maintained by NinjaScript. Thus, Close[n] and ask[n]
    etc etc, will always retrieve data from the same bar, for all values of 'n'.

    Your series are first-class citizens. They are not any different than
    the predefined series -- thus if you understand what the BarsAgo
    index of '2' is doing in Close[2], then ask[2] is no different.

    Just my 2˘.



    (*) Assumes all series are synced to the same bars array, which is
    done by the 'this' in the code 'new Series<double>(this);'
    Last edited by bltdavid; 06-03-2022, 09:34 AM.

    Leave a comment:


  • waltS
    replied
    ok; Here is my solution:

    Code:
    private Series<double> bid;
    private Series<double> ask;
    
    protected override void OnStateChange()
    {
    
         if (State == State.Configure)
           {          
            AddDataSeries("AUDUSD", BarsPeriodType.Minute, 5, MarketDataType.Ask);
           AddDataSeries("AUDUSD", BarsPeriodType.Minute, 5, MarketDataType.Bid);
         }
    else if (State == State.DataLoaded)
    {
    bid = new Series<double>(this);
    ask = new Series<double>(this);
    }
    
    //.....
    
    protected override void OnBarUpdate()
    {
    
    if (BarsInProgress == 0)
    {
     //...
    }
    else if (BarsInProgress == 1)
    {
    [B]ask[0][/B] = BarsArray[1].GetClose(CurrentBar);
    }
    else if (BarsInProgress == 2)
    {
    [B]bid[0][/B] = BarsArray[2].GetClose(CurrentBar);
    }
    
    if (BarsInProgress < 2) return;
    
    //...... calculations ...
    
    }
    The last piece of the puzzle is to find where I can grab the instrument name in the "OnStateChange" as the "instrument" object is null...

    I now can use the bid and ask series in my calculations...

    Leave a comment:


  • waltS
    replied


    Thanks for the info bitdavid;

    I am currently translating an FX strategy from Multicharts where I get Low pivots using the bid and and High pivots using the ask. (in MC these are already available)
    >>In FX these two data are sometimes very different from the "normal" close... and give a better indication of direction changes.

    <<ask[0] = Bars.GetAsk(CurrentBar);>>

    I will try this (which should be fine to use in the "Bar change" event) but I think I may have to load the initial history in the "State.DataLoaded"... so I can use as source for "zigZag"
    That was the reason for the initial question...

    You have been a great help and I will post when I figure out what works.

    Walt

    Leave a comment:


  • bltdavid
    replied
    Originally posted by waltS View Post
    Have to say, I've been programming for many years, (many languages & platforms), but to correctly populate a series with "ask" and "bid" in Ninja, is NOT straightforward... Still trying to wrap my head around it...
    Frankly, I've never seen a usage case for GetAsk() and GetBid().

    I mean, the bid/ask prices can be take on many different values through out
    the life of the bar -- I've always preferred to use the real-time bid/ask prices
    gathered via OnMarketData.
    Last edited by bltdavid; 06-02-2022, 08:34 PM.

    Leave a comment:


  • bltdavid
    replied
    Originally posted by waltS View Post
    Thank you Bitdavid, I was beginning to suspect that was the case that the series is reverse and the spots have to be "populated in reverse";

    I did look over the links, thank you;

    Ok so to populate a "double series" "ask" with the asks values;

    Code:
    ask[ask.count] = GetAsk(currentBar)
    and then can the "ask" series be used in an indicator??
    Did you try?
    ask[0] = Bars.GetAsk(CurrentBar);

    -=o=-

    But why do you need to use a series?

    I mean, if Bars.GetAsk(CurrentBar) is the current ask price of the most
    recently closed bar, then Bars.GetAsk(CurrentBar-1) is the ask price of
    the previous recently closed bar.

    What I mean is, if you use,

    Bars.GetAsk(CurrentBar-n)

    (where 'n' is basically the BarsAgo index) doesn't this do what you want?

    Leave a comment:


  • waltS
    replied
    Have to say, I've been programming for many years, (many languages & platforms), but to correctly populate a series with "ask" and "bid" in Ninja, is NOT straightforward... Still trying to wrap my head around it...
    Last edited by waltS; 06-02-2022, 07:30 PM.

    Leave a comment:


  • waltS
    replied
    Thank you Bitdavid, I was beginning to suspect that was the case that the series is reverse and the spots have to be "populated in reverse";

    I did look over the links, thank you;

    Ok so to populate a "double series" "ask" with the asks values;

    Code:
    ask[ask.count] = GetAsk(currentBar)
    and then can the "ask" series be used in an indicator??
    Last edited by waltS; 06-02-2022, 04:10 PM.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by kevinenergy, 12-18-2018, 07:08 AM
13 responses
331 views
0 likes
Last Post Bidder
by Bidder
 
Started by Vulgoth_t_Destroyer, 05-09-2022, 04:45 PM
59 responses
6,311 views
0 likes
Last Post slade3789  
Started by ryjoga, Yesterday, 11:22 PM
0 responses
9 views
0 likes
Last Post ryjoga
by ryjoga
 
Started by Vikuno1, Yesterday, 10:22 PM
0 responses
7 views
0 likes
Last Post Vikuno1
by Vikuno1
 
Started by nicthe, Yesterday, 07:57 PM
0 responses
11 views
0 likes
Last Post nicthe
by nicthe
 
Working...
X