Monthly High Low Exploration

Status
Not open for further replies.

amitrandive

Well-Known Member
#21
I need an all Monthly high low exploration.
It could be interpreted in 2 ways.

My understanding of the above stated requirement is

Case 1
I need an "all" Monthly high low exploration for the past 12 months.

Explore all the monthly highs/lows if a stock makes new monthly high it should put 1 else 0.

And

Case 2
It is different if the stated requirement is
to explore
I need an "all Monthly(all time) high low "" exploration.
ie all the stocks that are making new all time highs month on month with in the past 12 months.
Similarly for Lows.


And my code is intended for the first.



.
Jagan

Apologise if I did not state the requirement correctly.

Now your well explained Case:2 fulfills my requirement.
:D
 

jahan

Well-Known Member
#22
I praise the effort being put in by jagankris and the way amit is handling this thread.

I find the posts of trash to be offensive and low standard :annoyed:

He might be a super expert programmer having great skills, but the way he has replied in this thread is real bad.

jagankris bro, please do not be offended by his reply. For every single guy like him, there would be ten other guys who would praise the efforts put in by you to help in a polite manner.

With my best regards
Yes i agree with u....

he is a great programmer...,his words sometimes below the lowest standard.

may be he is thinking, that he is the one who knows how to teach coding,if someone interferes he get's angry( may be).

Regards,
 

jagankris

Well-Known Member
#24
Jagan

Apologise if I did not state the requirement correctly.

Now your well explained Case:2 fulfills my requirement.
:D
No need to apologize Amit.It happens.
M12H - Refers to the previous 12th Month High - M11H - Previous 11Th Month High and so on.M1H - Refers to the 1st Month High.

_SECTION_BEGIN("MonthlyHighExploration");

//The Code is expected to pick the previous 12 months highs and compare with the historical highs for the
//data available.
//if a New all time High is made it will have value 1 else 0.
//For example M12High means - the previous 12th month high is a new high compared to the highs before from the first candle data available till the 12th month.
//M11High - Previous 11 th month high is a new high new high compared to the highs before from the first candle data available till the 11th month and also > M12High.
//M5H will check - all data prior to the previous 5th Month High.
//and so on
//If M11High is not a new high - it will have 0 else 1.
//


TimeFrameSet( inMonthly );
Counter = 0;
NFlag = 0;
BC = BarCount;
HH = 0;
HH = HHV(H,BC);
//Check if NewHigh is with in the last 12 months
M12HH = HHV(H,12);

NFlag = StrToNum(WriteIf(M12HH >= HH,"1","0"));

AddColumn(BC,"BC");
//If Highest is with in the last 12 months
if (NFlag > 0 AND BC >= 3)
{

//For each of the last tweleve bars set the high values in the variable M1H,M2H,M3H .....

for(i=0;i<12;i++)
{
VarSet("M"+i+"H",Ref(H,-i));
}
x = 0;
for(k=0;k<12;k++)
{

Temp = VarGet("M"+k+"H");

Counter = 0;
for(i=BC-1;i>k;i--)
{
zArray = 0;
zArray = Ref(High,-i);
NullFlag = StrToNum(WriteIf((IsNull(Temp) < 1) AND (IsNull(zArray) < 1),"1","0"));
if (NullFlag == 1)
{
Counter = Counter + StrToNum(WriteIf(Temp >= zArray,"0","1")); //Check if New High is Made
}
}
if(Counter == 0)
{
VarSet("M"+k+"High",1);
}

if(Counter > 1)
{
VarSet("M"+k+"High",0);
}

Counter = 0;
x = x + 1;
}
}
for(i=0;i<12;i++)
{
intTemp = 0;
intTemp = StrToNum(WriteIf((IsNull(VarGet("M"+i+"High")) < 1),"0","1"));
if(intTemp == 0)
{
// AddColumn(VarGet("M"+i+"High"),"M"+(i+1)+"High");
MH = VarGet("M"+i+"High");
if (MH > 0)
{
AddTextColumn( NumToStr(MH),"M"+(i+1)+"High",1.2,colorWhite, colorGreen,-1 ) ;
}
if (MH == 0)
{
AddTextColumn( NumToStr(MH),"M"+(i+1)+"High",1.2,colorBlack, colorGrey50,-1 ) ;
}

}
if(intTemp == 1)
{
MH = 0;
AddTextColumn( NumToStr(MH),"M"+(i+1)+"High",1.2,colorBlack, colorGrey50,-1) ;
}

}

Filter = 1 AND NFlag > 0 AND BC >= 3;
_SECTION_END();
 

