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

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, 08: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 love2code2trade, 04-17-2024, 01:45 PM
                        4 responses
                        31 views
                        0 likes
                        Last Post love2code2trade  
                        Started by cls71, Today, 04:45 AM
                        2 responses
                        10 views
                        0 likes
                        Last Post eDanny
                        by eDanny
                         
                        Started by proptrade13, Today, 11:06 AM
                        0 responses
                        2 views
                        0 likes
                        Last Post proptrade13  
                        Started by kulwinder73, Today, 10:31 AM
                        1 response
                        10 views
                        0 likes
                        Last Post NinjaTrader_Erick  
                        Started by RookieTrader, Today, 09:37 AM
                        3 responses
                        15 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Working...
                        X