Announcement

Collapse
No announcement yet.

Donchian Channel....

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Donchian Channel....

    Hi,

    Is there a script/formula for the Donchian Channel that buys and sells at market when the breakouts occur?

    IE. When the channel trend is down and reverses to break through overhead resistance, a buy at market occurs, now if the bar (say a 20 minute bar is used) doesn't close beyond this break in the direction of the new trend, then the position is abandoned and sold at market. Next trade is taken on the next breakout whether it be continuing the trend up or another reversal down breaking support. All trades at market. Must be optimizable for the number of "lookback" bars. I use 3 with a 20 minute bar chart. Have found 4 and 31 works for daily's. And have ability to place stop "x" points out when the trades are not closing in the direction of the new breakout.

    I hope this makes sense... I searched for scripts but none even close were found. Couldn't find any even taking trades...

    Thanks for the help.....

  • #2
    Code..

    You're talking about alot of work....

    With the Donchians and the 20 minute chart (possibly dailys), the issues for back-testing are as follows...

    1. Breach of the levels does not occur in RT, so all orders need to be executed as LIMIT orders.
    2. Confirming a close above/below the Donchian level is not too difficult.
    3. Stops are virtually impossibly to verify in this type of code. We can't tell which side of the market was touched first (high or low), thus the stops will not be accurate.
    4. Optimizing is something that can't be done (as far as I know) in esignal.

    I would suggest you try building it in stages.. Here is the first stage - a system that buys and sells on CLOSING PRICE breaches of the Donchian channels.

    PHP Code:
    var study = new DonchianStudy(200);

    function 
    preMain() {
        
    setPriceStudy(true);
        
        
    setDefaultBarFgColor(Color.blue0); // upper
        
    setDefaultBarFgColor(Color.red1); // basis
        
    setDefaultBarFgColor(Color.blue2); // lower
    }

    function 
    main() {
        var 
    vUpper study.getValue(DonchianStudy.UPPER);
        var 
    vBasis study.getValue(DonchianStudy.BASIS);
        var 
    vLower study.getValue(DonchianStudy.LOWER);
      
       if ((!
    Strategy.isLong()) && (close() > vUpper ))  {
        
    Strategy.doLong("Buy"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT);
      }
       if ((!
    Strategy.isShort()) && (close() < vLower ))  {
        
    Strategy.doShort("Sell"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT);

      }

      
        return new Array(
    vUppervBasisvLower);

    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thanks Brad!

      It appears I must have made some sense.....

      If e-signal does not optimize than do you know if TradeStation or Wealth-Labs or any other charting software which might?

      Or maybe I just have to open and reload each number manually.

      Again many thanks, Jack

      Comment

      Working...
      X