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

Trying a Probability Indicator Need Help!

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

    Trying a Probability Indicator Need Help!

    Hey guys. I'm trying something out and cant figure some stuff out. I attached the indicator. its SUPPOSED to Plot a yellow diamond when the winning condition is met, and Red Diamond when Losing condition is met.

    WInning = After RSi goes OverSold, the Next Bar or next 2 bars have to Close Above the Low of the Bar that had the RSI crossbelow OverSold.

    Losing = Next bar or 2, Close Below the LOW of the RSI-Trigger bar.

    1. First problem, when I try to set the Close Above condition, the indicator is using the Trigger bars Close, so its Drawing the Diamond on the Trigger bar, even if the Next bar closes Below the Trigger.
    SAMPLE: http://screencast.com/t/GLoGBiX8a

    Is there a way to make the RSI-Trigger bar get ignored so that the WIN/LOSS is only calculated on the Next Bar or Bar after that???


    In other words. RSI Crosses Below --> This Bar that got OverSold Gets the High/Low Values inputed into a Variable, but the Close is Ignored --> The Next Bar's Close is used for calculation --> The Bar right after that is used for Calculation = WIN/LOSS. Draw Diamond.
    Attached Files

    #2
    ginx10k, sounds to me like you want to save the barnumber (CurrentBar) where your condition evaluated to a variable and then upon doing the count demand that the CurrentBar is greater than this last saved value, thus ensuring the counting could not happen on the same bar.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Are you asking a question, or stating something? I'm sorry, I was hoping for a bit more help then that. Perhaps some code sample or something.

      If I wasn't clear enough in my First post or the Code, or my questions please let me know.

      Please show me some sample of code or something helpful so I can accomplish this task.


      thank you for fast response!!

      Comment


        #4
        ginx10k, to clarify - I did state input for you to think about and work with on your custom study. As you probably already know we do not provide coding services and as such we cannot make those modifications for you unfortunately.

        To further expand you can save the barnumber in any condition in your code such as when you start drawing

        if (condition)
        myBarNumber == CurrentBar; // where myBarNumber would be an integer variable you already have setup

        You can now subsequently work with that saved value for comparison in other conditions, i.e.

        if (condition && CurrentBar > myBarNumber)
        ... do something

        If you prefer to have these modifications done by a professional NinjaScript consultant for you here's a list of all certified ones -



        Thanks for your understanding of our process and approaches of requests in this regard.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          That was def helpful. its all I was asking, a little code snippet. and I appreciate that very much.

          now 2nd question. Is there a way to Skip a Bar.

          Lets say I capture the Trigger bar,

          if(condition)
          triggerBar = Currentbar;

          But I don't want the very Next bar to check something, I want the bar after that one:

          if(Close[3rdBar] > Close[triggerBar];
          //do something.......

          But how do I do that. I know that if I type if(Close[0] > Close[triggerBar]) it'll use the very next bar after triggerBar.

          Comment


            #6
            ginx10k, you don't want to use the saved bar as index for accessing the Close price, but you rather want to include it in your condition to do the second check you seek, so it would skip a bar as you would define how many bars between the saved bar and then CurrentBar would have to have passed before your condition evaluates to 'true'. That was the second part in my earlier reply...

            if (condition && CurrentBar > yourSavedTriggerBar)
            ... do something
            BertrandNinjaTrader Customer Service

            Comment


              #7
              ??

              But that's what confuses me. How would I set that condition to skip the bars. it's a Little bit more confusing than I thought because I thought when we set the trigBar = CurrentBar; that would've made the trigBar an Integer that I could've used for Close[trigBar];

              I just want some clear way of making this happen cause "if (condition && CurrentBar > yourSavedTriggerBar)
              ... do something" just throws me off a bit. sry for my confusion, I'm not 100% versed in C# or NinjaScript. still learning.


              How would I use the "if(Close[0] be greater than The Low of the Trigger bar, from 2 bars ago."

              Please Someone Help with This.

              Comment


                #8
                Originally posted by ginx10k View Post
                But that's what confuses me. How would I set that condition to skip the bars. it's a Little bit more confusing than I thought because I thought when we set the trigBar = CurrentBar; that would've made the trigBar an Integer that I could've used for Close[trigBar];

                I just want some clear way of making this happen cause "if (condition && CurrentBar > yourSavedTriggerBar)
                ... do something" just throws me off a bit. sry for my confusion, I'm not 100% versed in C# or NinjaScript. still learning.


                How would I use the "if(Close[0] be greater than The Low of the Trigger bar, from 2 bars ago."

                Please Someone Help with This.
                The Low of the trigger bar, int Trig, as measured from the CurrentBar is:

                Low(CurrentBar - Trig)

                Comment


                  #9
                  I finally Figured out what you were saying Bertrand. CurrentBar is a number. and saved bar is a number. okay. this is awesome.


                  Sorry I just couldn't get it.

                  Thanks!!

                  Comment


                    #10
                    No worries, glad that worked out for you. Yes CurrentBar is an integer number that lets you know what bar OnBarUpdate() is currently processing.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Fixed Text

                      I know this is amazing. I can skip any bar I want. Much appreciated.

                      Another small question:

                      If lets say I want to place a FixedText probability the Counting variable that I'm going to use. On lets say the top left corner of Every Session. Is that possible?

                      For instance, if my "WIN = wins++" and I want that to ONLY show the Wins for Monday, but then when tuesday comes, I want a New Text to be drawn with Tuesday's Wins.

                      But I want to Still Look back at every day and see that the Wins from Every day are there.

                      Is that possible? any suggestions to start drawing New Text Every Day, but keep old text when I'm looking back?

                      Comment


                        #12
                        Sure, you could use the relatively easy to use DrawTextFixed(), which will allow drawing that text to one of 5 predefined locations on your chart.



                        You can display then whatever text string you want to show, like the # of wins for a given day - you would just need to reset your tracking variable then every new session basically - here's a sample that will help in this regard - http://www.ninjatrader.com/support/f...ad.php?t=19182
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Percentage Not Working

                          Thanks again bertrand.

                          Any idea why the simple code
                          Code:
                          winPercent = (value / maxvalue) * 100;
                          keeps returning a 0.


                          I even tried simple (50 / 100) * 100; I can't get a percentage. and the winpercent is a double.

                          Comment


                            #14
                            Any idea why the simple code Code:
                            winPercent = (value / maxvalue) * 100;
                            keeps returning a 0.

                            I even tried simple (50 / 100) * 100; I can't get a percentage. and the winpercent is a double.
                            Hi Gin

                            This kind of thing has always driven me mad - but after 2˝ of working with Ninjascript/C# I'm learning - just about!!!

                            It's a question of declaring integers as doubles in C#, so that line should be coded as:

                            Code:
                            double winPercent = ((double) 50 / (double) 100) * 100;
                            If you had written:

                            Code:
                            double winPercent = .5 * 100;
                            that would have worked.

                            Maybe the seriously brilliant Ninja guys could offer something better than this, but it works - I've just checked it in an indicator.

                            Happy coding.

                            P.S. I don't know whether you declared value and maxvalue as int or double but the above should help.
                            Last edited by arbuthnot; 06-28-2014, 12:06 PM. Reason: Omitted something important

                            Comment


                              #15
                              thanks Bud. I used
                              Code:
                              winPercent = (wonTrade/(wonTrade+lossTrade)) * 100;
                              where I declared everything a Double and it worked.

                              Only problem is it gives a Long Decimal number. any idea how to Round that up.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by cre8able, Today, 01:16 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post cre8able  
                              Started by chbruno, 04-24-2024, 04:10 PM
                              3 responses
                              48 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by samish18, Today, 01:01 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by WHICKED, Today, 12:56 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by WHICKED, Today, 12:45 PM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X