Money Flow Index (MFI) Strategy (Amibroker And Tradestation Code)
The original article can be found here.
The logic in plain English:
- If the two-day MFI is below 10, we buy at the close
- We sell at the close when the close ends higher than yesterday’s high
- We have a time stop of 10 trading days
Amibroker code:
Buy= MFI(2)<10 ;
buyPrice=Close;
Sell= C>Ref(H,-1);
sellPrice= Close ;
ApplyStop(stopTypeNBar,stopModeBars,10,1);
Tradestation code:
{
Strategy - Money flow index
https://www.quantifiedstrategies.com/lessons/money-flow-index-mfi-strategy-amibroker-code/
}
Inputs:
Lookback(2),
Treshold(10),
MaxHoldBars(10);
if MoneyFlow(Lookback) < Treshold Then
Buy at this bar close;
if C > H[1] OR Barssinceentry(0) >= MaxHoldBars then
Sell at this bar close;
