Announcement

Collapse
No announcement yet.

Plotting Strategy.setStop Fills ?

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

  • Plotting Strategy.setStop Fills ?

    Does anyone have a simple way to plot a fill specific to a Strategy.setStop ?

    I need to plot it on a reversal system, so I need to flag it seperatly from my normal exits types (doSell, doLong,doCover.doShort).

    When my stop is filled, I want to drawShape and set some other flags to wait for the next reversal signal and re-enter the reversal strategy.

    I'm not sure what to "listen" for to hear that a setStop was filled other than assuming the price was hit hence the setStop executed -- is that the easiest/cleanest way?

    -willr

  • #2
    Hello Willr,

    What I usually do in this case instead of using setStop() is use a global variable (vStop) to keep track of the stop price and check the close against vStop and call doSell() or doCover() when the conditions are meet. This will allow you to use drawShapeRelative() at the specific stop price and/or return your stop level to your chart visually. The BarCntr thing is just used to create unique tag names for the shapes so they will all be displayed on your chart.

    PHP Code:
    var vStop null;
    var 
    BarCntr 0;

    function 
    main() {
        if (
    getBarState() == BARSTATE_NEWBARBarCntr += 1;

        
    // after entering a position set vStop = desired stop price
        
        
    if (close() <= vStop && Strategy.isLong() == true) {
            
    Strategy.doSell("Sell Stop"Strategy.STOPStrategy.THISBARStrategy.DEFAULT, vStop)
            
    drawShapeRelative(0vStopShape.CIRCLEnullColor.redShape.ONTOP"sell tag name"+BarCntr);
        }
        if (
    close() >= vStop && Strategy.isShort() == true) {
            
    Strategy.doCover("Buy Stop"Strategy.STOPStrategy.THISBARStrategy.DEFAULT, vStop)
            
    drawShapeRelative(0vStopShape.CIRCLEnullColor.greenShape.ONTOP"cover tag name"+BarCntr);
        }

    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