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

Newbie coding help query; Range Bar query

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

    #16
    In Variables section of your code:

    Code:
    private int currVol = 0;
    private int prevVol = 0;
    private int upVol = 0;
    private int downVol = 0;
    In Initialize() method
    Code:
    CalculateOnBarClose = false;
    In OnBarUpdate() method
    Code:
    currVol = Volume[0] - prevVol;
    prevVol = Volume[0];
    if (Close[0] > Open[0])
         upVol = upVol + currVol;
    else if (Close[0] < Open[0])
         downVol = downVol + currVol;
    Again, I am ignoring the close versus open business.

    Are you saying that 'Volume' distinguishes between up volume and down volume? I thought Volume just counts shares/contracts traded in either direction. It certainly seems to do so from the up-down volume indicator.

    Or: does the close versus open business behave differently if you are not waiting until the close, i.e. working intrabar in which case close versus open = each subsequent tick one after another?

    Comment


      #17
      Josh,

      thanks for bearing with me. My last post was being sent after you had made this one. I believe we are beginning to understand each other on up volume etc. Yes, I mean upvolume tick by tick within the bar and same for down volume. That's the whole point.

      Thanks also to Anachronist.

      In your code, is prevTick something that has to be defined as a variable? I can't find it in the Help Menu anywhere but it looks to me like that is a pre-defined function. If not, how do you tell it what it is? (If you know what I mean!).

      Boy this is hard!!!! Surely it would take less time and bandwidth just to write it out?!

      Ash.


      Originally posted by NinjaTrader_Josh View Post
      cclsys,

      Then I do not know what you mean by volume. Volume only goes up; it never goes down except for when it is resetting itself for the next bar.

      You need to redefine out what up volume is to you. Up volume to me is the associated volume with an upward moving price. Down volume is the associated volume with a downward moving price. The way you determine up or down price movement is by comparing Close against Open.

      If you wanted to check this every single tick, the current tick's price against the previous tick's price, this is possible too.
      Code:
      if (Close[0] > prevTick)
           upVol = upVol + currVol;
      else if (Close[0] < prevTick)
           downVol = downVol + currVol;
      prevTick = Close[0];

      Comment


        #18
        OK, try this:

        (Variables)
        private int currVol = 0, prevVol = 0, upVol = 0, downVol = 0;
        private int prevPrice = 0;

        (Initialize)
        CalculateOnBarClose = false;

        (OnBarUpdate)
        if (FirstTickOfBar) upVol = downVol = prevVol = 0; // reset on first tick
        if (prevPrice == 0) { prevPrice = Close[0]; return; } // ignore first-ever tick
        currVol = Volume[0] - prevVol; // volume of this tick
        if (Close[0] > prevPrice) upVol += currVol;
        else if (Close[0] < prevPrice) downVol += currVol;
        prevVol = Volume[0]; // save value for next tick
        prevPrice = Close[0]; // save value for next tick

        Are you saying that 'Volume' distinguishes between up volume and down volume? I thought Volume just counts shares/contracts traded in either direction. It certainly seems to do so from the up-down volume indicator.
        No, Volume is just volume. It grows with each tick. The code above calculates the current tick volume by subtracting current volume from the previous volume from the last tick. Then it adds that difference to upVol or downVol depending on whether the current tick is higher or lower than the last tick.
        Or: does the close versus open business behave differently if you are not waiting until the close, i.e. working intrabar in which case close versus open = each subsequent tick one after another?
        I believe Open[0] is always the open of the current bar, not the current tick. Close[0] is the most recent price of the current bar. That's why the code above doesn't use Open. It uses the previous close for comparing the current close.

        It might be useful to make an indicator called UpVolume and DownVolume using the code above. That way you wouldn't need to reproduce the code where you need it elsewhere, because with NinjaTrader you can call indicators just like you'd call functions in TradeStation.

        -Alex
        Last edited by anachronist; 10-27-2008, 05:54 PM.

        Comment


          #19
          Anachonist:

          I know this is asking a lot but could you please send the whole thing? I can't get it to verify at all, errors all over. If I could see the whole thing after all this thread I think I would have learned a lot about how the language works and which section means what.

          Right now I am not sure where to put what and I think that is ballsing it up.

          Am getting the error (not referenced in Help when you click on it) that 'cannot convert a double to int' but it isn't a double in the variables menu which I pasted in (I think) from your post. Again, if I could get the whole thing then I could learn. Not only that, we'd have the paintbar!

          Ccclsys.
          Ash.


          Originally posted by anachronist View Post
          OK, try this:

          (Variables)
          private int currVol = 0, prevVol = 0, upVol = 0, downVol = 0;
          private int prevPrice = 0;

          (Initialize)
          CalculateOnBarClose = false;

          (OnBarUpdate)
          if (FirstTickOfBar) upVol = downVol = prevVol = 0; // reset on first tick
          if (prevPrice == 0) { prevPrice = Close[0]; return; } // ignore first-ever tick
          currVol = Volume[0] - prevVol; // volume of this tick
          if (Close[0] > prevPrice) upVol += currVol;
          else if (Close[0] < prevPrice) downVol += currVol;
          prevVol = Volume[0]; // save value for next tick
          prevPrice = Close[0]; // save value for next tick


          No, Volume is just volume. It grows with each tick. The code above calculates the current tick volume by subtracting current volume from the previous volume from the last tick. Then it adds that difference to upVol or downVol depending on whether the current tick is higher or lower than the last tick.

          I believe Open[0] is always the open of the current bar, not the current tick. Close[0] is the most recent price of the current bar. That's why the code above doesn't use Open. It uses the previous close for comparing the current close.

          It might be useful to make an indicator called UpVolume and DownVolume using the code above. That way you wouldn't need to reproduce the code where you need it elsewhere, because with NinjaTrader you can call indicators just like you'd call functions in TradeStation.

          -Alex

          Comment


            #20
            Okay, here's what I wrote. Two indicators, UpTickVolume and DownTickVolume. They compile fine, but I can't test them because IB isn't feeding me tick data right now.
            -Alex

            (Updated attachment; downtick indicator logic was wrong. Finally tested with live IB data; both indicators seem to work fine. Values are zero if ticks stay the same price. Picture is a chart with 3-tick bars, with both indicators plotted in the same panel.)
            Attached Files
            Last edited by anachronist; 10-27-2008, 08:37 PM.

            Comment


              #21
              Thanks very much!

              Now I know it is possible to calculate up and down volume within a tick bar.

              I can also see how an idea is written from beginning to end without the wizard interface which helps me understand a bit better how the scripts run.

              I will look over them tomorrow and hopefully learn and understand more.

              I am not sure how to turn two separate indicators into one that simply paints the bar which is all I'm looking for, but with any luck I can figure it out.

              You mentioned that indicators can be used as functions. I guess all that is needed is to put them together into a third indicator and then plot the bar colour accordingly. But I note that each bar when they are combined only has one result, positive or negative, so maybe each indicator you have made is actually doing what I wanted already and if it's positive it plots in the uptick indicator and negative in the downtick indicator?

              It seems to me that perhaps all I will have to do is change one line (plus adding additional variables to include them all, namely:

              if (CurrentBar > 0 && Bars.TotalTicks == 0) return; // not a tick chart
              if (FirstTickOfBar) downVol = prevVol = 0; // reset on first tick
              if (prevPrice == 0) { prevPrice = Close[0]; return; } // ignore first-ever tick
              currVol = Volume[0] - prevVol; // volume of this tick
              if (Close[0] < prevPrice) downVol += currVol;
              prevVol = Volume[0]; // save value for next tick
              prevPrice = Close[0]; // save value for next tick

              DownTickVol.Set(-downVol);


              New version:

              if (CurrentBar > 0 && Bars.TotalTicks == 0) return; // not a tick chart
              if (FirstTickOfBar) downVol = prevVol = 0; // reset on first tick
              if (prevPrice == 0) { prevPrice = Close[0]; return; } // ignore first-ever tick
              currVol = Volume[0] - prevVol; // volume of this tick
              if (Close[0] < prevPrice) downVol += currVol else upvol +=currVol;
              prevVol = Volume[0]; // save value for next tick
              prevPrice = Close[0]; // save value for next tick

              DownTickVol.Set(-downVol);

              I added in the else command not knowing if it works in Ninja Script or how to write it.

              I don't see in the code where you tell it to plot. Is that what the last line is saying? If so, I would have to create another variable to hold it.

              Well, I think I have asked too much. I am quite surprised that such a simple thing is so complex to explain and to do and that I am still quite a ways from getting to make the paintbar from this. But that's the learning process I guess and thanks again.


              I wish there was a place where I could find a list of the core vocabulary, i.e. like 'firsttickofbar' along with explanations and examples of how they are used. That way it would be easier to learn. Noticing the little + mark by variables which Josh pointed out was very helpful. If it was in the tutorials I must have forgotten or simply not noticed that sometimes it is not expanded. I have no idea what += or == mean and not sure how to find out.

              I know I am supposed to do the videos but unfortunately I can't.




              Originally posted by anachronist View Post

              (Updated attachment; downtick indicator logic was wrong. Finally tested with live IB data; both indicators seem to work fine. Values are zero if ticks stay the same price. Picture is a chart with 3-tick bars, with both indicators plotted in the same panel.)

              Comment


                #22
                Originally posted by cclsys View Post
                I can also see how an idea is written from beginning to end without the wizard interface which helps me understand a bit better how the scripts run.
                Actually, I use the wizard to set up the framework for the code. It's easier than writing the whole thing from scratch, especially when the only parts one generally cares about are the variables, Initialize(), and OnBarUpdate().

                I am not sure how to turn two separate indicators into one that simply paints the bar which is all I'm looking for, but with any luck I can figure it out.
                Well, to paint a bar, you simply set BarColor to something. Example of another indicator using the ones I sent as functions:

                if (UpTickVolume()[0]+DownTickVolume()[0] < 0)
                BarColor = Color.Red;
                else
                BarColor = Color.Blue;

                You mentioned that indicators can be used as functions. I guess all that is needed is to put them together into a third indicator and then plot the bar colour accordingly. But I note that each bar when they are combined only has one result, positive or negative, so maybe each indicator you have made is actually doing what I wanted already and if it's positive it plots in the uptick indicator and negative in the downtick indicator?
                I noticed that too. A bar containing multiple ticks should have values for both the up volume and the down volume. I'm plotting up as positive and down as negative, but there should be bars that have both up and down values. Something is going wrong. I'm not sure what it is.

                It seems to me that perhaps all I will have to do is change one line (plus adding additional variables to include them all, namely:

                if (Close[0] < prevPrice) downVol += currVol else upvol +=currVol;

                I added in the else command not knowing if it works in Ninja Script or how to write it.
                You need a semicolon after the statement, like this:
                if (Close[0]<prevPrice) downVole += currVol; else upVol += currVol;

                Even so, that change won't work for you. Volume has THREE components: up volume, down volume, and unchanged volume. What you're doing above is lumping the unchanged volume into up volume.

                I don't see in the code where you tell it to plot. Is that what the last line is saying? If so, I would have to create another variable to hold it.
                The Initialize() method sets up a plot. Assigning a value to it causes something to be displayed. UpTickVol.Set(x) is the same as UpTickVol[0]=x by the way.

                I wish there was a place where I could find a list of the core vocabulary, i.e. like 'firsttickofbar' along with explanations and examples of how they are used. That way it would be easier to learn. Noticing the little + mark by variables which Josh pointed out was very helpful. If it was in the tutorials I must have forgotten or simply not noticed that sometimes it is not expanded. I have no idea what += or == mean and not sure how to find out.
                I suggest first getting a book on the C# language, or looking at Microsoft's online documentation, to learn the syntax. The NinjaTrader support page also has an online document (better than the downloadable PDF) with an index of just about all the vocabulary.

                Math operators like += are standard in many languages such as C, C++, Java, C#, PHP, etc. x+=y is shorthand for x=x+y. The former compiles into more efficient machine code than the latter, which is why we use it. The '=' operator is for assigning values, the '==' operator is for comparing values. As I said, study C# a bit. The NinjaTrader documents don't try to teach you the C# language; there are other manuals for that.

                -Alex
                Last edited by anachronist; 10-27-2008, 10:06 PM.

                Comment


                  #23
                  All,

                  A really good book which I use for syntax reference is
                  Pro C# 2008 and the .NET 3.5 Platform 4th Edition by Andrew Troelsen
                  ISBN #978-1-59059-884-9

                  It has a lot of advanced material that you probably won't use, but overall its a good, complete reference.

                  hope you find it helpful.

                  mrlogik
                  mrlogik
                  NinjaTrader Ecosystem Vendor - Purelogik Trading

                  Comment


                    #24
                    Well, it is 1 am chez moi so I'm calling it a night. Thanks again for the help. I'll spend some time going through all this and will learn, though it is clear that if I want to learn to code in Ninja I'll have to study C+ and I suspect I just won't be able to go there. Pity.

                    That said, in response to remark below: there is no such thing as 'unchanged' volume. With every tick there is volume, the only question is how much, i.e. 1 contract or 50 contracts, and the additional question is it up volume or down volume. There is no comparison with previous volume necessary, i.e. whether it's higher or lower or unchanged.

                    Probably it would be fine to assume that an uptick's volume is upvolume and a downtick's is down volume, but how you deal with bids and offers happening at the same price I am not sure, but again I am not really sure how up and down volume is calculated exactly since in EL it's part of the preset codes and works easily.

                    But practically speaking I am sure it would be fine to simply add the volume in an uptick to the upvolume of the bar and the volume in a downtick to the downvolume of a bar.

                    In the end, in each bar there will X up contracts and Y down contracts and the net is X-Y which determines the bar colour.

                    The logic in EasyLanguage sorta English is sort of like this:

                    If it's the first tick of a bar everything starts fresh.
                    If it's an uptick, add the volume to uptickvol;
                    If it's a downtick, add the volume to downtickvol;
                    Netvol = uptickvol-downtickvol;

                    If Netvol >0 then color is bullcoror else color is bearcolor.

                    Plot Netvol (color).

                    Anyway, thanks again and ciao.

                    Originally posted by anachronist View Post
                    Actually, I use the wizard to set up the framework for the code. It's easier than writing the whole thing from scratch, especially when the only parts one generally cares about are the variables, Initialize(), and OnBarUpdate().

                    Well, to paint a bar, you simply set BarColor to something. Example of another indicator using the ones I sent as functions:

                    if (UpTickVolume()[0]+DownTickVolume()[0] < 0)
                    BarColor = Color.Red;
                    else
                    BarColor = Color.Blue;

                    I noticed that too. A bar containing multiple ticks should have values for both the up volume and the down volume. I'm plotting up as positive and down as negative, but there should be bars that have both up and down values. Something is going wrong. I'm not sure what it is.

                    You need a semicolon after the statement, like this:
                    if (Close[0]<prevPrice) downVole += currVol; else upVol += currVol;

                    Even so, that change won't work for you. Volume has THREE components: up volume, down volume, and unchanged volume. What you're doing above is lumping the unchanged volume into up volume.

                    The Initialize() method sets up a plot. Assigning a value to it causes something to be displayed. UpTickVol.Set(x) is the same as UpTickVol[0]=x by the way.

                    I suggest first getting a book on the C# language, or looking at Microsoft's online documentation, to learn the syntax. The NinjaTrader support page also has an online document (better than the downloadable PDF) with an index of just about all the vocabulary.

                    Math operators like += are standard in many languages such as C, C++, Java, C#, PHP, etc. x+=y is shorthand for x=x+y. The former compiles into more efficient machine code than the latter, which is why we use it. The '=' operator is for assigning values, the '==' operator is for comparing values. As I said, study C# a bit. The NinjaTrader documents don't try to teach you the C# language; there are other manuals for that.

                    -Alex

                    Comment


                      #25
                      Originally posted by cclsys View Post
                      there is no such thing as 'unchanged' volume. With every tick there is volume, the only question is how much, i.e. 1 contract or 50 contracts, and the additional question is it up volume or down volume.
                      You're misunderstanding what unchanged volume means. There is volume associated with up moves, volume associated with down moves, and volume when trading occurs at a constant unchanging price. That last is unchanged volume. It's standard terminology. It means we had volume while price stayed constant.

                      What you seem to have been requesting is volume when there's an uptick, and volume when there's a downtick. Volume which the price doesn't change has been ignored all throughout this message thread. You can't just take the volume when price doesn't change and arbitrarily call it one or the other.

                      If you want to define 'up volume' and 'down volume' differently, then we can implement something else. Your slight change to a line of code won't do it, though.

                      Even if you define them, as Josh did originally, as volume above the bar open and volume below the bar open, you still have 'unchanged' volume corresponding to when price equals the bar open.

                      Probably it would be fine to assume that an uptick's volume is upvolume and a downtick's is down volume, but how you deal with bids and offers happening at the same price I am not sure, but again I am not really sure how up and down volume is calculated exactly since in EL it's part of the preset codes and works easily.
                      The only way I can think to include the volume of unchanged prices is to lump them in with the last uptick or downtick. That is, when we get some up volume, any subsequent volume continues to be classified as up volume until we get some down volume.

                      I can change the indicators to do that, if you want.

                      Also, I figured out something, and hope Josh or someone can help here. The reason the plot looks wrong is that indicators for historical bars don't use the underlying ticks! It's just using open and close, basically. So if the bar closes higher, it's an up volume bar. If the bar closes lower, it's a down volume bar.

                      I noticed, that that bars updating in REAL TIME actually do show up and down volume simultaneously. It's the historical bars that don't do that.

                      I am not sure how to fix this, other than perhaps overriding the internal OnMarketData() method. (Update: I just tried it; OnMarketData() also ignores the historical ticks.)

                      Anyone from support shed some light?

                      -Alex
                      Last edited by anachronist; 10-27-2008, 10:56 PM.

                      Comment


                        #26
                        Alex,

                        There is nothing you can do about that right now. Historical bars only have OHLC of the bar and no tick data available for those bars. This is why you can't access the up/down volume from those historical bars.

                        NT7 will have multi-instrument indicators which can solve this to a degree, but loading 1-tick data in the background along with several days of data can be very taxing on the computer system.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #27
                          Thanks for the clarification, Josh.

                          Taxing the software with historical tick data while managing real-time incoming tick data probably isn't practical, I agree.

                          However, would it be reasonable to do this in a backtesting mode only, when there is no connection to a data provider? If not tick data, then how about very short time interval bars (like 30 second bars) from which to build higher time interval bars?

                          -Alex

                          Comment


                            #28
                            Alex,

                            It depends on the power of your own computer. You can definitely play with it to see what your system can handle. There will be performance improvements in NT7 so that should help out too.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #29
                              Anachronist: I see what you mean about unchanged volume and understand. I thought you meant something else.

                              As I mentioned somewhere down there, I am not sure exactly what I am looking for since in TS it's precoded; how they calculate up and down volume exactly I am not sure but I suspect it's based on bid and offer rather than ticks per se. That way anything bought at the bid is down and anything sold at the offer is above. But I really don't know how they do it and they don't say and that function code for 'uptick' and 'downtick' is not open. (sometimes uptick = up vol, sometime uptick depending on how you set the symbol on loading).

                              I also noticed them updating live. Interesting. Am still not sure if they are giving the right reading but it would be interesting to see them put together as originally conceived into one indicator and/or paintbar which is all I really want. I tried combining them but the result was clearly wrong. Probably something to do with not knowing how to code + or - properly in C+.

                              Thanks for recommendation of C+ book. I really hesitate to get into all that but I suspect I am going to have to if I want to get anywhere with Ninja coding. Actually, I am using Ninja primarily as trading platform and the two simple indicators I use are already included. But I do like that Better Volume Indicator - thanks to Anach. for coding it, works fine although latest version is a little better at discriminating up and down vol although perhaps that is going to be hard in Ninja! - and also like my volume bars versus simple up and down bars which only tell you what you can already see in a non-coloured OHLC bar.

                              I am not sure if I was asking for a change. When Josh first defined it as above the open or below the open I did not understand this was happening tick by tick, he did not explain just put it out there and I thought it meant the bar open and bar close. This is because I am new to Ninja coding and also I think he only put those lines in isolated from anything else. In any case, I misunderstood what he was doing and thought he was basically doing the same thing as the up-down volume indicator which paints the volume bullish if the bar closes higher or something. I now think that when you have it set to not use the close for updating (sorry, can't remember code and am typing in little window here) then c = each tick not the close of the bar. Is this correct?

                              Assuming it is, then Anachronist if you think you have a solution, please go ahead. I would really like to see it all put into one indicator although personally I like the paintbar better. However, the indicator at least lets you see what its calculating so we can check, although how to check I don't know come to think of it! I guess if the up and down volume together end up being the same amount as the basic Volume Indicator then probably it is correct!


                              Originally posted by anachronist View Post
                              You're misunderstanding what unchanged volume means. There is volume associated with up moves, volume associated with down moves, and volume when trading occurs at a constant unchanging price. That last is unchanged volume. It's standard terminology. It means we had volume while price stayed constant.

                              What you seem to have been requesting is volume when there's an uptick, and volume when there's a downtick. Volume which the price doesn't change has been ignored all throughout this message thread. You can't just take the volume when price doesn't change and arbitrarily call it one or the other.

                              If you want to define 'up volume' and 'down volume' differently, then we can implement something else. Your slight change to a line of code won't do it, though.

                              Even if you define them, as Josh did originally, as volume above the bar open and volume below the bar open, you still have 'unchanged' volume corresponding to when price equals the bar open.

                              The only way I can think to include the volume of unchanged prices is to lump them in with the last uptick or downtick. That is, when we get some up volume, any subsequent volume continues to be classified as up volume until we get some down volume.

                              I can change the indicators to do that, if you want.

                              Also, I figured out something, and hope Josh or someone can help here. The reason the plot looks wrong is that indicators for historical bars don't use the underlying ticks! It's just using open and close, basically. So if the bar closes higher, it's an up volume bar. If the bar closes lower, it's a down volume bar.

                              I noticed, that that bars updating in REAL TIME actually do show up and down volume simultaneously. It's the historical bars that don't do that.

                              I am not sure how to fix this, other than perhaps overriding the internal OnMarketData() method. (Update: I just tried it; OnMarketData() also ignores the historical ticks.)

                              Anyone from support shed some light?

                              -Alex

                              Comment


                                #30
                                I tried changing it but of course nothing will verify but tell me what you think of the logic. I took your original code for the downtick indicator and hashed out the lines, then changed a few things and tried to combine them.

                                Now what I did was say that if Vol [0] which I understand now to mean the volume at the point of this current tick is greater than prevVOL which is the vol at the last tick, then do the following: if its an uptick (close > open) add it to upvol, it it's a downtick add it to downvol. Then take upvol-downvol and paint the bar accordingly. That's what I am trying to do anyway based on what I have tried to understand here.

                                I also hashed out the line for if it's not a tick chart since this works just as well with any bar as a tick bar. Unless that's another thing with Ninja that I just don't know about. But there are ticks in minute bars, ticks in range bars so I don't see it makes any difference so I took that line out.

                                Ash.

                                /// <summary>
                                /// This method is used to configure the indicator and is called once before any bar data is loaded.
                                /// </summary>
                                protected override void Initialize()
                                {
                                Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Bar, "DownTickVol"));
                                CalculateOnBarClose = false;
                                Overlay = false;
                                PriceTypeSupported = false;
                                }

                                /// <summary>
                                /// Called on each bar update event (incoming tick)
                                /// </summary>
                                protected override void OnBarUpdate()
                                {
                                //if (CurrentBar > 0 && Bars.TotalTicks == 0) return; // not a tick chart
                                //if (prevPrice == 0) { prevPrice = Close[0]; return; } // ignore first-ever tick
                                //if (Close[0] < prevPrice) downVol += currVol;
                                //else upVol +=currVol;
                                //prevVol = Volume[0]; // save value for next tick
                                //prevPrice = Close[0]; // save value for next tick
                                //DownTickVol.Set(upVol-downVol);

                                if (FirstTickOfBar) downVol = prevVol = 0;
                                if (FirstTickOfBar) upVol = prevVol = 0; // reset on first tick

                                currVol = Volume[0] - prevVol; // volume of this tick
                                if (Volume[0] > prevVol) begin
                                if (Close[0] < prevPrice) downvol +=currVol;
                                if (Close[0] > prevPrice) upvol += currVol; end;

                                // if (Volume[0] > prevVol) and (Close[0] < prevPrice) downvol +=currVol;
                                // if (Volume[0] > prevVol) and (Close[0] > prevPrice) upvol += currVol;
                                //last two lines an attempt at two lines above without begin end but still don't verify.
                                prevVol = Volume[0]; // save value for next tick
                                prevPrice = Close[0]; // save value for next tick

                                if (downvol - upvol < 0)
                                BarColor = Color.Cyan; // bearish
                                else
                                BarColor = Color.Yellow; // bullish


                                }
                                Last edited by cclsys; 10-28-2008, 01:35 PM.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by cmtjoancolmenero, Yesterday, 03:58 PM
                                6 responses
                                28 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Started by gbourque, Today, 06:39 AM
                                2 responses
                                14 views
                                0 likes
                                Last Post gbourque  
                                Started by rexsole, Today, 08:39 AM
                                0 responses
                                4 views
                                0 likes
                                Last Post rexsole
                                by rexsole
                                 
                                Started by trilliantrader, Yesterday, 03:01 PM
                                3 responses
                                31 views
                                0 likes
                                Last Post NinjaTrader_Clayton  
                                Started by Brevo, Today, 01:45 AM
                                1 response
                                14 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Working...
                                X