Hi, Shrewd!        Login  
Shrewd'm.com 
A merry & shrewd investing community
Best Of MI | Best Of | Favourites & Replies | All Boards | Post of the Week! | How To Invest
Search MI
Shrewd'm.com Merry shrewd investors
Best Of MI | Best Of | Favourites & Replies | All Boards | Post of the Week! | How To Invest
Search MI


Investment Strategies / Mechanical Investing
Unthreaded | Threaded | Whole Thread (63) |
Author: ges 🐝  😊 😞
Number: of 5384 
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
https://www.shrewdm.com/MB?pid=149338549&wholeThre...*/

// 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
Unthreaded | Threaded | Whole Thread (63) |


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