Home › Forums › Trading System Mentor Course Community › AmiBroker Coding and AFL › Gap Filter
- This topic is empty.
-
AuthorPosts
-
August 9, 2020 at 5:57 am #102043#REF!McGrathParticipant
When I ran my end of month exploration for the month of July (last trading day 31/7/20) the exploration picked up the stock PINS. I have a gap filter turned on. This stock closed up 36% for the day on the 31/7/20. When I ran my backtest for the month to compare against the exploration it did not pick up this stock. Also a historical exploration excludes this stock.
Any ideas as to why my exploration would have included this stock? The code is:
gapTog = ParamToggle(“Gap Filter”,”On|Off”,0);
GpP = Param(“Gap %”,15,1,200,0.01);
GpD = Param(“Gap Up Lookback”,150,1,1000,1);
PF1 = C;
PF2 = Ref(C,-1);
R1 = ((PF1-PF2)/PF2)*100;G1 = GapUp() AND R1 > GpP;
GapNum = Sum(G1,GpD);
GapFilter = GapNum == 0;
gapFilterOn = IIf(gapTog,1,gapFilter);August 10, 2020 at 6:58 am #111982SaidBitarMemberI think it is case sensitive
gapFilterOn = IIf(gapTog,1,GapFilter );g should be upper case
try itOctober 8, 2020 at 10:39 pm #111984RobertMontgomeryParticipantGavin, Did this gap filter code work for you? I have been tinkering with it as part of a rotational system, but it’s not filtering as I expected.
October 10, 2020 at 6:13 pm #112286AnonymousInactiveRob M wrote:Gavin, Did this gap filter code work for you? I have been tinkering with it as part of a rotational system, but it’s not filtering as I expected.Hey Rob, I also attempted to use a gap filter for my rotational system but I do not have it live in production. When I lengthened my calculations for the stocks, I realized that a gap filter was not needed.
That being said:
Code:_SECTION_BEGIN(“% Move Filter”);MovePercent = Param(“Move %”,25,5,100,1);
//MovePercent = Optimize(“Move %”,10,5,100,1);
MoveLook = Param(“Move Lookback”,21,1,250,1);
//MoveLook = Optimize(“Move Lookback”,21,5,50,1);
PF1 = C;
PF2 = Ref(C,-1);
M1 = ((PF1-PF2)/PF2)*100 > MovePercent;MoveNum = Sum(M1,MoveLook);
MoveFilt = MoveNum == 0;
//————————————————-
_SECTION_END();October 11, 2020 at 11:44 am #112301SaidBitarMemberCode:DailyGap = abs(Open – Ref(Close, -1))/Ref(Close,-1) * 100;
DailyGapMax = Param(“Max Allowed Daily Gap %”, 25, 25, 100, 5);
DailyGapCond = HHV(DailyGap,100) <= DailyGapMax;this is how i use it
October 11, 2020 at 10:52 pm #112311TerryDunneParticipantHi Said,
I’m curious that you are using open and close rather than high and low to calculate gaps…you’re not bothered that an opening gap can be filled during the day?
I’m struggling to make use of the gap filter on any of my draft momentum systems, although it did help on one of my mean reversion systems. In fact, I’m struggling with momentum systems no matter what I try.
October 12, 2020 at 12:50 am #112312Nick RadgeKeymasterReach out if you need help Terry.
October 12, 2020 at 3:16 am #112314TerryDunneParticipantThanks Nick, I will arrange an appointment with you.
October 13, 2020 at 1:07 am #112315RobertMontgomeryParticipantThanks everyone for sharing your gap filters. It’s sounds we are all seeing similar results, when I applied the version below adapted from Gavin’s example to my momentum system it doesn’t make a significant improvement to the results. Talking to Craig about this it seems the original intent was to filter out stocks in the midst of a takeover.
PF1 = L;
PF2 = Ref(H,-1);
R1 = ((PF1-PF2)/PF2)*100;Gaps = GapUp() AND R1 > 45;
NoGaps = Sum(Gaps,150) == 0;October 15, 2020 at 9:29 am #112313SaidBitarMemberTerry Dunne wrote:Hi Said,I’m curious that you are using open and close rather than high and low to calculate gaps…you’re not bothered that an opening gap can be filled during the day?
Honestly for me gap is the distance from the open to the previous close, and when i am using gap filter the target is around 25% so if the gap was closed definitely i do not want to be in this stock.
-
AuthorPosts
- You must be logged in to reply to this topic.