Initial stop loss and a profit target for two separate setups doesn’t work

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #167198 quote
    SaschaSascha
    Participant
    Average

    Hi,

    How can I code two separate setups, one with only an initial stop loss  and the other with an initial stop loss and a profit target.

    When I create the code like below what happens is that Setup 1 which has only an initial stop loss (and some other exit rules that are not below), exits with the profit target that I defined for Setup 2. It seems like once a profit target is defined it is applied to any open trade. Why is that?

    Can I code it in a way that the profit target is only applied for the trade setup 2?

    Thanks

    Sascha

    if Setup1  then  
    ISL = 10000*(1*ATR + SBuffer )
    TradeRisk = pipvalue*ISL
    ContractSize = 100/TradeRisk
    SELLSHORT ContractSize SHARES AT market
    
    SET STOP LOSS 1*ATR + SBuffer
    ENDIF
    
    if Setup2  then 
    ISL = 10000*(1*ATR + SBuffer )
    TradeRisk = pipvalue*ISL
    ContractSize = 100/TradeRisk
    SELLSHORT ContractSize SHARES AT close+0.25*ATR Limit
    
    SET STOP LOSS 1*ATR + SBuffer
    SET TARGET PROFIT 1.5*ATR + SBuffer
    ENDIF
    #167230 quote
    NicolasNicolas
    Keymaster
    Legend

    There is no way to identify the orders with code. What you can do is partial closing of position in profit at a desired level with a pending order, example  below:

    exitshort 1 contract at mylevel limit //mylevel is your desired price level
    #167268 quote
    SaschaSascha
    Participant
    Average

    Thanks for your reply.

    That’s unfortunate that this is not working. The goal was that I wanted to have one setup once triggered lets the trade run as long as possible until stopped out with a predefined trailing stop loss. And a second setup that exits with a fixed profit target, and having both setups in one automated trading system.

    However, it seems that the solution is only to have two separate trading systems. One with a trailing stop loss and the other with a fixed profit target. The annoying thing is that if I want to run this system on 8 currency pairs, then I have to have 16 systems instead.

    I mentioned before that I had the impression that once a profit target is defined (like it is Setup 2 in the example code) it is applied to any open trade. How is that technically possible?

    If only the conditions for Setup 1 are me (which has no profit target) and the conditions for Setup 2 are not met, how can the profit target be even triggered as it is only within the if-clause of Setup 2?

    #167307 quote
    NicolasNicolas
    Keymaster
    Legend

    Because the Takeprofit is applied directly to any open order, there is no way to select an order specifically.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Initial stop loss and a profit target for two separate setups doesn’t work


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Sascha @goedelsa Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by NicolasNicolas
5 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/15/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...