Announcement

Collapse
No announcement yet.

setting exits on a strategy

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

  • setting exits on a strategy

    Ive been tinkering with the cci_strategy.efs and was wondering how i can adjust the strategy to buy on the close of the bar and have an exit of +1.5 points for longs with a stop of -1.5 points. For shorts an exit of -1.5 points with a stop of +1.5 points.
    So on a bar that closes more than 1.5 points above or below my entry i want the strategy to use the 1.5 points when it calculates the results not the close of the bar.
    I dont know if this is possible but if it is i know this is the place to find the answer
    Thanks
    Yoda

  • #2
    It is possible...

    You simply have to order your strategy in the proper manner - like below...

    function main()
    {

    do any calculations...

    Test for Stops

    Test for profits

    Test for New Entries

    return any values
    }

    An example of this is...
    PHP Code:
    var EntryPrice 0;
    var 
    StopPrice 0;
    var 
    PTPrice 0;

    function 
    main()
    {
    //  Calc any indicators.....

    //  Test for Stops...
      
    if ((Strategy.isLong()) && (low() <= StopPrice) ){
       
    Strategy.doSell("Long Stop Exit"Strategy.LIMITStrategy.THISBARStopPrice);
      }
      if ((
    Strategy.isShort()) && (high() >= StopPrice) ){
       
    Strategy.doCover("Short Stop Exit"Strategy.LIMITStrategy.THISBARStopPrice);
      }

    //  Test for Profits...
      
    if ((Strategy.isLong()) && (high() >= PTPrice ) ){
       
    Strategy.doSell("Long Stop Exit"Strategy.LIMITStrategy.THISBARPTPrice );
      }
      if ((
    Strategy.isShort()) && (low() <= PTPrice ) ){
       
    Strategy.doCover("Short Stop Exit"Strategy.LIMITStrategy.THISBARPTPrice );
      }

    //----------------------------------
    //  Test for Entries...
      
    if ((!Strategy.isInTrade()) && (Long Entry Signal) ){
       
    Strategy.doLong("Long Entry"Strategy.MARKETStrategy.NEXTBAR);
      
    PTPrice open(1) + 1.50;
      
    StopPrice open(1) - 1.50;
      }
      if ((!
    Strategy.isInTrade()) && (Short Entry Signal) ){
       
    Strategy.doShort("ShortEntry"Strategy.MARKETStrategy.NEXTBAR);
      
    PTPrice open(1) - 1.50;
      
    StopPrice open(1) + 1.50;
      }


    Hope this helps...

    Brad
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thanks it has helped me greatly

      Comment

      Working...
      X