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

High Low Range Value

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

    High Low Range Value

    I am trying to define 2 variables that will hold the high and one to hold the low value of an opening range.

    I have pulled several indicators off the support forum and tried to use the code but I keep getting string and double errors when trying to use math calculations

    Basically I would like code to accomplish this

    Capturing High and Low value for the first 15 minute open. 9.30am - 9.45am

    Entering above High value

    Target = High + (High - Low) - basically 100% extention

    The main questions is how to I define the variable so it is useable in math equations.


    thanks for any help

    Stefan

    #2
    Stefan, do you have an example of what you tried to compile but wasn't accepted?

    If you work with a series return, you would need to request a for example a single double return value from it and use in your math operations - i.e.

    double myTarget = High[0] + (High[0] - Low[0])
    BertrandNinjaTrader Customer Service

    Comment


      #3
      because I haven't figured out the logic to capture the 15 minute open high and low yet

      what I did was import a high low indicator from the download section. The one I am using is BzvOpeningRange4

      I used the condition wizard to generate an entry condition using the indicator where the price breaks the Low of the time period. This entry works

      I thought from there I could add my own exit directly in the code which is where I am generating the error.

      My assumtion (not being a programmer) is that the variable from the indicator is a string

      Here is what I was trying - this is actually a short entry not a long off the high

      I put the code in the next post

      Comment


        #4
        protectedoverridevoid OnBarUpdate()
        {
        double LowValue = (BzvOpeningRange4("0330", "0430", "1000").RangeLowSeries)[0];

        double HighValue = (BzvOpeningRange4("0330", "0430", "1000").RangeHighSeries)[0];

        double Spread =((BzvOpeningRange4("0330", "0430", "1000").RangeHighSeries)[0] - (BzvOpeningRange4("0330", "0430", "1000").RangeLowSeries)[0]);
        double target = LowValue - Spread;
        double stop = LowValue + Spread;


        Comment


          #5
          code #2

          Sorry I had to put it in 2 posts it was too long

          // Condition set 1 - this entry works
          if (CrossBelow(Low, BzvOpeningRange4("0330", "0430", "1000").RangeLowSeries,1)
          && ToTime(Time[0]) > ToTime(4, 30, 0)
          && ToTime(Time[
          0]) < ToTime(6, 0, 0))
          {
          EnterShort(DefaultQuantity,
          "BreakOutShort");
          }
          // Condition set 2
          if (Low[0] <= target)
          {
          ExitShort(
          "Target", "");
          }
          // Condition set 3
          if (High[0] > stop)
          {
          ExitShort(
          "Stop", "");
          }

          Comment


            #6
            Originally posted by delta20 View Post
            Sorry I had to put it in 2 posts it was too long

            // Condition set 1 - this entry works
            if (CrossBelow(Low, BzvOpeningRange4("0330", "0430", "1000").RangeLowSeries,1)
            && ToTime(Time[0]) > ToTime(4, 30, 0)
            && ToTime(Time[
            0]) < ToTime(6, 0, 0))
            {
            EnterShort(DefaultQuantity,
            "BreakOutShort");
            }
            // Condition set 2
            if (Low[0] <= target)
            {
            ExitShort(
            "Target", "");
            }
            // Condition set 3
            if (High[0] > stop)
            {
            ExitShort(
            "Stop", "");
            }
            And what is the error message that you are getting?

            Comment


              #7
              Thank you

              That is really weird I went and compiled it to get the error and it is working.

              Previously I was getting an error something like "cannot perform functions such as + on strings or doubles"

              Since I can't reproduce it that is the best of my memory.

              I guess it is like getting better while you are waiting for the doctor.


              sorry if I wasted your time

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Waxavi, Today, 02:10 AM
              1 response
              16 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by Kaledus, Today, 01:29 PM
              5 responses
              13 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Waxavi, Today, 02:00 AM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by alifarahani, Today, 09:40 AM
              5 responses
              23 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by gentlebenthebear, Today, 01:30 AM
              3 responses
              17 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X