Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help Plotting highs and lows to trade around them

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

    Help Plotting highs and lows to trade around them

    Hello,

    I have a quick help request.

    This is very simple, I need to plot the highest bar and the lowest bar from a particular time set and set up a strategy to trade those levels.

    I use multiple products so I need something that I can just say something like, plot the high between 7 am to 9 am and the low between 5 am and 9 am in ES, and then be able to get a strategy to buy/sell if the price crosses above or below those plots. I found a couple of indicators that plot similar things but they are way to complicated to make into a strategy, I would really appreciate if you guys can give me a much needed hand.

    Thanks so much!!

    #2
    Hello EminiJalapenio,

    Thank you for your patience.

    You can use the code listed below:
    Code:
            #region Variables
            private int hiBar = 0;
    		private int loBar = 0;
    		private bool hiBool = true;
    		private bool loBool = false;
            #endregion
    
            /// <summary>
            /// This method is used to configure the indicator and is called once before any bar data is loaded.
            /// </summary>
            protected override void Initialize()
            {
                
                Overlay				= true;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                if(ToTime(Time[0]) >= ToTime(7,0,0)
    				&& hiBool)
    			{
    				hiBar = CurrentBar;
    				hiBool = false;
    			}
    			if(ToTime(Time[0]) >= ToTime(5,0,0)
    				&& loBool)
    			{
    				loBar = CurrentBar;
    				loBool = false;
    			}
    			
    			 if (ToTime(Time[0]) > ToTime(7,0,0) && ToTime(Time[0]) < ToTime(9,0,0) )
    			{
    				int barsAgo = CurrentBar - hiBar;
                    DrawHorizontalLine( "hi" , MAX(High,  barsAgo)[ 0], Color.Black);
    			}
    			
    			 if (ToTime(Time[0]) > ToTime(5,0,0) && ToTime(Time[0]) < ToTime(9,0,0) )
    			{
    				int barsAgo = CurrentBar - loBar;
                    DrawHorizontalLine( "lo" , MIN(Low,  barsAgo)[ 0], Color.Black);
    			}
    			
    			if(ToTime(Time[0]) >= ToTime(9,0,0))
    			{
    				hiBool = true;
    				loBool = true;
    			}
            }

    Comment


      #3
      Awesome! thank you!!!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      32 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      127 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      182 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      94 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      138 views
      0 likes
      Last Post cmoran13  
      Working...
      X