Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Between Range

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

    Between Range

    Hey,

    I am trying to do the following.

    If price is in the range of 2 plotted points do X function else do X function EG: Plot1 1100.25 | Plot2 1200.25

    any help that you can provide would be most grateful.

    #2
    What specififically are you asking for? Syntax help?

    Code:
    if (Close[0] < value1 && Close[0] > value2)
        // Do something here
    else
        // Do something else here
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply.

      What i am after is syntax help as i am not a coder.

      What i am trying to do is make a zone of lets say 10ticks (SP500) around a SMA On a graph it would look like bands would be the easiest way to explain it.

      I don't know how to pull a value from another indicator.

      thanks

      Comment


        #4
        Hi, please see the indicator in this thread - http://www.ninjatrader-support2.com/...ad.php?t=11757

        I believe it does what you are after...

        Comment


          #5
          Thanks heaps for that

          Comment


            #6
            Originally posted by NinjaTrader_Ray View Post
            What specififically are you asking for? Syntax help?

            Code:
            if (Close[0] < value1 && Close[0] > value2)
                // Do something here
            else
                // Do something else here

            Firstly thanks for your help.

            I am getting close now. Bertrand indicator is exactly what i need but i can not work out how to code the conditions. (what i am after is between the lower and upper channel is a no trade zone)

            Code:
            Close[0] <= ConstantChannel(10, 6).Lower[0]; && Close[0] >= ConstantChannel(10, 6).Upper[0];
            This code basically does never become true as price can not be in 2 places at once so will || (or else) work? or do i have to approach it in another way?

            Comment


              #7
              Yes, you can use || for an OR statement. You need to watch out on your use of the semi colon though. You cannot have ; in the middle of your statement.

              This is what you have:
              Code:
              Close[0] <= ConstantChannel(10, 6).Lower[0][SIZE=5][B][COLOR=Red];[/COLOR][/B][/SIZE] && Close[0] >= ConstantChannel(10, 6).Upper[0][SIZE=5][COLOR=Red][B];[/B][/COLOR][/SIZE]
              This is what it should be:
              Code:
              if (Close[0] <= ConstantChannel(10, 6).Lower[0] || Close[0] >= ConstantChannel(10, 6).Upper[0])
              {
                   // Do something;
              }
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Thanks Josh,

                Question for you about bar ago option, how is it calculated? Is it from the current forming bar or the one just closed.

                | |
                ^This one

                or

                | | |
                ^ This one

                Cheers

                Comment


                  #9
                  Depends on your CalculateOnBarClose setting. If true then it starts with the most right bar. If false then it starts with the bar behind the bar that is forming.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Ok so please correct me if i am wrong.

                    with CalculateOnBarClose=true Close[0] would be the bar that just closed and Close[1] would be the bar before that.

                    Comment


                      #11
                      That is correct.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks for your help

                        Comment


                          #13
                          Is this code correct? I think it is combining the "and"s (&&) and putting them vs the "or" (||).

                          Code:
                          if (CrossAbove(EMA(5), EMA(8), 2)
                           && (CrossAbove(SMA(5), EMA(8), 2)
                           && Close[0] < ConstantChannel(10, 6).Lower[1] || Close[0] > ConstantChannel(10, 6).Upper[0]
                          I want the "or" (||) to only apply to the ConstantChannel rule, is there an easy way around this?

                          thanks in advance

                          *edit* was just tweaking it and put () around the "Close[0] < ConstantChannel(10, 6).Lower[1] || Close[0] > ConstantChannel(10, 6).Upper[0]" Line and seemed to work is this correct?
                          Last edited by cirion; 12-17-2008, 03:27 AM.

                          Comment


                            #14
                            Hi cirion,
                            Please use this code below, you missed setting the if in parenthesis...

                            Code:
                            [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] [COLOR=red]([/COLOR]CrossAbove(EMA([/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]5[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]), EMA([/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]8[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]), [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2])[/SIZE]
                            [SIZE=2]&& CrossAbove(SMA([/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]5[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]), EMA([/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]8[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]), [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2])[/SIZE]
                            [SIZE=2]&& Close[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]] < ConstantChannel([/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]10[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]6[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]).Lower[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]] || Close[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]] > ConstantChannel([/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]10[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]6[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]).Upper[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]][COLOR=red])[/COLOR][/SIZE][/SIZE]
                            Above that you will need to run your code and check if the trading logic hits home for you...

                            Comment


                              #15
                              Thanks everyone for your help it is coming along good now

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              578 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              334 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              554 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              551 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X