Your interactive trading laboratory!
 • 
12 users online

Undercut & Run - Setups

In the past 2-3 years I have noticed, that breakouts don't work any more. Instead there is often a little sell-off where an elapsed low is taken out of the market and afterwards a small rally starts. I wonder if there is a "ready-made" indicator in QS which would be suitable for such undercuts & run setups? If no, maybe someone has an idea how to code/build this in QS?

Here's a sample Chart from AYX which is kind of a Textbook Stock for such setups:


Attachment

Cancel

Responses

What you describe is known as "Turtle Soup" setup by Raschke/Connors for decades:

link link

Here's some C# code for a modified Turtle Soup strategy that should be easy to translate to QSV:

link

What you describe is known as "Turtle Soup" setup by Raschke/Connors for decades: [link](http://technical.traders.com/tradersonline/display.asp?art=2414) [link](https://fbs.com/analytics/tips/turtle-soup-trading-strategy-cooked%E2%80%9D-by-l-raschke-1159) Here's some C# code for a modified Turtle Soup strategy that should be easy to translate to QSV: [link](https://www.wealth-lab.com/Strategy/Details/165)

Sounds like a donchian channel thing....

I'm not sure if a 20 day low is good enough and I can't get the sample code from Wealth-Labs. Can you post the code here?

Sounds like a donchian channel thing.... I'm not sure if a 20 day low is good enough and I can't get the sample code from Wealth-Labs. Can you post the code here?

Here's my quick take at it:

using System;
using QuantaculaCore;
using QuantaculaIndicators;
using System.Drawing;
using System.Collections.Generic;

namespace Quantacula
{
    public class MyModel1 : UserModelBase
    {
		TimeSeries l2;
		int BreakoutPeriod = 20, Timeout = 30, ExitAfter = 5, lowBar = -1, waitBars = 4;
		bool support = false;
	    	    
        //create indicators and other objects here, this is executed prior to the main trading loop
        public override void Initialize(BarHistory bars)
        {
			l2 = new Lowest(bars.Close, BreakoutPeriod) >> 1;
        }

        //execute the strategy rules here, this is executed once for each bar in the backtest history
        public override void Execute(BarHistory bars, int idx)
        {
			if (bars.Close[idx] <= l2[idx])
			{
				support = true;
				lowBar = idx;
				SetBarColor( lowBar, Color.Orange);
			}

			// reset if setup has timed out
			if ((idx + 1 - lowBar) > Timeout * 100)
				support = false;

			if (!HasOpenPosition(bars, PositionType.Long))
            {
				if (support)
				{
					if (
					   ( bars.Close[idx] <= l2[idx]) &       // 2nd breakdown
					   ( bars.Close[idx] <= bars.Close[lowBar]) &   // price at the 2nd breakdown is lower than at the 1st
					   ( idx + 1 - lowBar <= Timeout))   // pattern emerged within [timeout] days
					{
						SetBarColor( idx, Color.Red);
						if (PlaceTrade(bars, TransactionType.Buy, OrderType.Market) != null)
						//if (PlaceTrade(bars, TransactionType.Buy, OrderType.Stop, bars.High[idx]) != null)
						{
							lowBar = 0;
							support = false;
						}
					}
				}
            }
            else
            {
				if (idx + 1 - LastPosition.EntryBar >= ExitAfter)
					PlaceTrade(bars, TransactionType.Sell, OrderType.Market);
            }
        }
    }
}```
Here's my quick take at it: [CODE]using QuantaculaBacktest; using System; using QuantaculaCore; using QuantaculaIndicators; using System.Drawing; using System.Collections.Generic; namespace Quantacula { public class MyModel1 : UserModelBase { TimeSeries l2; int BreakoutPeriod = 20, Timeout = 30, ExitAfter = 5, lowBar = -1, waitBars = 4; bool support = false; //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { l2 = new Lowest(bars.Close, BreakoutPeriod) >> 1; } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { if (bars.Close[idx] <= l2[idx]) { support = true; lowBar = idx; SetBarColor( lowBar, Color.Orange); } // reset if setup has timed out if ((idx + 1 - lowBar) > Timeout * 100) support = false; if (!HasOpenPosition(bars, PositionType.Long)) { if (support) { if ( ( bars.Close[idx] <= l2[idx]) & // 2nd breakdown ( bars.Close[idx] <= bars.Close[lowBar]) & // price at the 2nd breakdown is lower than at the 1st ( idx + 1 - lowBar <= Timeout)) // pattern emerged within [timeout] days { SetBarColor( idx, Color.Red); if (PlaceTrade(bars, TransactionType.Buy, OrderType.Market) != null) //if (PlaceTrade(bars, TransactionType.Buy, OrderType.Stop, bars.High[idx]) != null) { lowBar = 0; support = false; } } } } else { if (idx + 1 - LastPosition.EntryBar >= ExitAfter) PlaceTrade(bars, TransactionType.Sell, OrderType.Market); } } } }[/CODE]

Thanks for your sample. I'll try it...

Thanks for your sample. I'll try it...
Forum Tips

Please sign in if you want to participate in our forum.

Our forum uses Markdown syntax to format posts.

To embed code snippets, enclose them in [CODE][/CODE] tags.