• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 7:22am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 7:22am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Highest Open / Lowest Open Trade 17,608 replies

As complicated as necessary: Highest Open / Lowest Open Trade 858 replies

Seeking Help for Open & Close Trades On New Bar Open 6 replies

ECN && STP && Scalping && Hedging - Broker Review - Oct 2009 24 replies

Open & Close advantage in spreadbetting firms 3 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
Tags: Highest & Lowest Open/Close Price for a Loop
Cancel

Highest & Lowest Open/Close Price for a Loop

  • Post #1
  • Quote
  • First Post: Aug 12, 2021 9:41am Aug 12, 2021 9:41am
  •  chimoong
  • | Joined May 2016 | Status: Member | 245 Posts
Hi coders, could you please advise and provide your coding solution. I can get the highest Open/Close prices but I cannot get the lowest Open/Close prices for the loops.

Inserted Code
   double tMxOC=0;
   for(int i=20; i>=1; i--)
   {
      double mxOC=MathMax(iOpen(Symbol(),60,i),iClose(Symbol(),60,i));
      if(mxOC>=tMxOC) {
      tMxOC=mxOC;
      }
   }
 
   {Alert(Symbol()+" Highest OC Price : "+DoubleToStr(tMxOC,5)); }
 
// This loop works and the highest Open/Close Prices are shown
 
//+------------------------------------------------------------------+
   double tMnOC=0;
   for(int i=20; i>=1; i--)
   {
      double mnOC=MathMin(iOpen(Symbol(),60,i),iClose(Symbol(),60,i));
      if(mnOC<=tMnOC) {
      tMnOC=mnOC;
      }
   }

   {Alert(Symbol()+" Lowest OC Price : "+DoubleToStr(tMnOC,5)); }
 
// This loop is NOT working and the lowest Open/Close Prices are shown "0", no price at all.

Kindly help, thanks
  • Post #2
  • Quote
  • Aug 12, 2021 10:46am Aug 12, 2021 10:46am
  •  Jagg
  • Joined Oct 2006 | Status: Member | 533 Posts
You have to initialize tMnOc with DBL_MAX (or a high digit like 999999) not with 0.
 
 
  • Post #3
  • Quote
  • Aug 12, 2021 10:53am Aug 12, 2021 10:53am
  •  chimoong
  • | Joined May 2016 | Status: Member | 245 Posts
Quoting Jagg
Disliked
You have to initialize tMnOc with DBL_MAX (or a high digit like 999999) not with 0.
Ignored
Thanks Jagg, you're right, brilliant, appreciated.

Inserted Code
   double tMnOC=99999999;
   for(int i=20; i>=1; i--)
   {
      double mnOC=MathMin(iOpen(Symbol(),60,i),iClose(Symbol(),60,i));
      if(mnOC<=tMnOC) {
      tMnOC=mnOC;
      }
   }
 
   {Alert(Symbol()+" Lowest OC Price : "+DoubleToStr(tMnOC,5)); }
 
 
  • Post #4
  • Quote
  • Last Post: Apr 24, 2023 8:32am Apr 24, 2023 8:32am
  •  TooSlow
  • Joined Mar 2012 | Status: Trader | 12,067 Posts
May I suggest you use iHighest and iLowest. No need for a loop.

Cheers.
My Threads: Trading is as simple as 1-2-3, Highest Open / Lowest Open Trade
 
 
  • Platform Tech
  • /
  • Highest & Lowest Open/Close Price for a Loop
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023