Monthly High Low Exploration

Status
Not open for further replies.

amitrandive

Well-Known Member
#1
Dear All

I need an all Monthly high low exploration.
It should progressively put "Yes" after hitting a new month high every month.

At the time it hits 12 Month high it should show all the earlier columns as filled

Please see image to understand



Started with these lines

Code:
Mth  = Param("Month", 1, 1, 12);
MH1 =High>Ref(HHV(High,Mth),-1);
ML1= Low  < Ref(LLV(Low,Mth),-1);
Filter=MH1 OR ML1;
 

trash

Well-Known Member
#3
What's the problem? It's just a few lines of code.

You have numbered columns with increment of 1.
So what do we use? Right, we use loop.

Code:
for( i = 1; i < 13; i++ ) { // loop from month 1 to month 12
....
}
i++ means i = i+1 so we iterate from 1 to 12 with increment of 1 -> 1, 2, 3, ..., 12

So how to set variables such as MH1, MH2, MH3, ... , MH12 in such loop ?

We use VarSet() for that

Code:
for( i = 1; i < 13; i++ ) {
    // HHV variables
    VarSet( .... );
    // LLVV variables
    VarSet( .... );
}
How do we call them after setting them? Right. Loop again.

Code:
if( Interval() == 2160001 ) { // output in Monthly TF
	// High vars columns
	for( i = 1; i < 13; i++ ) {
		Hcond = H > VarGet( .... );
		AddColumn( .... );
	}
        //
	// space column
	AddTextColumn( "", "", 1, colorGrey50, colorGrey50, 5 );
	//
	// Low vars columns
	for( i = 1; i < 13; i++ ) {
		Lcond = L < VarGet( .... );
		AddColumn( ... );
	}
} else // show error if Monthly TF is not set
	Error( "Set to monthly time frame" );
Filter?

Code:
// filter at last bar 
Filter = (H > MH1 OR L < ML1) AND Status( "lastbarinrange" );
NOTE: you need to fill in missing info in upper incomplete codes yourself. So happy easy coding

Result

 

amitrandive

Well-Known Member
#4
What's the problem? It's just a few lines of code.

You have numbered columns with increment of 1.
So what do we use? Right, we use loop.

Code:
for( i = 1; i < 13; i++ ) { // loop from month 1 to month 12
....
}
i++ means i = i+1 so we iterate from 1 to 12 with increment of 1 -> 1, 2, 3, ..., 12

So how to set variables such as MH1, MH2, MH3, ... , MH12 in such loop ?

We use VarSet() for that

Code:
for( i = 1; i < 13; i++ ) {
    // HHV variables
    VarSet( .... );
    // LLVV variables
    VarSet( .... );
}
How do we call them after setting them? Right. Loop again.

Code:
if( Interval() == 2160001 ) { // output in Monthly TF
	// High vars columns
	for( i = 1; i < 13; i++ ) {
		Hcond = H > VarGet( .... );
		AddColumn( .... );
	}
        //
	// space column
	AddTextColumn( "", "", 1, colorGrey50, colorGrey50, 5 );
	//
	// Low vars columns
	for( i = 1; i < 13; i++ ) {
		Lcond = L < VarGet( .... );
		AddColumn( ... );
	}
} else // show error if Monthly TF is not set
	Error( "Set to monthly time frame" );
Filter?

Code:
// filter at last bar 
Filter = (H > MH1 OR L < ML1) AND Status( "lastbarinrange" );
NOTE: you need to fill in missing info in upper incomplete codes yourself. So happy easy coding

Result

Thanks trash

Will complete the code and paste it here after done.

:thumb:
 

amitrandive

Well-Known Member
#6
Why would you repost a code that is already posted in post #3?? It's already there and laid out on a silver plate.
Yes, since I am from a non programming background , tried to fill in the blanks ,but was unsuccessful so far.

Still struggling :(

Would appreciate help from an expert.

Tried to define the VarSet ,but something went wrong and messed up all the indicators present
 
Last edited:

jagankris

Well-Known Member
#8
Yes, since I am from a non programming background , tried to fill in the blanks ,but was unsuccessful so far.

Still struggling :(

Would appreciate help from an expert.

Tried to define the VarSet ,but something went wrong and messed up all the indicators present
I appreciate your interest to learn ami programming.
Check if this is helpful.

_SECTION_BEGIN("MonthlyHighExploration");

SetChartOptions( 0, chartShowArrows | chartShowDates );
TimeFrameSet( inMonthly );
j=13;
i=0;
for( i = 1; i < 13; i++ )
{
VarSet( "M"+i+"H", Ref( H, -j ) );
J--;
}

j=2;
for( i = 1; i < 13; i++ )
{
VarSet( "M"+i+"High", IIf(VarGet("M"+j+"H") > VarGet("M"+i+"H"),1,0) );
j++;
}

Filter = 1 AND Status("lastbarinrange"); ;
for( i = 1; i < 13; i++ )
{
AddTextColumn(NumToStr(VarGet("M"+i+"High")), "M"+i+"High", 1.2,colorBlack,colorGrey50,-1);
}
_SECTION_END();
 
Last edited:

amitrandive

Well-Known Member
#10
I appreciate your interest to learn ami programming.
Check if this is helpful.

_SECTION_BEGIN("MonthlyHighExploration");

SetChartOptions( 0, chartShowArrows | chartShowDates );
TimeFrameSet( inMonthly );
j=13;
i=0;
for( i = 1; i < j; i++ )
{
VarSet( "M"+i+"H", Ref( H, -j ) );
J--;
}

j=2;
for( i = 1; i < 13; i++ )
{
VarSet( "M"+i+"High", IIf(VarGet("M"+j+"H") > VarGet("M"+i+"H"),1,0) );
j++;
}

Filter = 1 AND Status("lastbarinrange"); ;
for( i = 1; i < 13; i++ )
{
AddTextColumn(NumToStr(VarGet("M"+i+"High")), "M"+i+"High", 1.2,colorBlack,colorGrey50,-1);
}
_SECTION_END();
Jagan

Thanks for the code ,

A few queries ,if that is not too demanding

Check the image below , if the Ambujacem stock is making a 3 ,4,5 month high ,it will surely make a 1 and 2 monthly high.

For Axis bank,if it makes a 1,3,4 month high ,it must surely make a 2 month high.

Also would be better if this code also does past days scanning.
Currently it scans only for the last day available.

 
Status
Not open for further replies.

Similar threads