Setting the Basket/Combined Profit Target

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #48188 quote
    David
    Participant
    Veteran

    On IG PRT currently the:

    SET TARGET $PROFIT 10

    is set for each individual position that is opened within a system and not as a basket/combined positions.

    A potential solution for this as suggested by Nicolas (here) is:

    IF ONMARKET THEN
    SELL AT positionprice+10*pointvalue LIMIT // 10pips/10Points
    ENDIF

    When I had tried this it didn’t work. When I start a strategy it get’s “Rejected”. It’s opens but shortly after it get’s closed with the response from PRT being:

    The limit level you have requested is too far from the current market level. The maximum limit distance from the current market level for this market is 9973.350 per point

    The IG Markets transaction list showed the positioned opened at 1.32965 – in summary it didn’t work so I tried:

    IF ONMARKET THEN
    SELL AT positionprice+(0.001*pointvalue) LIMIT // 10pips/10Points
    ENDIF

    This seemed to work but still each position was set to hit profit target of 10 pip/point of profit each at a combined level to make it 20pip/point. Then 1 more attempt:

    IF ONMARKET THEN
    SELL AT positionprice+((0.001*pointvalue)/COUNTOFPOSITION) LIMIT // 10pips/10Points
    ENDIF

    This seems to work – hope it’s helpful for others and feel free to make suggestions or improvements.

    GBPUSD.png GBPUSD.png
    #48391 quote
    Nicolas
    Keymaster
    Master

    Thanks David, but while $PROFIT is a target in the money account, the solution you propose is set to exit on points basis.

    Also, even with IG, POSITIONPRICE is the whole basket average price of all opened orders on market.

    The limit level you have requested is too far from the current market level. The maximum limit distance from the current market level for this market is 9973.350 per point

    I must admit that I’m totally lost about this error … still trying to understand where the first code is failing.. ?! Are you on a limited risk account?

    #48393 quote
    David
    Participant
    Veteran

    Nicolas I guess you’re pointing out that I’m mixing the concept of $PROFIT with PointProfit but at this stage there is no way to set PointProfit and this means when some uses this approach they have to be aware of this and take this in consideration on the instrument they trade and size etc…?

    So If you trade EURUSD set it to: SELL AT positionprice+((0.001*pointvalue)/COUNTOFPOSITION) LIMIT 
    mini = USD $10
    standard = USD $100

    What would be another way to make this work to set an actual SET TARGET $PROFIT BASKET?

    I’m not on a limited risk live account (but I did this on a demo which might be limited risk?), regardless I don’t think it is related in this example because how it came up with “9973.350”, and the Order List showed 2.32711 while the actual open price was 1.32965

    #48396 quote
    Nicolas
    Keymaster
    Master

    oh! got it now.. it wasn’t clear to me what you were looking to do at the first glance. Your solution is a good one, another one would be to calculate the basket floating profit and take decision from it:

    //floating profit
    floatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gains
    #48397 quote
    David
    Participant
    Veteran

    I have used the floatingprofit but the downside with that approach is that we have to wait for the Bar to Close which is dependent on timeframe to check that the profit target is met and sadly sometimes an opportunity to take profit is missed especially when higher volatility shows because the price moves away by the time the Close happens also floatingprofit  can be a slight issue with spread because PRT cannot account for it. Thanks for the suggestion.

    #62873 quote
    David
    Participant
    Veteran

    I’ve been doing some testing with this code block.

    IF NOT ONMARKET THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF 
    

     OPTION 1
     This will only set the Sell Limit after 1 bar of the trade starting with no Sell Limit set until the 2nd bar

    IF NOT ONMARKET OR COUNTOFPOSITIONS = 1 THEN
    // 0.001 = 10 points // 0.0001 = 1 point
    SELL AT positionprice+((0.001*pointvalue)/COUNTOFPOSITION) LIMIT 
    ENDIF
    

    OPTION 2
    This will set the SELL LIMITS based on the SET TARGET pProfit when the trade starts 1st bar and but note if 2 positions are opened it requires 1 bar after the second position has opened to set the basket/combined limit properly because it still keeps SET TARGET pProfit on the 1st position until the 2nd bar of the 2nd position opening. But then the potential issue with this that 2 of the SELL LIMITS are different and 1 might get hit within the bar but the other might not so the system is back to having 1 position open. 

    IF NOT ONMARKET OR Amnt = 1 THEN
    SET TARGET pProfit 10
    ENDIF
    
    IF Amnt > 1 THEN
    SET TARGET pProfit 0
    SELL AT positionprice+((0.001*pointvalue)/COUNTOFPOSITION) LIMIT
    ENDIF
    
    #62889 quote
    Nicolas
    Keymaster
    Master

    How are you increasing your “Amnt” variable? If you increase it each time you open a new position with BUY instruction, then there’s no need to wait until the next bar to know how many positions are opened. Without the whole code, it is difficult to get a complete view of your problem.

    #62892 quote
    David
    Participant
    Veteran

    The Amnt variable is just

    Amnt = COUNTOFLONGPOSITIONS

    So what you’re stating is correct in theory “if you increase it each time you open a new position with BUY instruction, then there’s no need to wait until the next bar to know how many positions are opened.” but it’s not the case in the demo environment. I will provide sample code and I will try to provide a video later to show how it treats the positions.

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

Setting the Basket/Combined Profit Target


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
David @dwgfx Participant
Summary

This topic contains 7 replies,
has 2 voices, and was last updated by David
8 years ago.

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