How to define piecewise calculation?

 

Hi folks

How can I define that an indicator begins at the start of a month an ends with the last day of the month, then starts with a new illustration for the next month.

For example:
1st of April: the maximum of the momentums (march to april) of two pairs is measured and for april the ATR of this maximum pair is shown.
1st of May: same again... maximum momentums (april to may)---> ATR of the maximum pair is shown for May

How can I do that?

Many many thanks!

Ron

 

I don't know the answer, maybe in another timeday or another timemonth i'll have the answer

int TimeDay( datetime date) 
//Returns day of month (1 - 31) for the specified date.  
int TimeMonth( datetime time) 
//Returns the month number for the specified time. 
 

i did it like that, but it isn't working (obviously i am not very experienced in programming)

start()
{
int counted_bars=IndicatorCounted();
if(Bars<=0) return(0);
if(counted_bars<1)
i=Bars-counted_bars-1;

while(i>=0)
{
if(DayOfWeek()>3)
TestBuffer1[i]=iATR("EURUSD",0,1,0);
i--;
}
return(0);
}

(its just an example)

where am i wrong?

many thanks!

ron

 
Ron12:

i did it like that, but it isn't working (obviously i am not very experienced in programming)

(its just an example)

where am i wrong?

many thanks!

ron

The first three errors are

(1) Failed to use SRC button to paste source code (which gives syntax coloring and is easier to read)

(2) Failed to post all the code

(3) Failed to state what the problem is ("it isn't working" is not a useful error report).

But you are not very experienced so we won't hold it against you :-)

Reason: