Quick SL and TP Q

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #50273 quote
    Joachim Nilsson
    Participant
    Average

    Hey guys, I have a quick question about SL and TP. Is it possible to have one SL/TP for the long side and one for the short side in the same code? 🙂

    Like this:

    // Stops and targets
    
    SLL = 50 
    TPL = 50 
    if longonmarket then
    SET STOP pLOSS SLL
    sET TARGET pPROFIT TPL
    ENDIF
    
    
    SLS = 40
    TPS = 40 
    if SHORTonmarket then
    SET STOP pLOSS SLS
    sET TARGET pPROFIT TPS
    ENDIF
    
    #50280 quote
    Despair
    Blocked
    Master

    It is possible but you can not use the SET command. Look here:

    SLL = 50 
    TPL = 50 
    if longonmarket then
      sell at TPL limit
      sell at SLL stop
    ENDIF
     
     
    SLS = 40
    TPS = 40 
    if SHORTonmarket then
      exitshort at TPS limit
      exitshort at SLS stop
    ENDIF
    #50331 quote
    Joachim Nilsson
    Participant
    Average

    Thanks!

    #50615 quote
    Nicolas
    Keymaster
    Master

    @Despair

    Thanks for answering the Joachim’s question but I do not understand your code. The code Joachim shared in his post should work fine to me.

    In your code:

    SLL = 50 
    TPL = 50 
    if longonmarket then
      sell at TPL limit
      sell at SLL stop
    ENDIF

    the long orders will close at 50, which will never be possible if the current instrument quote at 13000 for instance. I think Joachim would like to set its takeprofit and stoploss in points, not in price.

    #50626 quote
    Despair
    Blocked
    Master

    You are correct Nicolas. I forgot to add the trade price. The think Joachim wanted to achieve is that he has different TP and SL for short and long.

    SLL = 50*pipsize
    TPL = 50*pipsize
    if longonmarket then
      sell at TPL+tradeprice(1) limit
      sell at tradeprice(1)-SLL stop
    ENDIF
     
     
    SLS = 40*pipsize
    TPS = 40*pipsize 
    if SHORTonmarket then
      exitshort at tradeprice(1)-TPS limit
      exitshort at tradeprice(1)+SLS stop
    ENDIF
    
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Quick SL and TP Q


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Despair
8 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/23/2017
Status: Active
Attachments: No files
Logo Logo
Loading...