Explorer Help --> Explorer for Trending Stocks

Hello Friends of Amibroker,

i have a Problem i´m not so good a coding. So please help me.

With hat scanner you can find stable trending stock in a correction. i searches for a system quality number over 2.5

for 100 weeks (van tharp)

now i wanna detect more stocks so i wanna search for stocks from 100 weeks until 200 weeks in 4 weeks ranges.

so when the sqn value is over 2.5 for 100 weeks or 104 weeks or 108 weeks or 112 weeks until 200 weeks i wanna get a hit and see the stock in the explorer. is thats possible?

ProfitSer = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA = ma(ProfitSer,100);
sqn = sqrt(100) * ProfitSMA / StDev(ProfitSer,100);

Filter = RSI(2) < 10 AND sqn >= 2.5 AND MA(Close*Volume,52) > 3000000;
AddColumn(sqn, "sqn" );
AddColumn(rsi(2), "RSI");

thanks for your great help

marcus

@odin are you looking at Weekly data or daily data? So for example in your code are you looking at a one week rate of change, and 100 week moving average?

Can you use daily interval instead (for example 5 Daily bars instead of 1 Weekly bar)?

ProfitSer = ROC(Close,1);
ProfitSMA = ma(ProfitSer,100);
sqn = sqrt(100) * ProfitSMA / StDev(ProfitSer,100);
1 Like

hi portfolio builder, i look for weekly data. so i wanna filter to stocks the have an sqn score for 100 weeks > 2.5 or 104 weeks > 2.5 or 108 weeks > 2.5 and so on.
so i write the filter condition 25 times from 100 to 200 but no output comes.

please can some one help me?

here is the code of my second try:

