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

Getting same error

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

    Getting same error

    I keep getting the same error, I read the help but I don't understand what I am doing wrong. Can someone please help, thanks.

    I want to plot the high and low for the last 24 bar with an inner high line 20 pips below the high and an inner low line 20 pips above the low. Then I want to create a true false so I can create an alert in market analyzer if any of the following conditions is true,

    1. the high of the previous bar crossed the inner high line,
    2. the high of the previous bar crossed the high line,
    3. the low of the previous bar crossed the inner low line,
    4. the low of the previous bar crossed the low line,

    5. the high of the previous bar crossed above the inner high line and current bar closes down,
    6. the high of the previous bar crossed above the high line and current bar closes down,
    7. the low of the previous bar crossed below the inner low line and current bar closes up,
    8. the low of the previous bar crossed below the low line and current bar closes up.

    1 to 4 are the setup and 5 to 8 is the confirmation.
    Attached Files

    #2
    Code for last post part 1

    protectedoverridevoid OnBarUpdate()
    {
    RHigh.Set(HighestBar(High, 24)[0]);
    RLow.Set(LowestBar(Low, 24)[0]);
    InnerHigh.Set(HighestBar(High, 24)[0]-20/10000);
    InnerLow.Set(LowestBar(Low, 24)[0]+20/10000);

    Plot0.Set( (

    (CrossAbove(High, HighestBar(High, 24), 1)) ||
    (CrossAbove(High, HighestBar(High, 24)-20/10000, 1)) ||
    (CrossBelow(Low, LowestBar(Low, 24), 1)) ||
    (CrossBelow(Low, LowestBar(Low, 24)+20/10000, 1)) ||

    (CrossAbove(High, HighestBar(High, 24), 1) && Close[0] < Open[0]) ||
    (CrossAbove(High, HighestBar(High, 24)-20/10000, 1) && Close[0] < Open[0]) ||
    (CrossBelow(Low, LowestBar(Low, 24), 1) && Close[0] > Open[0]) ||
    (CrossBelow(Low, LowestBar(Low, 24)+20/10000, 1) && Close[0] > Open[0])

    ) ? 1 : 0);

    }

    Comment


      #3
      Code for last post part 2

      #region Variables
      privateint myInput0 = 1; // Default setting for MyInput0
      #endregion
      protectedoverridevoid Initialize()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "RHigh"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "RLow"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Hash, "InnerHigh"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Hash, "InnerLow"));
      Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
      CalculateOnBarClose = true;
      Overlay = true;
      PriceTypeSupported = false;
      }

      Comment


        #4
        anyone know a better way to post this crap?

        Comment


          #5
          Thanks for any help.

          Comment


            #6
            Sorry, 1 to 4 should be the current bar, not prior bar.

            Comment


              #7
              Sorry forgot the text file. Thanks.
              Attached Files

              Comment


                #8
                It works except for the inner high line and the inner low line are not plotting. For these to plot correctly, on line 25 I am trying to make the instrument point value to be a parameter, e.g. 100 for JPY pairs and 10000 for other pairs. The point value is declared as an integer called "iValue" and the formula is using "-(20/iValue)" on line 51 and "+(20/iValue)" on line 53, but it is not plotting the lines. If I hard key "+0.20" and "-0.20", then the lines plot correctly for JPY pairs. If iValue is equal to 100, then I am not sure why "(20/iValue)" would not return "0.20". I would appreciate any help, thanks.
                Attached Files

                Comment


                  #9
                  vegasfoster, sorry for the late reply here from us.

                  Please print out the values you calculate to check if your logic to automatically calculate those hits home as you would expect.

                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Thanks for getting back to me. So I did that, but the output window is simply showing that it isn't adding or subtracting the "(20/iValue)", it isn't telling me why I can't divide 20 by the parameter that I created and add or substract it to another figure.

                    I kept searching and finally found the following thread



                    After changing the 20 to 20.0, it works.

                    Comment


                      #11
                      Great it works, probably needed to be double value since you set a double value to plot and also add to a double value...
                      BertrandNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by algospoke, Yesterday, 06:40 PM
                      2 responses
                      19 views
                      0 likes
                      Last Post algospoke  
                      Started by ghoul, Today, 06:02 PM
                      3 responses
                      14 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Started by jeronymite, 04-12-2024, 04:26 PM
                      3 responses
                      45 views
                      0 likes
                      Last Post jeronymite  
                      Started by Barry Milan, Yesterday, 10:35 PM
                      7 responses
                      20 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Started by AttiM, 02-14-2024, 05:20 PM
                      10 responses
                      181 views
                      0 likes
                      Last Post jeronymite  
                      Working...
                      X