Announcement

Collapse
No announcement yet.

strategy.setStop()

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

  • strategy.setStop()

    Hi,

    Can someone explain how strategy.setStop() works/if it works.

    In the documentation it says you go long at 900 then strategy.setStop(3) will put a stop 3 points below the market (897). However, when I backtest it just stops out every trade at 3 (even though, of course, the market never gets to 3). Does it just not work?

    Also, if I am in a trade is there some way of telling at what price I traded? (So if I need to strategy.setStop(897), how will I actually get the number 897?)

    Thanks for your help in advance.

    Cheers

    mmillar

    p.s. I'm on build 579
    Last edited by mmillar; 05-11-2003, 06:32 AM.

  • #2
    Hello mmillar,

    The value passed to the Strategy.setStop() function is where the stop will be set. Try Strategy.setStop(897).
    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


    • #3
      Hi,

      Sorry, I'm new to this so maybe asking very obvious questions...

      If I do ...

      Strategy.doLong("Long", Strategy.MARKET, Strategy.NEXTBAR);

      ...how do I find out what price it has entered at so that I am then able to set a stop at the appropriate level?

      Thanks

      mmillar

      Comment


      • #4
        mmillar,

        The strategy statement that you specified will go long at the open of the next bar. This means all you have to do is use
        open(); when getbarstate() == BARSTATE_NEWBAR.


        PHP Code:
        // Check for a new bar and a long flag
        if (getBarState == BARSTATE_NEWBAR && nLongFLag == true){
           
        nMyFillPrice open();
           
        nLongFLag false;
        }
        // If I got a signal set the long flag and tell the backtester to go 
        // long on the open of the next bar
        if (MySignal == true){
           
        nLongFlag true;
           
        Strategy.doLong("Long"Strategy.MARKETStrategy.NEXTBAR);

        Hope this helps.

        Garth
        Garth

        Comment


        • #5
          Thanks very much Garth. That's exactly what I wanted.

          Comment

          Working...
          X