// sqn for a range over 100 weeks in 4 weeks steps until 200 weeks
ProfitSer = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA = ma(ProfitSer,100);
sqn = sqrt(100) * ProfitSMA / StDev(ProfitSer,100);
// sqn for a range over 104 weeks in 4 weeks steps until 200 weeks
ProfitSer1 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA1 = ma(ProfitSer1,104);
sqn1 = sqrt(104) * ProfitSMA1 / StDev(ProfitSer1,104);
// sqn for a range over 108 weeks in 4 weeks steps until 200 weeks
ProfitSer2 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA2 = ma(ProfitSer2,108);
sqn2 = sqrt(108) * ProfitSMA2 / StDev(ProfitSer2,108);
// sqn for a range over 112 weeks in 4 weeks steps until 200 weeks
ProfitSer3 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA3 = ma(ProfitSer3,112);
sqn3 = sqrt(112) * ProfitSMA3 / StDev(ProfitSer3,112);
// sqn for a range over 116 weeks in 4 weeks steps until 200 weeks
ProfitSer4 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA4 = ma(ProfitSer4,116);
sqn4 = sqrt(116) * ProfitSMA4 / StDev(ProfitSer4,116);
// sqn for a range over 120 weeks in 4 weeks steps until 200 weeks
ProfitSer5 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA5 = ma(ProfitSer5,120);
sqn5 = sqrt(120) * ProfitSMA5 / StDev(ProfitSer5,120);
// sqn for a range over 124 weeks in 4 weeks steps until 200 weeks
ProfitSer6 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA6 = ma(ProfitSer6,124);
sqn6 = sqrt(124) * ProfitSMA6 / StDev(ProfitSer6,124);
// sqn for a range over 128 weeks in 4 weeks steps until 200 weeks
ProfitSer7 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA7 = ma(ProfitSer7,128);
sqn7 = sqrt(128) * ProfitSMA7 / StDev(ProfitSer7,128);
// sqn for a range over 132 weeks in 4 weeks steps until 200 weeks
ProfitSer8 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA8 = ma(ProfitSer8,132);
sqn8 = sqrt(132) * ProfitSMA8 / StDev(ProfitSer8,132);
// sqn for a range over 136 weeks in 4 weeks steps until 200 weeks
ProfitSer9 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA9 = ma(ProfitSer9,136);
sqn9 = sqrt(136) * ProfitSMA9 / StDev(ProfitSer9,136);
// sqn for a range over 140 weeks in 4 weeks steps until 200 weeks
ProfitSer10 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA10 = ma(ProfitSer10,140);
sqn10 = sqrt(140) * ProfitSMA10 / StDev(ProfitSer10,140);
// sqn for a range over 144 weeks in 4 weeks steps until 200 weeks
ProfitSer11 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA11 = ma(ProfitSer11,144);
sqn11 = sqrt(144) * ProfitSMA11 / StDev(ProfitSer11,144);
// sqn for a range over 148 weeks in 4 weeks steps until 200 weeks
ProfitSer12 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA12 = ma(ProfitSer12,148);
sqn12 = sqrt(148) * ProfitSMA12 / StDev(ProfitSer12,144);
// sqn for a range over 152 weeks in 4 weeks steps until 200 weeks
ProfitSer13 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA13 = ma(ProfitSer13,152);
sqn13 = sqrt(152) * ProfitSMA13 / StDev(ProfitSer13,152);
// sqn for a range over 156 weeks in 4 weeks steps until 200 weeks
ProfitSer14 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA14 = ma(ProfitSer14,156);
sqn14 = sqrt(156) * ProfitSMA14/ StDev(ProfitSer14,156);
// sqn for a range over 160 weeks in 4 weeks steps until 200 weeks
ProfitSer15 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA15 = ma(ProfitSer15,160);
sqn15 = sqrt(160) * ProfitSMA15 / StDev(ProfitSer15,160);
// sqn for a range over 164 weeks in 4 weeks steps until 200 weeks
ProfitSer16 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA16 = ma(ProfitSer16,164);
sqn16 = sqrt(164) * ProfitSMA16 / StDev(ProfitSer16,164);
// sqn for a range over 168 weeks in 4 weeks steps until 200 weeks
ProfitSer17 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA17 = ma(ProfitSer17,168);
sqn17 = sqrt(168) * ProfitSMA17 / StDev(ProfitSer17,168);
// sqn for a range over 172 weeks in 4 weeks steps until 200 weeks
ProfitSer18 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA18 = ma(ProfitSer18,172);
sqn18 = sqrt(172) * ProfitSMA18 / StDev(ProfitSer18,172);
// sqn for a range over 176 weeks in 4 weeks steps until 200 weeks
ProfitSer19 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA19 = ma(ProfitSer19,176);
sqn19 = sqrt(176) * ProfitSMA19 / StDev(ProfitSer19,176);
// sqn for a range over 180 weeks in 4 weeks steps until 200 weeks
ProfitSer20 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA20 = ma(ProfitSer20,180);
sqn20 = sqrt(180) * ProfitSMA20 / StDev(ProfitSer20,180);
// sqn for a range over 184 weeks in 4 weeks steps until 200 weeks
ProfitSer21 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA21 = ma(ProfitSer21,184);
sqn21 = sqrt(184) * ProfitSMA21 / StDev(ProfitSer21,184);
// sqn for a range over 188 weeks in 4 weeks steps until 200 weeks
ProfitSer22 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA22 = ma(ProfitSer22,188);
sqn22 = sqrt(188) * ProfitSMA22 / StDev(ProfitSer22,188);
// sqn for a range over 192 weeks in 4 weeks steps until 200 weeks
ProfitSer23 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA23 = ma(ProfitSer23,192);
sqn23 = sqrt(192) * ProfitSMA23 / StDev(ProfitSer23,192);
// sqn for a range over 196 weeks in 4 weeks steps until 200 weeks
ProfitSer24 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA24 = ma(ProfitSer24,196);
sqn24 = sqrt(196) * ProfitSMA24 / StDev(ProfitSer24,196);
// sqn for a range over 200 weeks in 4 weeks steps until 200 weeks
ProfitSer25 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA25 = ma(ProfitSer25,200);
sqn25 = sqrt(200) * ProfitSMA25 / StDev(ProfitSer25,200);
// Stock should be oversold in correction
condition1 = RSI(2) > 100 ;
// minum of 3 mio dollar average volume 
condition2 = MA(Close*Volume,52) > 3000000;
// sqn 100 until 200 weeks in 4 week steps
condition3 = sqn OR sqn1 OR sqn2 OR sqn3 OR sqn4 OR sqn5 OR sqn5 or
sqn6 OR sqn7 OR sqn8 OR sqn9 OR sqn10 OR sqn11 OR sqn12 OR
sqn13 OR sqn14 OR sqn15 OR sqn16 OR sqn17 OR sqn18 OR sqn19 OR
sqn20 OR sqn21 OR sqn22 OR sqn23 OR sqn24 OR sqn5 OR sqn25;
// // sqn 100 until 200 weeks in 4 week steps should be over 2.5
condition4 = condition3 >= 2.5;
// summarize in filter
Filter= condition1 AND condition2 AND condition4;

AddColumn(sqn, "sqn" );
AddColumn(rsi(2), "RSI");

do you have understand my logic i´m looking for? :slight_smile:

Hello Friends of Amibroker,

i have a Problem i´m not so good a coding. So please help me.

With hat scanner you can find stable trending stock in a correction. it searches for system quality number score over 2.5

