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

Gloabal Variables?

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

    #31
    I trade 1%-2% risk, but on day trades I find an individual trade frequently might use 50% of my equity with that risk profile. Its not a small account, but then again its not huge...

    The system makes like 4-5 trades a day, and i think i can get with a shared balance i can get a more efficient use of my funds...might not make a huge difference but we will see.

    I will report back with whether or not the static variable approach works...thanks!

    Comment


      #32
      Originally posted by bridenour View Post
      I trade 1%-2% risk, but on day trades I find an individual trade frequently might use 50% of my equity with that risk profile. Its not a small account, but then again its not huge...

      The system makes like 4-5 trades a day, and i think i can get with a shared balance i can get a more efficient use of my funds...might not make a huge difference but we will see.

      I will report back with whether or not the static variable approach works...thanks!
      Sounds like you have thought this out well and I'm glad to see you have a small risk. I haven't found a strategy that can use 50% of my equity with a 2% risk.. in my strategies a 2% risk usually means 2 contracts max. I think I need to find strategies with lower risk.

      Let me know how it goes. To test it I created a couple strategies that just entered randomly each bar (say 30% chance of entry) and I ran them and made sure that I never had two positions open at the same time. For some reason I did have 2 open at the same time! It's hard to debug.

      I don't remember what I wrote in the other thread but what I did was I made a strategy to handle this account equity. I used synchronized methods to "lock" and "unlock" the equity.

      Comment


        #33
        That explains it...I have a multiinstrument strategy that trades a bunch of 3x ultra etf's intraday -- thats where most of my balance can get allocated to a single position.

        I am currently layering in some futures strategies...they don't trade very often and that's where the shared account balance would come in handy.

        Thanks

        Comment


          #34
          Here is my code for the account "lock"

          Here is my code, I hope you will find it useful. I make no guarantees about it. For the most part it worked but when I ran the same strategy several times after a while (15-30 minutes?) I'd end up with two positions open.

          I also include an example strategy that uses it.

          After looking at the code I remember the difficulty: when you run a strategy you have to take into account the historical part, whether it locks or not. I also put an override in the strategy parameters because if the lock is in a "locked" state and you stop your strategies, you'll be stuck in the "locked" state. so the override let's you specify that it starts locked or unlocked.

          it's more complicated than it seems in my opinion.
          Attached Files

          Comment


            #35
            Newbie question

            Thanks for the code but as a relative newbie I wonder if you could suggest a "simple" route to take a variable from one indicator and plonk it in another?
            In easy language I would use the global variable route but I am a bit unsure here - you don't seem to have used that route?

            Comment


              #36
              Mindset,

              Have you seen this reference sample? http://www.ninjatrader-support2.com/...ead.php?t=4991
              Josh P.NinjaTrader Customer Service

              Comment


                #37
                Call bearIndication variable

                Josh

                So how does one call the variable in another indicator?

                Code:
                private DataSeries bullIndication;
                bullIndication  = new DataSeries(SampleBoolSeries());
                Print(bullIndication[0].ToString());
                This just seems to produce a string of zeros.
                Last edited by Mindset; 03-17-2009, 12:50 PM. Reason: change title

                Comment


                  #38
                  Originally posted by Mindset View Post
                  Thanks for the code but as a relative newbie I wonder if you could suggest a "simple" route to take a variable from one indicator and plonk it in another?
                  In easy language I would use the global variable route but I am a bit unsure here - you don't seem to have used that route?
                  The code I posted is to share data between two strategies. If you are in a single strategy working indicators then it's a lot easier, you can just use the code in your strategy.

                  It's not clear to me exactly what you're trying to do. If you could be more descriptive and provide an example then I'm sure we could give you some help.

                  Comment


                    #39
                    Mindset,

                    You can do so exactly the same way it is done in the strategy reference over on an indicator.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #40
                      Just not getting this

                      I am sorry for being dim but the sample just isn't helping me! It shows me how to create a non plotted value but I have no idea how to call it in another indicator

                      I assumed I create a new data series of the samplebool
                      series and then call the indexed bar of that data series and up pops the value? But my example doesn't do that so I am lost ... (lol)
                      remember I only learnt C# 3 months ago so what might seem obvious to yourself is not so obvious to me.

                      cunparis

                      thanks for the offer and I feel v frustrated that I just don't get this but
                      lets say I want to call this sampleboolseries in another indicator?
                      What do I need to invoke it? Print it out to the output window for instance?

                      Comment


                        #41
                        Apologies

                        Sorry.
                        I did not realise there was a strategy as well as the indicator which shows exactly how to call the variable. Doh - a homer moment.

                        Comment


                          #42
                          Ha ha

                          ok so I followed the strategy example

                          Add(MACD(12, 26, 9));
                          Add(SampleBoolSeries());

                          and I get an invalid argument error in both.

                          Comment


                            #43
                            Mindset,

                            You cannot "add" other indicators to an indicator. You can reference other indicators, but you can't add them for charting.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #44
                              lightbulb goes on

                              Got it - thanks Josh

                              Comment


                                #45
                                mkTrend, Have you used Global variables 2.2 version from Tradestation, which has the named varibales too with Ninja?

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by frankthearm, Yesterday, 09:08 AM
                                12 responses
                                43 views
                                0 likes
                                Last Post NinjaTrader_Clayton  
                                Started by junkone, Today, 11:37 AM
                                1 response
                                12 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Started by quantismo, 04-17-2024, 05:13 PM
                                5 responses
                                35 views
                                0 likes
                                Last Post NinjaTrader_Gaby  
                                Started by proptrade13, Today, 11:06 AM
                                1 response
                                6 views
                                0 likes
                                Last Post NinjaTrader_Clayton  
                                Started by love2code2trade, 04-17-2024, 01:45 PM
                                4 responses
                                35 views
                                0 likes
                                Last Post love2code2trade  
                                Working...
                                X