Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to hold a position for half hour?

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

    How to hold a position for half hour?

    I would like to hold a position for half hour at least half hour, how to do that?

    Thanks
    Last edited by Jenny; 10-11-2007, 01:53 PM.

    #2
    Hi Jenny,

    If you are working with the Condition Builder please review the information at the following link regarding time comparisons - http://www.ninjatrader-support.com/H...mparisons.html

    If you are coding it in the NinjaScript Editor please see the following reference sample - http://www.ninjatrader-support.com/v...ead.php?t=3226

    You can also work with the BarsSinceEntry() method to determine how many bars have elapsed.
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks for your fast respone.
      Take care

      Comment


        #4
        "BarsSinceEntry()" is a very good, do you have others "BarsSince...." , like
        BarsSinceCrossAbove(SMA(
        5), SMA(10))?
        Thanks

        Comment


          #5
          You could try MRO.

          RayNinjaTrader Customer Service

          Comment


            #6
            MRO is very cool, but the first one works, the second one doesn't work.
            LowBar1 =MRO(delegate {return (CrossBelow(SMA(5), SMA(10), 1));},1, 1440) return some number, but
            HighBar1 =MRO(delegate {return (CrossBelow(SMA(5), SMA(10), 1));},2, 1440); return nothing, even not a "-1".

            Would you please tell me why?

            Thanks
            Last edited by Jenny; 10-23-2007, 04:14 PM.

            Comment


              #7
              If you mean that it does not work in that it only returns a value of -1, then likely the condition is never met. You will likely spend some time debugging to understand what is happening.

              If it does not work in terms of throwing exception (error message in the log tab of the Control Center window) then let me know.

              Here is some information to help you debug. http://www.ninjatrader-support.com/v...ead.php?t=3418
              RayNinjaTrader Customer Service

              Comment


                #8
                I already use debug, it return nothing, even not "-1". If never met the condition, it should return "-1". And I can see the condition is met by the chart. Within 1440 bar, SMA(5) Cross over SMA(10) hundreds times! Do you think there is a bug some where?

                Thanks

                Comment


                  #9
                  Are you getting any errors in your logs?
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    No error either. Can you do some test in your side?
                    Thanks
                    Last edited by Jenny; 10-23-2007, 08:02 PM.

                    Comment


                      #11
                      Sure Jenny.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        After some tests there is nothing wrong with the MRO. Please check out the reference sample I've attached. Try running it on your end. You should see two plots like how it looks in the attached image.

                        I suspect it to be a bug in your code somewhere since there seems to be no issue with this simple-as-possible indicator using MRO.

                        To install the reference sample please follow these steps:
                        1. Download the file contained in this thread to your PC desktop
                        2. From the Control Center window, select the menu File > Utilities > Import NinjaScript
                        3. Select the downloaded file
                        Attached Files
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks for your sample. It looks work in the indicator, but how come when I try to use it in my Strategy, it doesn't work.:
                          HighBar1 =MRO(delegate {return (CrossBelow(SMA(5), SMA(10), 1));},2, 1440);

                          Take care

                          Comment


                            #14
                            In the indicator I used your exact line of code. You are going to need to debug your code to see where it is failing. I suspect you probably placed the line within an if statement that is never executed. Thus causing your HighBar1 to never be set.
                            Josh P.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            597 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            343 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            103 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            556 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            555 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X