Two Dimensional Market Environment Filter

About the Author Jeff Swanson

Jeff is the founder of System Trader Success - a website and mission to empowering the retail trader with the proper knowledge and tools to become a profitable trader the world of quantitative/automated trading.

follow me on:
  • Ninelivesz says:

    Thanks for the interesting articles Jeff.

    I took the accumulated RSI and averaged it out so it plots similar to basic RSI. Here’s the code. It matches up very well with the RSI Accum oversold area.

    Input:

    Price( Close ),
    Length( 2 ),
    OverSold( 20 ),
    OverBought(80),
    OverSColor( Green ),
    OverBColor(Red);

    Variables:
    MyRSI( 0 ) ;

    MyRSI = (RSI(Price[2],Length) + RSI(Price[1],Length) + RSI(Price,Length))*.33;

    if MyRSI OverBought then SetPlotColor( 1, OverBColor ) ;

    Plot1( MyRSI, “RSI”) ;
    Plot2( OverSold, “OverSold” ) ;
    Plot3( OverBought, “OverBought” ) ;

    if MyRSI crosses over OverSold then Alert( “Accum RSI buy zone” );
    if MyRSI crosses under OverBought then Alert( “Accum RSI sell zone” );

    • Glad you liked it. That is an interesting twist on the indicator. Thanks for sharing.

  • […] is not unilaterally the best in all types of markets.  He’s more recently followed up with another article using the ROC, RSI, and TSI indicators in another variation of trading based on market […]

  • BlueHorseshoe says:

    Thanks for the article Jeff.

    An interesting thing to do with a strategy like this is to feed some of the performance stats back into the strategy as inputs, so that parameters are updated in an “on-line” fashion.

    For example, how relevant is the 10 day ATR? Volatility might be better measured over a period equal to the typical trade – afterall that’s the volatility your position will, on average, endure.

    The best thing about this is that because the volatility is used only to size positions and not to determine entries/exits, feeding the average trade length back into the strategy in this way can have no effect on the future average trade length – you get a potentially more meaningful input with no risk of convergence on a sub-optimal solution.

    Hope that’s a useful idea to someone!

    • Thanks BlueHorsehoe, that’s an interesting idea. That’s the thing with trading, there are so many ideas to test!

    • Mark says:

      I’m not entirely I follow exactly what you’re getting at, BlueHorseshoe, but would walk-forward optimization be a systematic way of doing this?

  • Rick says:

    The tsi study is not verifying in tradestation.

    I get the following error:

    Series input not allowed here. Line 14 error (#30254)

    Smoothed is highlighted.

    Help!

    Thanks

    Rick

  • Pietro says:

    I’ve tried 150 ROC with smoothing weights = [1 2 1]/4; RSI=4 days, entry = 15, exit = 60 if TSI5. Looks good! The most sensitive parameter is the RSI window…

  • Rick says:

    I did both….neither would verify.

    Rick

    • I’ve not received any other issues from other people, so this makes me think you have something unique going on with your machine. A quick fix may be 1) Remove the TSI function from your strategy code and 2) simply cut-and-paste the TSI calculations directly into your strategy. This will bypass the need to call the function which is not verifying. The TSI function is only a couple lines of code (along with a single variable). While this is not the best solution it should get you up and running quickly.

  • trader911 says:

    Thanks Jeff, i did see some issues with code

    1. the code does not verify unless you adjust the code to:
    cntrcts = _CE_Normalize_Units_vs_Volatility( AccountSize, RiskPerTrade$, Close, 20, 3, false );

    2. If EnableTrendFilter(false); then it doesnt display any trades;

    3. I couldn’t match your performance on the same set of data.

  • Michael Young says:

    Have you tried an exit strategy that exits after say 3 profitable closes or 10 unprofitable closes?

    • Michael, those are good ideas. At this time I’ve have not tested those exit methods.

  • Cosmogeek says:

    How can you get more trades by adding a condition that keeps you in some trades longer, especially when you didn’t change the entry condition? Something doesn’t smell right.

    • Thanks for pointing that out. The article was recently moved from a another format in WordPress and it appears during that process a paragraph was skipped. If you look at the strategy code you’ll see the entry threshold is also changed based upon the TSI indicator. I updated the article with the missing paragraph.

  • >