Announcement

Collapse
No announcement yet.

Trailing Stop Formula

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

  • Trailing Stop Formula

    I would certainly appreciate help with coding the following in an EFS formula:

    Initial stop = Low() - 3

    For next bar and each consecutive bar:

    Stop (D +1) = Low() - Stop (D)

    Where

    Stop(D + 1) is next bar stop
    Stop(D) is this bar stop

    This is not the exact formula but what i am struggling with is the logic where the next bar stop includes the this bar stop in the equation.

    Thank You!

  • #2
    Something like this....

    Big,

    I don't know about your formula for the stop level and will simply give an example for you to work with. I can't tell if your "low()" for the "following bars" is refering to the low of the entry bar or the low of the following bars.

    We can continue to adapt this structure as you provide more information.

    It would look something like this....

    PHP Code:
    var nStopLevel 0;

    if (
    Strategy.isInTrade == false) {
    //  Entry Signals
      
    if (*buycondition*) {
       
    Strategy.doLong(...);
       
    nStopLevel low() - 3.0;
      }
      if (*
    sellcondition*) {
       
    Strategy.doShort;
       
    nStopLevel high() + 3.0;
      }
    //  End Entry Signals
    } else {
    //  Stop Conditions
      
    if (Strategy.isLong == true) {
       if (
    low() < nStopLevel) {
          
    Strategy.doSell(..)  //  Stop hit.
       
    }
       
    //  re-adjust stop level
       
    nStopLevel low() - nStopLevel;
      }
      if (
    Strategy.isShort == true) {
       if (
    high() > nStopLevel) {
          
    Strategy.doCover(..)  //  Stop hit.
       
    }
       
    //  re-adjust stop level
       
    nStopLevel high() - nStopLevel;
      }
    //  End Stop Conditions.

    This is a besic example of how you would accomplish this task. With more information about what you are trying to accomplish, I can provide more help.

    Brad
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thanks so much for your help and quick reply Brad!

      I will try this code to see what happens.

      I would post the entire formula, but I read it in a book and I am not sure if it is appropriate to post a formula from a copyrighted book?

      Comment

      Working...
      X