Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

New high/low signals?

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

    New high/low signals?

    Hi,

    I just downloaded the 6.5 Beta. Is there a way to use either the "OnMarketData" or "OnPositionUpdate" to signal changes in highs/lows...I'd like to be able to reset/change a StopLoss based on new prices for these parameters, thus enabling a more "sensitive" dynamic instead of waiting for "bar closes". Thanks in advance.

    #2
    OnMarketData() will give you all level 1 market data events. It will not give you new high/low events on a bar basis.
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks. According to the manual it will give "last price" information, thus I suppose it could be used simply to compare if the last price was a new high/low then, correct?

      Comment


        #4
        You could have an internal double variable to store the highest and lowest price seen and compare each incoming last price event to these numbers.
        RayNinjaTrader Customer Service

        Comment


          #5
          Thank you.

          Comment


            #6
            Hi again,

            Would the following code logic be acceptable?:

            protected override void OnMarketData(MarketDataEventArgs e)
            {
            if(e.MarketDataType == MarketDataType.Last)
            {
            if(MarketDataType.Last <= Low[0]){LOW_VAL = MarketDataType.Last;} //new low reached
            if(MarketDataType.Last >= High[0]){HI_VAL = MarketDataType.Last;} //new high reached
            }
            }

            Comment


              #7
              No since you can not guarantee that the low/high of the current bar is seen before or after the OnMarketData throws the event. If you want to monitor new highs/lows in the strategy, set CalculateOnBarClose to false and then you get each and every tick and then monitor the close price to see if its the current bar high or low etc...
              RayNinjaTrader Customer Service

              Comment


                #8
                But I thought that "OnMarketData" does update on each tick...wouldn't it have to in order to catch each price change?

                I was under the impression that the "OnMarketData" method was a way to get tick-by-tick data within a strategy using "calculate on bar close" within the "OnBarUpdate" method...
                Last edited by Burga1; 12-17-2007, 07:32 PM.

                Comment


                  #9
                  Yes to all of your questions however, what you want to do is best accomplished in the manner in which I stated. Don't make it more complex than it needs to be. If you intermix checking data between OnMarketData and OnBarUpdate you may run into race conditions since their is not guarantee in in which order the events are triggered although most of the time OnBarUpdate for last changed price will fire before OnMarketData.
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    I have a condition within the "OnBarUpdate" that is dependent on "calculate on bar close"...because of this I didn't want to have to disable the bar close requirement.

                    I can accomplish what I desire by using the "Close" instead of "high/low" however this is an incomplete solution that results in unacceptable strategy performance...

                    I would have thought it possible to use the "calculate on bar close" requirement while at the same time simply checking for high's and low's on a tick-by-tick basis...

                    Comment


                      #11
                      Might it be possible to use certain commands, perhaps the "GetBar" and/or the commands relating to date/time to possibly "simulate" a calculate on bar close requirement?

                      Comment


                        #12
                        What you can try is to use FirstTickOfBar and then when you reference dataseries values reference them 1 bar ago. This isn't precisely an equivalent to CalculateOnBarClose, but I think it might suffice?
                        Josh P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by timmbbo, 01-08-2020, 08:09 PM
                        3 responses
                        395 views
                        0 likes
                        Last Post bltdavid  
                        Started by ntbone, Today, 02:30 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post ntbone
                        by ntbone
                         
                        Started by tuliomgui, Yesterday, 10:07 PM
                        3 responses
                        13 views
                        0 likes
                        Last Post NinjaTrader_ShawnB  
                        Started by Learner Trader, Today, 08:36 AM
                        1 response
                        24 views
                        0 likes
                        Last Post NinjaTrader_ShawnB  
                        Started by GeorgeW, Today, 03:15 AM
                        1 response
                        16 views
                        0 likes
                        Last Post NinjaTrader_ShawnB  
                        Working...
                        X