jagankris

Well-Known Member
#25
/*
//The Code is expected to pick the previous 12 months Lows and compare with the historical Lows for the data available.
//if a New all time Low is made it will have value 1 else 0.
M12Low - Refers to the previous 12th Month Low.
M11Low - Refers to the previous 11th Month Low. and So on.

For example M12Low means - the previous 12th month Low is a new low compared to the Lows before from the first candle data available till the 12th month.
M11Low - Previous 11 th month Low is a new Low compared to the Lows before from the first candle data available till the 11th month and also < M12Low.
and so on
If M11Low is not a new Low - it will have 0 else 1.
*/

_SECTION_BEGIN("MonthlyLowExploration");

TimeFrameSet( inMonthly);

BC = BarCount;
//Check if NewLow is with in the last 12 months
NF = "0";
CounterL = 0;
LFlag = 0;
LL =0;
LL = LLV(L,BC);
M12LL = LLV(L,12);
LFlag = StrToNum(WriteIf(M12LL <= LL,"1","0"));


//If Lowest is with in the last 12 months
if (LFlag > 0 AND BC >= 3)
{

//For each of the last tweleve bars set the high values in the variable M1H,M2H,M3H .....

for(i=0;i<12;i++)
{
VarSet("M"+i+"L",Ref(L,-i));
}
x = 0;
for(k=0;k<12;k++)
{

TempL = VarGet("M"+k+"L");

CounterL = 0;

for(i=BC-1;i>k;i--)
{
zLow = 0;
zLow = Ref(Low,-i);

NullFlagL = StrToNum(WriteIf((IsNull(TempL) < 1) AND (IsNull(zLow) < 1),"1","0"));

if (NullFlagL == 1)
{
CounterL = CounterL + StrToNum(WriteIf(TempL <= zLow ,"0","1"));
}


}

if(CounterL == 0)
{
VarSet("M"+k+"Low",1);
}

if(CounterL > 1)
{
VarSet("M"+k+"Low",0);
}

CounterL = 0;

x = x + 1;
}
}

for(i=0;i<12;i++)
{
intTemp = 0;
intTemp = StrToNum(WriteIf((IsNull(VarGet("M"+i+"Low")) < 1),"0","1"));
if(intTemp == 0)
{
ML = VarGet("M"+i+"Low");
if (ML > 0)
{
AddTextColumn( NumToStr(ML),"M"+(i+1)+"Low",1.2,colorWhite, colorRed,-1 ) ;
}
if (ML == 0)
{
AddTextColumn( NumToStr(ML),"M"+(i+1)+"Low",1.2,colorBlack, colorGrey50,-1 ) ;
}

}
if(intTemp == 1)
{
ML = 0;
AddTextColumn( NumToStr(ML),"M"+(i+1)+"Low",1.2,colorBlack, colorGrey50,-1) ;
}
}


Filter = 1 AND LFlag > 0 AND BC >=3;
_SECTION_END();
 
Last edited:
#27
@Trash On the forum, have observed people from different backgrounds connected by a common interest. You have expertise in coding AFL and by your presence in the forum, I infer that you are interested in sharing your knowledge and learning from others, to achieve the common interest. As there are people from different backgrounds, their skill sets on let say coding AFL would be at different levels. Some would have learnt by initially copying AFL’s and then tinkering around with it. Some would have the benefit of learning it in a structured manner, hence are able to pick the threads fast. But trading is not defined by AFL. It is just one of the inputs. Converting an idea into an AFL and then using the output to get a successful trade is every traders dream. But which idea / AFL, under what conditions and the guidelines for its usage is what separates a successful trader from the crowd. For people trading with only own resources (as on this forum), the best way is to share an idea and get multiple feedback / possible angles to the idea to help formulate it into a strategy. For this each resource is important.
Going thru the thread, I could infer a difference in expectation between the resource seeker and the resource provider. If @Amit, has not been able to infer your code, suggest try lowering the bar and possibly giving some examples or reference material which can possibly be read and understood. If the interest is genuine, possibly @Amit would be able to get the solution or would be asking the right questions. I don’t know him personally, but have seen his threads and posts, to me he appears knowledgeable and genuine.
Further, with your expertise would love to see a thread, which starts with the absolute basics of AFL coding, with gradual increase in complexity of coding and also possibly answering stupid basic questions. Possibly such a thread would help many learn coding in a structured manner.
 
#28
Thread closed on request from the thread starter.

Smart_trade
 
Status
Not open for further replies.

Similar threads