I try to use NorgateIndexConstituentTimeSeriesOther in an IF-Statement
I rank all Stocks from the Dynamic Norgate Watchlichst and try to save the return value of NorgateIndexConstituentTimeSeriesOther in an array: "InList".
Than i try to use "InList" in an If Statement, but i have Problems to address the right value.
Because i don't know the right array field.
In AddColumn i try different array field but all are wrong.
I also have problems with _trace,It is executed only once, on the last day of the analysis period.
#include_once "Formulas\Norgate Data\Norgate Data Functions.afl"
maxPosLong = 10;
maxPosShort = 0;
maxPos = maxPosLong + maxPosShort;
entryDelay = 0;
SetOption( "InitialEquity", 30000 );
SetOption( "CommissionMode", 2 );
SetOption( "CommissionAmount", 4 );
SetOption( "MaxOpenLong", maxPosLong );
SetOption( "MaxOpenPositions", maxPos );
SetOption( "UsePrevBarEquityForPosSizing", True );
SetOption( "AllowPositionShrinking", True );
SetOption( "PriceBoundChecking", False );
PositionSize = ( -( 100 / maxPosLong ) );
//------------------------------------------------------------------------------
// ######## Einmal Ranking ########### Einmal Ranking
_SECTION_BEGIN( "1x Ranking" );
wlnum = GetOption( "FilterIncludeWatchlist" );
List = CategoryGetSymbols( categoryWatchlist, wlnum ) ;
ListQty = StrCount( List, "," ) + 1;
if( Status( "stocknum" ) == 0 )
{
StaticVarRemove( "RawValue_*" );
StaticVarRemove( "RankRawValue_*" );
_Tracef("Date:"); // Give exacly 1 output. at the enddate of the analysis timespan
InList=0;
for( n = 0; ( Symbol = StrExtract( List, n ) ) != ""; n++ ) //
{
InList= IIf(NorgateIndexConstituentTimeSeriesOther("$SPX",Symbol),1,0);
IstInList[n]=InList[n];
Filter=1;
if(Symbol=="ABS-200606")
{
AddTextColumn(Symbol ,"Symbol");
AddColumn(InList ,"InList"); //Correkt Value that the Symbol is in Index or not
AddColumn(LastValue(InList) ,"LastValue"); // Output is every Time 0. Is this the last value of this array at last Bar ?
AddColumn(InList[BarCount-1] ,"BarCount-1"); // Output is every Time 0. Is this the last value of this array at last Bar ?
AddColumn(InList[BarCount-n+1] ,"BarCount-n+1"); // Output is every Time 0. Is this the last value of this array at last Bar ?
AddColumn(InList[n] ,"n"); // Every Time empty
AddColumn(InList[n-1] ,"n-1"); // Every Time empty
}
//IF(InList)
//{
SetForeign( Symbol, 0 );
RankValue = 0;
RankValue =IIf(InList, C,0); // Workaround that ist correkt
RestorePriceArrays();
StaticVarSet( "RawValue_" + Symbol, RankValue );
//}
}
StaticVarGenerateRanks( "Rank", "RawValue_", 0, 1224 );
}
Rang = StaticVarGet( "RankRawValue_" + Name() );
Buy = Sell = Short = Cover = 0;
BuyPrice = ShortPrice = o;
SellPrice = CoverPrice = o;
B0 = IIf(Rang <= MaxPosLong,1,0);
Buy = B0;// AND NorgateIndexConstituentTimeSeries("S&P 500") ;
ApplyStop( Type = 1, Mode = 1, Amount = 20 );
ApplyStop( Type = 0, Mode = 1, Amount =10 );