PureBytes Links
Trading Reference Links
|
I forgot to include where I create the composites. The entire
formula is as follows....
MarketCap = round(Close[BarCount -1] * GetExtraData("shares")/1000);
small = Marketcap < 3000;
mid = Marketcap >=3000 AND Marketcap < 9000;
Large = Marketcap >=9000;
function MarketCapGet()
{
CurDatabase = GetDatabaseName();
if(CurDatabase == "QP3")
{
MarketCap = round(Close[BarCount -1] * GetExtraData
("shares")/1000);
}
else
{
MarketCap = 666; //indicating N/A
}
return MarketCap ;
}
function MarketCapCategoryGet(MarketCap)
{
CurDatabase = GetDatabaseName();
if(CurDatabase == "QP3")
{
if (MarketCap < 3000)
MarketCapCategory= "Small";
else
{
if (MarketCap >= 3000 AND MarketCap < 9000)
MarketCapCategory= "Mid";
else
MarketCapCategory= "Large";
}
}
else
{
MarketCapCategory= "N/A"; //indicating N/A
}
return MarketCapCategory;
}
mktcaplarge = "~" + "LC_" + SectorID(1) + Large;
mktcapSC = "~" + "SC_"+ SectorID(1) + small;
mktcapmid = "~" + "MC_" + SectorID(1) + mid;
//Large
AddToComposite(C,mktcaplarge,"C");
AddToComposite(O,mktcaplarge,"O");
AddToComposite(H,mktcaplarge,"H");
AddToComposite(L,mktcaplarge,"L");
AddToComposite(1,mktcaplarge,"V");
//AddToComposite(IIf(newhigh,1,0),sym,"H");//
//Mid
AddToComposite(C,mktcapmid,"C");
AddToComposite(O,mktcapmid,"O");
AddToComposite(H,mktcapmid,"H");
AddToComposite(L,mktcapmid,"L");
AddToComposite(1,mktcapmid,"V");
//small
AddToComposite(C,mktcapSC,"C");
AddToComposite(O,mktcapSC,"O");
AddToComposite(H,mktcapSC,"H");
AddToComposite(L,mktcapSC,"L");
AddToComposite(1,mktcapSC,"V");
--- In amibroker@xxxxxxxxxxxxxxx, "jayhart_1972" <jayhart_1972@xxx>
wrote:
>
> I am relatively new to looping and I am trying to create
composites
> for small, mid, and large cap composites with their underlying
> sectors. For example, take utilities, I am trying to create
small,
> mid, and large cap composites for the utility sector. When I run
> this code I get two composites for each style, i.e. 2 for small
cap,
> 2 for mid cap, and 2 for large cap and I have no idea why - I am
> trying to get one of each not 2. I was hoping someone could shed
> some light on why this may be happening. The code is as follows:
>
>
> MarketCap = round(Close[BarCount -1] * GetExtraData
("shares")/1000);
> small = Marketcap < 3000;
> mid = Marketcap >=3000 AND Marketcap < 9000;
> Large = Marketcap >=9000;
>
> function MarketCapGet()
>
> {
>
> CurDatabase = GetDatabaseName();
>
>
>
> if(CurDatabase == "QP3")
>
> {
>
> MarketCap = round(Close[BarCount -1] * GetExtraData
> ("shares")/1000);
>
> }
>
> else
>
> {
>
> MarketCap = 666; //indicating N/A
>
> }
>
> return MarketCap ;
>
> }
>
>
>
> function MarketCapCategoryGet(MarketCap)
>
> {
>
> CurDatabase = GetDatabaseName();
>
>
>
> if(CurDatabase == "QP3")
>
> {
>
> if (MarketCap < 3000)
>
> MarketCapCategory= "Small";
>
> else
>
> {
>
> if (MarketCap >= 3000 AND MarketCap < 9000)
>
> MarketCapCategory= "Mid";
>
> else
>
> MarketCapCategory= "Large";
>
> }
>
> }
>
> else
>
> {
>
> MarketCapCategory= "N/A"; //indicating N/A
>
> }
>
> return MarketCapCategory;
>
> }
>
>
> mktcaplarge = "~" + "LC_" + SectorID(1) + Large;
> mktcapSC = "~" + "SC_"+ SectorID(1) + small;
> mktcapmid = "~" + "MC_" + SectorID(1) + mid;
>
|