Not logged in
Viewing 3 posts - 1 through 3 (of 3 total)

Forums>StrategyQuant>Application Support>How to set SL same as TP? Without using MM?

  • #113080 |
    Customer
    40 Posts

    Hi.

     

    I’ve been using a formula to get my stop loss which works well.

     

    But I’d like to copy that distance in pips for my TP, however I can’t see how to do it. I tried using MM but had some trouble. I also tried for example for long trades;

     

    TP; ((Order open price (1000) – Order stop loss (1000)) + (Order open price (1000)))

     

    Any help would be appreciated, thanks

     

    Julian

    #128251
    Mark Fric
    Administrator
    1182 Posts

    Julian, it wouldn’t work like this. The problem is that functions OrderOpenPrice() and OrderStopLoss() will return correct values only after the order is already opened.

    But you call them as the order is opening, they’ll return zeroes.

     

    But it can be easily made using variables.

     

    Define a new double type variable which you’ll use to compute SL.

     

    In THEN action first use Assign Variable to compute SL value and then store it into this variable.

    Then add new Enter at Market/Stop/Limit action and use this variable (or formula based on it) for SL and PT.

    Mark
    StrategyQuant architect

    #128261
    Customer
    40 Posts

    Thanks Mark.

     

    I think I get what you’re saying. I found someone else in the forum with a similar issue, in which you described a possible solution, so I adapted it myself and came up with this which works well:

     

     

    For long trades: PT= (open (0)) – (Min(low[2],low[1])) + ((ConvertToRealPips) (TakeProfitBuffer))

    Where TakeProfitBuffer is a variable I created, default set to 2, or same value as stop loss buffer, 2 pips away from the lowest of the last 2 lows.

     

    The same kind of thing can also be used to compute activate trailing stop value, works well :)

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.