this idead is from van tharp and the standard look back period is 100 weeks.

now i wanna detect more stocks, so i wanna search for stocks with a look back period from 100 weeks until 200 weeks in 4 weeks steps.

so when the sqn score is over 2.5 for 100 weeks or 104 weeks or 108 weeks or 112 weeks until 200 weeks i wanna get a hit in the explorer.

is thats possible?

this is the standard code for my 100 weeks scanner.

ProfitSer = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA = ma(ProfitSer,100);
sqn = sqrt(100) * ProfitSMA / StDev(ProfitSer,100);

Filter = RSI(2) < 10 AND sqn >= 2.5 AND MA(Close*Volume,52) > 3000000;
AddColumn(sqn, "sqn" );
AddColumn(rsi(2), "RSI");

and this is the code, which scearches from 100 weeks to 200 weeks in 4 week steps,
so i wrote i down 25 times and then i work with "OR" in condition3 (see below)
and then i work with condition4 = condition3 >= 2.5;

at least i but everything in the filter... but this code do not work :frowning:

i would be glad if you can help me one time in my amibroker life :slight_smile:

thank you

marcus

This Code here is my second try, that not work :frowning:

// sqn for a range over 100 weeks in 4 weeks steps until 200 weeks
ProfitSer = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA = ma(ProfitSer,100);
sqn = sqrt(100) * ProfitSMA / StDev(ProfitSer,100);
// sqn for a range over 104 weeks in 4 weeks steps until 200 weeks
ProfitSer1 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA1 = ma(ProfitSer1,104);
sqn1 = sqrt(104) * ProfitSMA1 / StDev(ProfitSer1,104);
// sqn for a range over 108 weeks in 4 weeks steps until 200 weeks
ProfitSer2 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA2 = ma(ProfitSer2,108);
sqn2 = sqrt(108) * ProfitSMA2 / StDev(ProfitSer2,108);
// sqn for a range over 112 weeks in 4 weeks steps until 200 weeks
ProfitSer3 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA3 = ma(ProfitSer3,112);
sqn3 = sqrt(112) * ProfitSMA3 / StDev(ProfitSer3,112);
// sqn for a range over 116 weeks in 4 weeks steps until 200 weeks
ProfitSer4 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA4 = ma(ProfitSer4,116);
sqn4 = sqrt(116) * ProfitSMA4 / StDev(ProfitSer4,116);
// sqn for a range over 120 weeks in 4 weeks steps until 200 weeks
ProfitSer5 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA5 = ma(ProfitSer5,120);
sqn5 = sqrt(120) * ProfitSMA5 / StDev(ProfitSer5,120);
// sqn for a range over 124 weeks in 4 weeks steps until 200 weeks
ProfitSer6 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA6 = ma(ProfitSer6,124);
sqn6 = sqrt(124) * ProfitSMA6 / StDev(ProfitSer6,124);
// sqn for a range over 128 weeks in 4 weeks steps until 200 weeks
ProfitSer7 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA7 = ma(ProfitSer7,128);
sqn7 = sqrt(128) * ProfitSMA7 / StDev(ProfitSer7,128);
// sqn for a range over 132 weeks in 4 weeks steps until 200 weeks
ProfitSer8 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA8 = ma(ProfitSer8,132);
sqn8 = sqrt(132) * ProfitSMA8 / StDev(ProfitSer8,132);
// sqn for a range over 136 weeks in 4 weeks steps until 200 weeks
ProfitSer9 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA9 = ma(ProfitSer9,136);
sqn9 = sqrt(136) * ProfitSMA9 / StDev(ProfitSer9,136);
// sqn for a range over 140 weeks in 4 weeks steps until 200 weeks
ProfitSer10 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA10 = ma(ProfitSer10,140);
sqn10 = sqrt(140) * ProfitSMA10 / StDev(ProfitSer10,140);
// sqn for a range over 144 weeks in 4 weeks steps until 200 weeks
ProfitSer11 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA11 = ma(ProfitSer11,144);
sqn11 = sqrt(144) * ProfitSMA11 / StDev(ProfitSer11,144);
// sqn for a range over 148 weeks in 4 weeks steps until 200 weeks
ProfitSer12 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA12 = ma(ProfitSer12,148);
sqn12 = sqrt(148) * ProfitSMA12 / StDev(ProfitSer12,144);
// sqn for a range over 152 weeks in 4 weeks steps until 200 weeks
ProfitSer13 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA13 = ma(ProfitSer13,152);
sqn13 = sqrt(152) * ProfitSMA13 / StDev(ProfitSer13,152);
// sqn for a range over 156 weeks in 4 weeks steps until 200 weeks
ProfitSer14 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA14 = ma(ProfitSer14,156);
sqn14 = sqrt(156) * ProfitSMA14/ StDev(ProfitSer14,156);
// sqn for a range over 160 weeks in 4 weeks steps until 200 weeks
ProfitSer15 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA15 = ma(ProfitSer15,160);
sqn15 = sqrt(160) * ProfitSMA15 / StDev(ProfitSer15,160);
// sqn for a range over 164 weeks in 4 weeks steps until 200 weeks
ProfitSer16 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA16 = ma(ProfitSer16,164);
sqn16 = sqrt(164) * ProfitSMA16 / StDev(ProfitSer16,164);
// sqn for a range over 168 weeks in 4 weeks steps until 200 weeks
ProfitSer17 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA17 = ma(ProfitSer17,168);
sqn17 = sqrt(168) * ProfitSMA17 / StDev(ProfitSer17,168);
// sqn for a range over 172 weeks in 4 weeks steps until 200 weeks
ProfitSer18 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA18 = ma(ProfitSer18,172);
sqn18 = sqrt(172) * ProfitSMA18 / StDev(ProfitSer18,172);
// sqn for a range over 176 weeks in 4 weeks steps until 200 weeks
ProfitSer19 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA19 = ma(ProfitSer19,176);
sqn19 = sqrt(176) * ProfitSMA19 / StDev(ProfitSer19,176);
// sqn for a range over 180 weeks in 4 weeks steps until 200 weeks
ProfitSer20 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA20 = ma(ProfitSer20,180);
sqn20 = sqrt(180) * ProfitSMA20 / StDev(ProfitSer20,180);
// sqn for a range over 184 weeks in 4 weeks steps until 200 weeks
ProfitSer21 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA21 = ma(ProfitSer21,184);
sqn21 = sqrt(184) * ProfitSMA21 / StDev(ProfitSer21,184);
// sqn for a range over 188 weeks in 4 weeks steps until 200 weeks
ProfitSer22 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA22 = ma(ProfitSer22,188);
sqn22 = sqrt(188) * ProfitSMA22 / StDev(ProfitSer22,188);
// sqn for a range over 192 weeks in 4 weeks steps until 200 weeks
ProfitSer23 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA23 = ma(ProfitSer23,192);
sqn23 = sqrt(192) * ProfitSMA23 / StDev(ProfitSer23,192);
// sqn for a range over 196 weeks in 4 weeks steps until 200 weeks
ProfitSer24 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA24 = ma(ProfitSer24,196);
sqn24 = sqrt(196) * ProfitSMA24 / StDev(ProfitSer24,196);
// sqn for a range over 200 weeks in 4 weeks steps until 200 weeks
ProfitSer25 = ROC(Close,1);
//Bar = Barindex - 1
ProfitSMA25 = ma(ProfitSer25,200);
sqn25 = sqrt(200) * ProfitSMA25 / StDev(ProfitSer25,200);


