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

Problems with a High formula set

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

    Problems with a High formula set

    Hi!

    I want to go short when the previous High[1] more than 16 Highs in a row.
    I tried many times, however all the time I have a error.
    Please help me to fix this issue

    if( High[1] > High[2] ...High[21] )
    {
    EnterShortLimit(GetCurrentBid(), "Short");
    Print(Time[0]+" Sell");
    }

    #2
    Originally posted by olres7 View Post
    Hi!

    I want to go short when the previous High[1] more than 16 Highs in a row.
    I tried many times, however all the time I have a error.
    Please help me to fix this issue

    if( High[1] > High[2] ...High[21] )
    {
    EnterShortLimit(GetCurrentBid(), "Short");
    Print(Time[0]+" Sell");
    }
    Expand the if statement so that we can see what you have written.

    Comment


      #3
      if( High[1]>High[2] &&
      High[1]>High[3] &&
      High[1]>High[4] &&
      High[1]>High[5] &&
      ...
      High[1]>High[21] &&
      High[1] - Low[1] <1
      {
      EnterShortLimit(GetCurrentBid(), "Short");
      Print(Time[0]+" Sell");
      }

      However this formula doesn't work right. It doesn't go short whenever previous high higher than 21 highs and the range between high and low less than 1 point
      Last edited by olres7; 09-12-2015, 10:11 PM.

      Comment


        #4
        So what is the error?

        Comment


          #5
          Hello olres7,

          Thank you for your post.

          As sledge asked, what is the full error you receive?

          Comment


            #6
            Reply

            I am making a program of sell short conditions.

            It go short whenever previous bar high[1] higher than 21 highs in a row and difference between previous high[1] and low[1] less than 2 points

            protected override void Initialize()
            {
            CalculateOnBarClose = true;
            SetStopLoss("", CalculationMode.Ticks, 4, false);
            SetProfitTarget("", CalculationMode.Ticks, 15);

            }

            protected override void OnBarUpdate()
            {

            if(

            //First Condition - Previous High[1] Higher than 21 highs
            High[1]>High[2] &&
            High[1]>High[3] &&
            High[1]>High[4] &&
            High[1]>High[5] &&
            High[1]>High[6] &&
            High[1]>High[7] &&
            High[1]>High[8] &&
            High[1]>High[9] &&
            High[1]>High[10] &&
            High[1]>High[11] &&
            High[1]>High[12] &&
            High[1]>High[13] &&
            High[1]>High[14] &&
            High[1]>High[15] &&
            High[1]>High[16] &&
            High[1]>High[17] &&
            High[1]>High[18] &&
            High[1]>High[19] &&
            High[1]>High[20] &&
            High[1]>High[21] &&

            //Second Condition - Difference between previous High[1] - Low[1] <2 points
            High[1] - Low[1] <2)
            {
            // Go short when 2 conditoins are true
            EnterShortLimit(GetCurrentBid(), "Short");
            Print(Time[0]+" Sell");
            }

            }//End OnBarUpdate

            Even it complies correct however it doesn't give me correct results. It doesn't go short when the previous high higher than 21 highs and the difference between high and low lower than 2 points.

            It go short on a completely wrong price
            Please help me to fix this issue
            Last edited by olres7; 09-13-2015, 11:59 AM.

            Comment


              #7
              Code:
              High[1] - Low[1] <2
              Just to say very quickly that you need to generalise this to whatever market you trade. (2 in the ES isn't the same as 2 in EUR/USD).

              Suggest you change this to:

              Code:
              High[1] - Low[1] <2 * TickSize
              Last edited by arbuthnot; 09-13-2015, 02:11 PM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              3 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Working...
              X