Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Marking Medium term High which is greater than previous and next short term High

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

    Marking Medium term High which is greater than previous and next short term High


    I don't know much of programming. I am trying to mark medium term high on the chart which is higher than previous short term high and next short term high.
    Short term high is high which is higher than previous 2 highs as well as next to highs.
    I am able to mark short term highs on the chart using following formula (screen shot attached)
    protected override void OnBarUpdate()
    {
    if (CurrentBar < 10)
    return;
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.

    if(High[0] > High[1] && High[0] > High[2] && High[0] > High[-1] && High[0] > High[-2])

    DrawArrowDown(CurrentBar.ToString(), true, 0, High[0] + TickSize, Color.Red);

    if (Low[0] < Low[1] && Low[0] < Low[2] && Low[0] < Low[-1] && Low[0] < Low[-2])

    DrawArrowUp(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Green);

    (This also gives short term lows similar ways)

    But I am not able to mark medium term high. I tried different ways but it does not work.
    Medium term High is a HIGH greater than previous short term high and greater than next short term high as well (middle out of 3 short term high which is highest)
    I was able to do in other platform where "valuewhen" function is allowed
    j = valuewhen (b, high, 2) where j is double and b bool. b = High[0] and (High[0] > High[1] && High[0] > High[2] && High[0] > High[-1] && High[0] > High[-2])
    I am not able to do this in Ninjatrader (recently started using Ninja trader and love it)
    screen shot attached
    Attached Files

    #2
    Hello baqer110,

    Attached is a basic example of checking for the middle High between two Highs as defined by your short term Highs above. This same idea can be applied to check for the middle Low between two Lows as defined by your short term Lows.

    Please let me know if you have any questions.
    Attached Files

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello baqer110,

      Attached is a basic example of checking for the middle High between two Highs as defined by your short term Highs above. This same idea can be applied to check for the middle Low between two Lows as defined by your short term Lows.

      Please let me know if you have any questions.
      Thanks a lot . I do appreciate your valuable time
      I imported the script you sent me to NT and applied to the chart. It's not plotting anything. No compilation error. I am studying the code and trying to figure out.
      Can you please apply this at your end and tell me whether it works?
      Once again I do appreciate your valuable time

      Comment


        #4
        I created a video on this example that I created at the following link: http://screencast.com/t/sXjXhCuImk6

        As mentioned in the video, it is a simple example and is not the full code you need. Also, my condition may not be what you need. I would recommend reviewing and understanding how the Loops pull the values, reviewing for loops, and implementing this. You can also consider a developer, and our affiliate NinjaTrader Ecosystem does partner with NinjaScript consultants.

        For information on for loops please visit the following link: https://msdn.microsoft.com/en-us/library/ch45axte.aspx

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,233 views
        0 likes
        Last Post sidlercom80  
        Started by thread, Yesterday, 11:58 PM
        0 responses
        1 view
        0 likes
        Last Post thread
        by thread
         
        Started by jclose, Yesterday, 09:37 PM
        0 responses
        6 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,414 views
        0 likes
        Last Post Traderontheroad  
        Started by firefoxforum12, Yesterday, 08:53 PM
        0 responses
        11 views
        0 likes
        Last Post firefoxforum12  
        Working...
        X