Announcement

Collapse
No announcement yet.

trailing stop

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

  • trailing stop

    I just completed example #3:Three bar breakout trading system from the tutorial download. How can I set a trailing stop for this? for example a trailing stop of the low of the last three bars?

    thanks in advance

  • #2
    Hello jvasto,

    One option would be to keep track of the low and check the current price against that value. If your condition is found, then exit your position. Try adding the following to your formula:

    PHP Code:
        var Lows getValue("Low", -33);
        var 
    vLow low(-1);
        for (
    03; ++i) {
            
    vLow Math.min(Lows[i], vLow)
        }
        
        if (
    Strategy.isLong() && close() <= vLow) {
            
    Strategy.doSell("Stopped"Strategy.MARKETStrategy.THISBAR);
        } 
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment

    Working...
    X