// Stock should be oversold in correction
condition1 = RSI(2) < 10 ;

// minum of 3 mio dollar average volume 
condition2 = MA(Close*Volume,52) > 3000000;


// sqn 100 until 200 weeks in 4 week steps
condition3 = sqn OR sqn1 OR sqn2 OR sqn3 OR sqn4 OR sqn5 OR sqn5 or
sqn6 OR sqn7 OR sqn8 OR sqn9 OR sqn10 OR sqn11 OR sqn12 OR
sqn13 OR sqn14 OR sqn15 OR sqn16 OR sqn17 OR sqn18 OR sqn19 OR
sqn20 OR sqn21 OR sqn22 OR sqn23 OR sqn24 OR sqn5 OR sqn25;

// // sqn 100 until 200 weeks in 4 week steps should be over 2.5
condition4 = condition3 >= 2.5;
// summarize in filter

Filter= condition1 AND condition2 AND condition4;

AddColumn(sqn, "sqn" );
AddColumn(rsi(2), "RSI");

@odin: Just happened on to this thread.

I think your logic for condition 3 and condition 4 are incorrect.

For Contition3, you are doing a LOGIC test on numbers. You appear to then try and test that the logical test you did on numbers can be then used to compare to a number.

I think you will have to do either:

  1. made a condsqn for each where you do the condsqn = sqn >= 2.5; then you can rewrite your condition 3 as condition3 = condsqn OR condsqn1 OR condsqn2 ... _ OR
  2. test each in your condition3 assignment condition3 = (sqn >=2.5) OR (sqn1>=2.5) OR ...

Hope this gets you going.

1 Like