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 burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      14 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      14 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,983 views
      3 likes
      Last Post jhudas88  
      Working...
      X