Hi, Shrewd!        Login  
Shrewd'm.com 
A merry & shrewd investing community
Best Of MIBest OfAll BoardsThe Shrewd’m WeeklyLearn to InvestHow to Become Shrewd
Search
Shrewd'm.com Merry shrewd investors
Search
Best Of MIBest OfAll BoardsThe Shrewd’m WeeklyLearn to InvestHow to Become Shrewd


The week's question
In March 2025, in the thread "Re: OT, out", Umm asked the members: "Do you think it is because America is made up of magical soil that makes businesses based in America magically profitable?" This week it is put to everyone again. The button below opens the small thread re-asking it - read what others have said so far, then give your own answer as an ordinary reply.
Answer this questionContinue to Shrewd'mThis note won't appear again
Investment Strategies / Mechanical Investing
Unthreaded | Threaded | Whole Thread (70) |
Author: ges ✧❂🐝 HONORARY
SHREWD
  😊 😞

Number: of 6243 
Subject: Re: NDX 100 Momentum Strategy - Code Repository
Date: 03/06/26 11:26 AM
Post New | Post Reply | Report Post | Recommend It!
No. of Recommendations: 4
I don't know if anyone here is using Amibroker, but here is (what I think would be) Amibroker AFL code for Philly Tides gtr1 code:
[I am not a proficient coder and this was with assistance from Gemini so...]

--------------------------
// --- GTR1 to AmiBroker Translation ---
/*Philly Tides nas100 verions
nas100.a = 1
tr(1,253) top 13
ratio(hgprc(1,253),lgprc(1,253)) top 11
ratio(tr(1,5),tr(1,200)) bottom 10
Philly Tide replies on NDX 100 Momentum Strategy - Code Repository*/

// 1. tr(1,253) -> Total Return 253 days, lagged 1 day
Factor1 = Ref(ROC(C, 253), -1);

// 2. ratio(hgprc(1,253),lgprc(1,253)) -> High/Low Ratio 253 days, lagged 1 day
Hi_253 = Ref(HHV(H, 253), -1);
Lo_253 = Ref(LLV(L, 253), -1);
Factor2 = Hi_253 / Lo_253;

// 3. ratio(tr(1,5),tr(1,200)) -> 5-day return relative to 200-day return, lagged 1 day
// This simplifies to Price(201 days ago) / Price(6 days ago)
TR_5 = Ref(C / Ref(C, -5), -1);
TR_200 = Ref(C / Ref(C, -200), -1);
Factor3 = TR_5 / TR_200;

// --- Exploration Setup ---

Filter = 1; // Show all symbols so you can sort them

AddColumn(Factor1, "TR_253 (Top 13)", 1.2);
AddColumn(Factor2, "H/L Ratio (Top 11)", 1.2);
AddColumn(Factor3, "Ret_Ratio (Bot 10)", 1.4, colorDefault, colorgreen);

// 3. Sort by Column 4 in Ascending order (Low to High)
// A negative number indicates Ascending, a positive number indicates Descending.
SetSortColumns(-3);

Post New | Post Reply | Report Post | Recommend It!
Print the post
Members reply directly to ges here — and replies get answered. Reading is free; so is joining the conversation. Join Shrewd'm »
This community has written 6,227 posts about Mechanical Investing. The article-length ones it recommended most:
Dividend investing · 52 recs · 2025
Non-Mag7 screen · 34 recs · 2025
OT - Div yields and returns · 32 recs · 2024
Using AI to generate backtesting programs · 30 recs · 2025
Rankings for 19Dec2022 · 29 recs · 2022
Unthreaded | Threaded | Whole Thread (70) |


Announcements
Mechanical Investing FAQ
Contact Shrewd'm
Contact the developer of these message boards.

Best Of MI | Best Of | Favourites & Replies | All Boards | Followed Shrewds | Open Questions | Moving a community