Foreign Function - with 2 Conditions - no result?


I have written the following AFL code

H1 = New High (65 Days)
XFL - T50 = Stock Belongs to ASX Top 50
H1_50 = If both H1 and XFL-T50 are true

I want to use the "Foreign Function" to Add up the total for both column "H1" and "H1_50".
However, the code only works for "H1", but not "H1_50".

The Foreign Column "NewH1_XFL50" is BLANK.

Does anyone know why this is happening?


**AFL Code Below**

#include_once "Formulas\Norgate Data\Norgate Data"

H1 = High > Ref(HHV(High,65),-1);

H1_50 = High > Ref(HHV(High,65),-1) AND NorgateIndexConstituentTimeSeries("$XFL");

AddToComposite(H1 > 0,"~~~H1_Count_Test~~~", "C", 7);
AddToComposite(H1_50 > 0,"~~~H1_Count_Test XFL_T50~~~", "C", 7);

NewH1 = Foreign("~~~H1_Count_Test~~~", "C", True);
NewH1_XFL50 = Foreign("~~~H1_Count_Test XFL_T50~~~", "C", True);

AddColumn(NorgateIndexConstituentTimeSeries("$XFL"),"XFL - T50");

Buy = 1; 
Sell = 1;
Filter = 1;

When posting the formula, please make sure that you use Code Tags (using </> code button) as explained here: How to use this site.

Using code button

Code tags are required so formulas can be properly displayed and copied without errors.

AddToComposite by default works ONLY in "SCAN" mode. So you need to run SCAN to create composite. Also, obviously, composite is built and completed only when scan is complete (not earlier).

Thanks Tomasz. I ran Scan 1st and it worked! :smiley:

Apologies for not using the Code Tags. I will use this from now on.

Hope you have a good weekend!

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.