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

Help understanding logic

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

    Help understanding logic

    I'm a self admitted hacker when it comes to writing strategies. So, when the author of an indicator helped me with something, he had me do something that went over my head. I was wondering if someone could explain the logic so that I can use it in the future?

    In the initialize section, I have:
    Code:
    zzBAR    = ZigZagUTC_TL_BarCount_Fibs_v5_1(3,false,false,false,false,false,false,false,1,true,Color.Green);
    In on bar update, I have:
    Code:
    double z = zzBAR[0];
    And if I want to use something from that, I can simply do a "zzBAR.lastlo" (Or whatever value I'm pulling from it).

    But my question is, how can I pull a value from a bar other than [0]? Like [1]. Doing something like zzBAR.lastlo[1] obviously won't work. Do I have to make a zzLASTBAR with double x = zzLASTBAR[1]; ? Or is there another cleaner way?


    edit::: Forgot to mention there is the following in the variables:
    Code:
    private         ZigZagUTC_TL_BarCount_Fibs_v5_1 zzBAR;
    Thanks
    Last edited by lookOutBelow; 03-09-2011, 01:18 PM.

    #2
    Hello lookOutBelow,

    You should be able to use:

    double x = zzBAR.lastlo[1];

    An example of accessing prior values of a standard multiplot indicator is:
    double x = RSI(14, 3).Avg[1];
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ryan,

      When I do that, I get an error: Cannot apply indexing with [] to an expression of type 'method group'.

      For a reason I don't understand, it seems it wants the indicator parameters. Shouldn't it already be defined in zzBAR?

      Comment


        #4
        Without seeing exactly how it's coded, it's difficult to know what NT is expecting for syntax.

        Continuing the RSI example:
        private RSI myRSI; //variable declaration

        myRSI = RSI(14, 3); //OnStartup()

        double x = myRSI.Avg[1]; //Accessing prior Avg plot value in OnBarUpdate()
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by TraderBCL, Today, 04:38 AM
        2 responses
        11 views
        0 likes
        Last Post TraderBCL  
        Started by martin70, 03-24-2023, 04:58 AM
        14 responses
        105 views
        0 likes
        Last Post martin70  
        Started by Radano, 06-10-2021, 01:40 AM
        19 responses
        606 views
        0 likes
        Last Post Radano
        by Radano
         
        Started by KenneGaray, Today, 03:48 AM
        0 responses
        4 views
        0 likes
        Last Post KenneGaray  
        Started by thanajo, 05-04-2021, 02:11 AM
        4 responses
        471 views
        0 likes
        Last Post tradingnasdaqprueba  
        Working...
        X