Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Static/saved variables/values for indicators?

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

    Static/saved variables/values for indicators?

    Hi,

    if I want to put an alert in my indicator (I'm not yet advanced enough to start programming strategies) for a possible entry, will the alert sound repeatedly on each new OnBarUpdate() as long as the possible entry is valid?

    Can I use a static or saved variable in the indicator so that my alert will only sound once for each possible new signal, ie "alert already sent for this signal, dont do it again", and then when the possible entry is void the variabe is reset, then set again only after the next possible entry?

    Also, I have 2 questions on strategies.

    1. are there any strategy samples that I can study to understand the process?
    2. is it possible to create an interface to control a strategy? for example I may want to start/stop/pause my strategy using a button. I would also like to be able to update my strategy with support and resistance levels while it is running, so on my interface i would be able to enter a support or resistance level and 'submit' to my strategy on the fly.

    Thanks,
    Will.

    #2
    Hi dontpanic, you could designate a number # of seconds after the which the alert would be rearmed :



    There are several strategies provided per default with NT, such as the SampleMACrossover and SampleAtmStrategy which you could review for code examples.

    Another good place to start is the wizard :



    Using buttons for strategy start / pausing would unfortunately not be supported, you could enable / disable the strategy via the strategies tab as needed.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Another way to interact

      Does Ninjatrader 7 support c# shared memory? this would be a way to interact with the strategy. I want to be able to interactively give my strategy support and resistance levels without having to start and stop it.

      Are there any more complex strategy examples? I'm looking for something that will show me how to properly manage a trade, not just make the entry.

      Thanks,
      Will.

      Comment


        #4
        Hi Will, unfortunately the strategies are not designed to interact / cross communicate - some customers have found success using for example the Global Variable dll that floats around here in the forum, but we could not offer support for this area.

        For more complex trade management, please see for example :

        The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()
        BertrandNinjaTrader Customer Service

        Comment


          #5
          static variables and c# version

          Hi,

          I just tried adding into the variables section in the indicator :-

          static int counter=0;

          then incremented and printed in OnBarUpdate();

          the count works, but the initialise did not seem to. For example on a 144 tick chart the first printed value was 2645, and 1126 on a 5min chart.

          The fact that the increment works and the static value is saved is enough for me to work with, but is there a reason why it does not (appear to) initialise correctly? Also tried initialising in the Intialise() function of the indicator.

          Also, what version of c# and .NET are supported in NT7?

          Thanks again.

          Comment


            #6
            Will, NT7 would work with .NET 3.5 per default - using static variables is unfortunately not supported by us - if you would like to expose a non plotted / internal variable in an indicator please see this example we provide :

            BertrandNinjaTrader Customer Service

            Comment


              #7
              NT and WCF

              Hi,

              please ignore the below re WCF, it now compiles after importing the .dll.

              Firstly, I discovered that using static variables works. The only limitation is that each chart that uses my indicator uses the SAME static variable, so I had to create a static array and set each chart to use a different array index by creating a user input chart variable. Awkward, but it works.

              Now I'm trying use Windows Communication Foundation (WCF) to talk to my indicator. WCF is supported in .NET 3.0 and greater, so shouldn't it work in NT? I'm running into problems right from the start, since the NT compiler wont recognise the reference. I included this reference :

              using System.ServiceModel;

              The compiler says :

              The type or namespace name "ServiceModel" could not be found. Are you missing...

              Why would the compiler not recognise this?

              Thanks,
              will.
              Last edited by dontpanic; 06-23-2011, 12:03 AM. Reason: Found Answer Myself

              Comment


                #8
                Will, I'm unfortunately not familair with this DLL, have you tried adding a reference in the NinjaScript editor directly via a right click in the code?
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by llanqui, Today, 03:53 AM
                0 responses
                3 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by burtoninlondon, Today, 12:38 AM
                0 responses
                10 views
                0 likes
                Last Post burtoninlondon  
                Started by AaronKoRn, Yesterday, 09:49 PM
                0 responses
                14 views
                0 likes
                Last Post AaronKoRn  
                Started by carnitron, Yesterday, 08:42 PM
                0 responses
                11 views
                0 likes
                Last Post carnitron  
                Started by strategist007, Yesterday, 07:51 PM
                0 responses
                14 views
                0 likes
                Last Post strategist007  
                Working...
                X