Buy 2 shares and sell one with a little profit and one when indicators change

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #5727 quote
    simon_json
    Participant
    Average

    Hi,

    If I would want to:

    Buy 2 shares and sell one with a little profit and one when indicators change, how can I code that?

    Maybe something like this?:

    IF c1>c2 THEN
    
    BUY 2 SHARES AT MARKET
    
    ENDIF
    
    IF "little profit" THEN
    
    SELL 1 SHARES AT MARKET
    
    ENDIF
    IF c1<c2 THEN
    
    SELL "all" AT MARKET
    
    ENDIF

     

    This is an attempt to compensate for a not trending market, with a trend following system.

    Thanks!

    #5728 quote
    simon_json
    Participant
    Average

    Maybe I can use:

    myCurrentProfit = STRATEGYPROFIT

    ?
    But if I want to define the profit in points?

    #5735 quote
    Nicolas
    Keymaster
    Master

    Hi simon, unfortunaly it is not possible to do partial close of the positions.

    About STRATEGYPROFIT, it defines the profit in money but for closed trades, not them actually on market.

    If you want to define the profit in points, you can make a loop through all the orders and make an addition of the whole actual profit:

    for short position example

    tradeprofit=0
    
    if shortonmarket then
    
     for i=0 to countofshortshares-1 do
      tradeprofit=tradeprofit+(tradeprice(i)-close)
     next
    
    endif
    #5763 quote
    simon_json
    Participant
    Average

    Thanks!

    #8313 quote
    Gustaf
    Participant
    Average

    Hi!
    How comes it’s not possible in PRT to partially close your position?
    Many of my “manual” strategies use this, so it’s a bummer if it will never get implemented in ProOrder.

    Do you have any information if it might be possible in the future?

    Cheers!

    #8315 quote
    Nicolas
    Keymaster
    Master

    It’s due to broker convention limitations actually. This is a must have you are right.  I don’t know when it will be available sorry.

    #8317 quote
    Yannick
    Participant
    Veteran

    Hello

    to solve this problem the only Way I found is to run two times the same algorithme with two different take profit …

    #8359 quote
    xozhang
    Participant
    New

    Hi there,

    Same problem here,  my strategy also employs partially closing of positions. I’ve tried to solve this by using a proprietary code for the stop loss and target profit  without using the build-in commands “set stop loss” and set target profit”. But this only solves the problem partially since my timeframe of preference is the 1H, the positions don’t get closed at the preprogrammed  desired levels due to the fact PRT doesn’t close the position until the nextbar open, so if this level differs a lot from the desired closing level then there will be a discrepancy between real trading and backtesting. This discrepancy becomes much smaller when trading the smaller timeframes.

    Regards,

    #12637 quote
    IGOSNELL
    Participant
    Average

    This is unfortunate wanted to forward test a strategy in my demo IG account and then suddenly realised that I could not because  my strategy partially closes positions. I find especially with short positions on the SA TOP 40 index  to take profits helps a lot in making short trades profitable.

    #12700 quote
    David
    Participant
    Veteran

    Nicolas I thought this partial close (x units) objective could be achieved with the floatingprofit code?

    #12709 quote
    Nicolas
    Keymaster
    Master

    Partial close of positions is only possible in paper trading. When you SELL or EXHITSHORT, every positions on market will be closed. I heard it would be possible in the future with the new IG API, but it’s only a “rumor” for now..

    Elsborgtrading and Cosmic1 thanked this post
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

Buy 2 shares and sell one with a little profit and one when indicators change


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
simon_json @simon_json Participant
Summary

This topic contains 10 replies,
has 7 voices, and was last updated by Nicolas
9 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/20/2016
Status: Active
Attachments: No files
Logo Logo
Loading...