Indicators: Dserg - LinRegression Breakout

 

Dserg - LinRegression Breakout:

The indicator for automatic drawing of consolidation areas and channels based on the linear regression

Fig.1 The Dserg - LinRegression Breakout indicator.

Fig.1 Dserg - LinRegression Breakout

Author: Nikolay Kositsin

 

Trading the Break (adapted from dailyfx article)

  • Breakouts emanate from range-bound markets as new information pushes prices higher or lower.
  • These breaks can often be accompanied with increased volatility that can prove devastating
  • Risk-Reward ratios are of the upmost importance, so traders can mitigate the damage of false breakouts while maximizing the reward of successful entries.

Since future price movements are, in essence, unpredictable; identifying with and trading in the direction of the trend gives the trader the chance to jump on the side of any bias that may have been seen in the market. And if those biases (trends) are to continue, the trader can potentially make three, four, or five times the amount they put up to risk.

Unfortunately, trends don’t always exist. More common is the condition with which prices aren’t displaying some element of a bias; when prices move in a range-bound fashion for an extended period of time. And because there is a lack of a bias, knowing how to trade in these situations can be quite a bit more difficult. But traders have two choices: They can trade as if the range is going to continue, or they can trade the range in the expectation of a breakout of those range-bound prices.


Breakouts

When prices do break-out from a range, the movement can be fast, violent, and extremely large. Imagine a rubber band being pulled all the way back, until eventually it pops; that’s somewhat similar to what can happen when a breakout takes place.
Trading a breakout is not for the faint of heart. Often the breakout will come from a news event, or a data announcement, or some other reason that causes traders to push prices being the previously defined support and resistance levels.

It often takes more than one attempt to catch a breakout


It’s this extreme pickup in volatility that makes trading breakouts so difficult; as the accompanying price movements can swing dangerously in both directions, and there will be many instances in which support and/or resistance get broken, only to see prices reverse and move in the opposite direction. This is the dreaded ‘false breakout.’

Because of the heightened volatility around such events, and given the risk of false breakouts; traders often need to focus more heavily on risk and reward while being more aggressive: cutting losers even quicker while also looking for larger profit targets when they find themselves on the right side of the trade.

Probabilities

Traders will often assign a lower probability of success to breakout strategies because of the aforementioned reasons. If a trader thinks they can usually win 1 out of every two trend trades, they will often look to win 1 of every 4 breakout trades.

And because breakouts have a lower probability of success, traders need to adjust risk-reward ratios accordingly: Looking at even tighter stops, and even larger profit targets.

So, we’ve warned you against the risks of trading breakouts; a logical question that follows is often ‘why would anyone trade breakouts when there might be a trend somewhere that can be traded?’

Well, the beauty of the breakout is in the potential. When a breakout does work, the upside can potentially be huge (just like the downside is huge, but can be addressed or offset with tighter stops).

New trends often form from an initial breakout; and this is a very natural life-cycle in financial markets. Let’s look at an example to illustrate


How to Trade Breakouts

The key ingredient to trading a breakout is Support and/or Resistance. These levels that may see changes in order flow are the same prices that traders can look to enter upon breaks.

Pivot Points are an extremely common option for breakout traders. Traders can look to these price levels for potential breakout moves, while placing entry orders just outside of these prices so that once a pivot point yields to a price surge, the entry is initiated and the trader is in the position.

Another common option for trading breakouts is including the Price Channels indicator (often called ‘Donchian Channels,’ after famed breakout-trader Richard Donchian). Price Channels will show the highest high, and the lowest low over the past x periods (x being the number of candles input by the trader). When prices approach these levels, they may go on to make higher highs, or lower lows; and this is the essence of a breakout entry.

The same type of logic can be utilized around psychological whole numbers, or round levels like 1.3500 on EURUSD or .9000 on AUDUSD. These round-number price levels will often see a large number of stops or limits, and this can stop a trend dead in its tracks, at least temporarily. But when a subsequent approach towards that level takes place, the number of stops or limits may not be able to hold back the surge of selling (or buying in the case of an up-trend).

This leads to one of the more common ways of trading breakouts; incorporating price action and previous market movements into the analysis.

 
Good evening
I've been using Dserg for a few days and it seems good to me; I think a warning would be useful when a Sell or Buy signal intervenes; how can you do it to insert it?
Greetings and thanks.
Roberto

 

Hi Nikolay

The indicator works really well on a live chart but when testing in the Startegy Tester it doesn't paint the arrows, something seems to be wrong with the way the Linear Regression is drawn. I've also tried to use it with iCustom in an EA and the painting is incorrect.

Any ideas how this could be fixed?

 
Any chance getting this set up to work on gold?
 
Alastair Norman:

Hi Nikolay

The indicator works really well on a live chart but when testing in the Startegy Tester it doesn't paint the arrows, something seems to be wrong with the way the Linear Regression is drawn. I've also tried to use it with iCustom in an EA and the painting is incorrect.

Any ideas how this could be fixed?

Hi, I solved this bug adding a refresh function at the beggining of every bar.

Here is what I changed at the very last lines of the code:

Before:

            if(!j)
              {
               B3_Buffer[barj]=res2;
               B4_Buffer[barj]=res3;
              }
            B0_Buffer[barj]=res2;
            B1_Buffer[barj]=res3;
           }
        }
     }
//----
       
   return(rates_total);
  }

//+------------------------------------------------------------------+

After:

            if(!j)
              {
               B3_Buffer[barj]=res2;
               B4_Buffer[barj]=res3;
              }
            B0_Buffer[barj]=res2;
            B1_Buffer[barj]=res3;
           }
        }
     }
//----
   int timeBar = timeBar();
   if(timeBar == true)
       ChartSetSymbolPeriod(ChartID(), _Symbol, PERIOD_M1); 
       
   return(rates_total);
  }
  
datetime newTime = 0;
bool timeBar()
{
   datetime lastBar = iTime(_Symbol, _Period, 0);
   
   if(newTime != lastBar)
   {  
      newTime = lastBar;
      return true;
   }
   else
      return false;
}

//+------------------------------------------------------------------+