Accumulate and average exit

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12751 quote
    CMac
    Participant
    New

    Hi Everyone,

    I’m trying to achieve something I believe is very simple but I am having a few troubles. What I would like is an average exit price of different entry prices and quantities when I set accumulate to true but cant seem to get it to work as expected. After reading as much as possible it seems profit target is meant to do this but it doesnt. I have tried using other commands in code such as positionprice but with no success. Any help would be great.

    Many Thanks

    Carter

    #12764 quote
    Nicolas
    Keymaster
    Master

    Hi,

    Do you mean you need to set an exit price for the whole basket in relation to their mean open price?

    POSITIONPRICE give you the average open price of the whole open orders. If you need to exit them at 5 points from it, you have to set a STOP or a LIMIT order at that price.

    #12795 quote
    CMac
    Participant
    New

    Hi Nicolas,

    Thank you for your reply, please see some code below for example. I’m not sure of the correct syntax to achieve this. Yes I want to achieve an average of the whole basket of orders.

    Thanks

    Carter

    // Definition of code parameters
    DEFPARAM CumulateOrders = true
    // Cumulating positions deactivated
    
    // Conditions to enter long positions
    indicator1 = high - ExponentialAverage[13](close)
    indicator2 = high - ExponentialAverage[13](close)
    c1 = (indicator1 >= indicator2[1])
    
    indicator3 = high - ExponentialAverage[13](close)
    c2 = (indicator3 < -20)
    
    IF c1 AND c2 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    exitprice = POSITIONPRICE + 15
    
    sell at exitprice stop
    
    // Stops and targets
    //SET TARGET pPROFIT 10
    #12797 quote
    Nicolas
    Keymaster
    Master

    I don’t know about the entry logic, but the exit one seems ok to me. You should adapt your exitprice variable to any instrument like this:

    exitprice = POSITIONPRICE + 15*pipsize
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Accumulate and average exit


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
CMac @cmac Participant
Summary

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

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