Daily Highest value of an indicator

 

Hi everyone,

I am looking for the simplest code in order to get the daily Highest/Lowest value of an indicator. For example we run CCI indicator with CCI_Period=12. This indicator has many picks as lowest or highest value in a day. I am trying to get this values in order to compare it with other days values. in the below picture i pointed the highest/lowest value of an CCI indicator of yesterday and today. In order to get highest value of this indicator a wrote this code, but it is wrong, because the highest CCI value on daily chart with the same period does not give us the highest CCI value of the day. If any body could help me, please correct it.

double highestCCI;
double CurrentCCI=iCCI(Symbol(),0,12,PRICE_TYPICAL,0);
double TodayCCI=iCCI(Symbol(),1440,12,PRICE_TYPICAL,0); // i think this must be changed


if ( CurrentCCI > TodayCCI)

{

TodayCCI= CurrentCCI;

}

deVries had solve this problem and i paste his code here. It gives exactly what i needed. So you can customize the below code for your favorit indicators.

//-------------------------------------------

datetime now = iTime(Symbol(),1440,0);
datetime yesterday = iTime(Symbol(),1440, 1 );
//barshift TF 1H
int Beginnow=iBarShift(NULL, 60, now);
int Beginyesterday=iBarShift(NULL, 60, yesterday);
//................ Lowestnow=1000;//define as double Lowestnow,Highestnow,
//CurrentCCI,Lowestyesterday,Highestyesterday
Highestnow=0;
Lowestyesterday=1000;
Highestyesterday=0;
//values for today Timeframe 1H
for(i = Beginyesterday; i >= 0 ; i--)
{
CurrentCCI=iCCI(Symbol(),60,12,PRICE_TYPICAL,i);
if(i<=Beginnow)
{
if(CurrentCCI>Highestnow)Highestnow=CurrentCCI;
if(CurrentCCI<Lowestnow)Lowestnow=CurrentCCI;
}
if(i>Beginnow)
{
if(CurrentCCI>Highestyesterday)Highestyesterday=CurrentCCI;
if(CurrentCCI<Lowestyesterday)Lowestyesterday=CurrentCCI;
}
}

 

No comment?????

no body can help?

 
hmrt135:

No comment?????

no body can help?


Is this helping .....

many thanks....

 
many thanksssssssssss
 
deVries:

Is this helping .....

many thanks....


very useful....

Many thankss... ;) lol

 
RaptorUK:
many thanksssssssssss

thank you so much for your response.

""many thanksssssssssss""

P.S. All rights reserved ;)

Best regards.

 

NO MORE useless thanks in others topics.....

if you do I don't wanna help you anymore....

.

   datetime now = iTime(Symbol(),1440,0);
   datetime yesterday = iTime(Symbol(),1440,1);
   //barshift  TF 1H
   int Beginnow=iBarShift(NULL, 60, now);
   int Beginyesterday=iBarShift(NULL, 60, yesterday);
   //................
   

   Lowestnow=1000;//define as double Lowestnow,Highestnow,
                  //CurrentCCI,Lowestyesterday,Highestyesterday
   Highestnow=0;
   Lowestyesterday=1000;
   Highestyesterday=0;
   //values for today Timeframe 1H                                     
   for(i = Beginyesterday; i >= 0 ; i--)  
    {
     CurrentCCI=iCCI(Symbol(),60,12,PRICE_TYPICAL,i);
     if(i<=Beginnow)
        {
         if(CurrentCCI>Highestnow)Highestnow=CurrentCCI;
         if(CurrentCCI<Lowestnow)Lowestnow=CurrentCCI;
        } 
     if(i>Beginnow)
        {
         if(CurrentCCI>Highestyesterday)Highestyesterday=CurrentCCI;
         if(CurrentCCI<Lowestyesterday)Lowestyesterday=CurrentCCI;
        }    
    }

Think this is almost what you needed..

you can make it calculating only at newbar

CCI TF 1H can't be compared with daily value CCI

 

many thanksssssssssss

(I just violate some copyright :D)

 
deVries:

How dare you.... violating copyright

You're welcomezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz


Hi everyone,

I am looking for the simplest code in order to get the daily Highest/Lowest value of an indicator. For example we run CCI indicator with CCI_Period=12. This indicator has many picks as lowest or highest value in a day. I am trying to get this values in order to compare it with other days values. in the below picture i pointed the highest/lowest value of an CCI indicator of yesterday and today. In order to get highest value of this indicator a wrote this code, but it is wrong, because the highest CCI value on daily chart with the same period does not give us the highest CCI value of the day. If any body could help me, please correct it.

All I know is daily chart is much more slow than it's lower TF. So for example CCI in 1 hour chart may above 100 while at daily chart is still below 100.

This is script only look for the recent highest/lowest and its previous highest/lowest of CCI bar, compiled not tested.

Use your creativity to do what ever you want.

:D

  int bar, first_highest = -1, second_highest = -1, first_lowest = -1, second_lowest = -1;
  double before, current, after;   
     
  for (bar = 0; bar < Bars; bar ++)
    {
    before  = iCCI (Symbol(), Period(), 12, PRICE_TYPICAL, bar + 1);
    current = iCCI (Symbol(), Period(), 12, PRICE_TYPICAL, bar    );
    if (bar == 0)
      {
      after = iCCI (Symbol(), Period(), 12, PRICE_TYPICAL, bar    );
      }
      else
      {
      after = iCCI (Symbol(), Period(), 12, PRICE_TYPICAL, bar - 1);
      } 

    // searching for the second high if we have the first high
    if (before < current && after <= current && current >= 100 && first_highest != -1) second_highest = bar;
    // searching for the second low if we have the first low
    if (before > current && after >= current && current <= -100 && first_lowest != -1) second_lowest = bar;
    
    // get out when we have the seconds high and low
    if (second_highest != -1 && second_lowest != -1) break;
    
    // searching for the first high
    if (before < current && after <= current && current >= 100 && first_highest == -1) first_highest = bar;
    // searching for the first low
    if (before > current && after >= current && current <= -100 && first_lowest == -1) first_lowest = bar;
    }
     
   Alert ("The first highest at bar ",first_highest," and the second highest at bar ",second_highest);
   Alert ("The first lowest at bar ",first_lowest," and the second lowest at bar ",second_lowest);
 
deVries:

NO MORE useless thanks in others topics.....

if you do I don't wanna help you anymore....

.

Think this is almost what you needed..

you can make it calculating only at newbar

CCI TF 1H can't be compared with daily value CCI


thank you deVries for your notice. I think you got what i needed. So i will test it on meta trader and if it does not give me the wishes results i will ask you again.

P.s. i want to thanks only topics that some body share a useful thread. Also if you hate it i will not thank them any more. ;)
 
onewithzachy:

You're welcomezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz


All I know is daily chart is much more slow than it's lower TF. So for example CCI in 1 hour chart may above 100 while at daily chart is still below 100.

This is script only look for the recent highest/lowest and its previous highest/lowest of CCI bar, compiled not tested.

Use your creativity to do what ever you want.

:D


thank you for your response.

i test the above code from deVries and it gives the exact values what i describe as problem. I think you can customize it for your favorit indicators.

Reason: