Doubts with cumulateorders = true

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #142367 quote
    Fran55
    Participant
    Veteran
    Doubts with cumulateorders = true.
    1. Lets start by the beginning.
    2. Can you have several positions with different stop and profit for each position?
    3. How to program that the first position enters with conditions, stop 1.5% and profit 3%, and places breakeven when it gains 0.5%, and then, when the first position places breakeven, that the second position enters without conditions and without affecting to the breakeven of the first position. For the second position the stop would be 2% and the profit 2.5%. There could be a third position, when the second position rises 0.5% and breakeven, its stop would be 2.5% and its profit 2%.
    Can this be done?
    #142372 quote
    robertogozzi
    Moderator
    Master

    Always use the ‘Insert PRT Code’ button when putting code in your posts, not when writing TEXT.

    1. Lets start by the beginning.
      I agree with this
    2. Can you have several positions with different stop and profit for each position?
      No, you can accumulate more than one position, but there is only one SL and only one TP
    3. How to program that the first position enters with conditions, stop 1.5% and profit 3%, and places breakeven when it gains 0.5%, and then, when the first position places breakeven, that the second position enters without conditions and without affecting to the breakeven of the first position. For the second position the stop would be 2% and the profit 2.5%. There could be a third position, when the second position rises 0.5% and breakeven, its stop would be 2.5% and its profit 2%.
      It can’t be done due to my answer to point 2.
    #142375 quote
    Fran55
    Participant
    Veteran

    OK Roberto, thanks for your answer …

    So I understand that several positions add up to a single position.
    Which brings me inevitably to the next question.

    If there is only one position, the stop would be 1.5% and 3% profit and its breakeven would be placed when it gains 0.5%.
    If another position enters, stop, profit and breakeven are canceled … but I understand that the stop could be 3%, profit 6% and the breakeven would be placed when it gains 1%.
    And if a third position enters, all of the above would be canceled, and we could put a 4.5% stop, 9% profit, and 1.5% to place the breakeven.

    In this way we could have similar conditions, regardless of how many positions there are, despite the circumstances

    Can this be done ??? … or something like that ???

    Please!!!

    #142377 quote
    robertogozzi
    Moderator
    Master

    When you add a position the tradeprice becomes POSITIONPRICE,  which is an average of all entry prices multiplied by the number of lots.

    Do the SL & TP are updated accordingly.

    Percentages will reamain the same, just calculated on a different average price. https://www.prorealcode.com/documentation/positionprice/

    #142379 quote
    Fran55
    Participant
    Veteran

    OKAY.

    I have elaborated all this code but there is something that escapes me.
    Up to € 21,000 of strategyprofit there can only be one position and up to € 10 of position.
    Between € 21,000 and € 28,000 of stategyprofit there may be one or two positions, both of € 10 each … that is, € 20 maximum total position.
    More than 28000 of strategy profit there can be one, two, or three positions, of € 10 each … that is, € 30 maximum total position.

    //Tamaño, Profit y Stop de la posicion
    IF CONDBUY and Strategyprofit <= 21000 and count<maxorders1 THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2.1
    SET STOP %LOSS 1.5
    ENDIF
    
    IF CONDBUY and Strategyprofit >= 21000 and Strategyprofit <= 28000 and count<maxorders1 THEN
    ONCE Positionsize = 10
    buy positionsize contract at market
    SET TARGET %PROFIT 2.1
    SET STOP %LOSS 1.5
    ENDIF
    
    IF CONDBUY and Strategyprofit >= 21000 and Strategyprofit <= 28000 and count<maxorders2 THEN
    ONCE Positionsize = 10
    buy positionsize contract at market
    SET TARGET %PROFIT 4.2
    SET STOP %LOSS 3
    ENDIF
    
    IF CONDBUY and Strategyprofit >= 28000 and count<maxorders1 THEN
    ONCE Positionsize = 10
    buy positionsize contract at market
    SET TARGET %PROFIT 2.1
    SET STOP %LOSS 1.5
    ENDIF
    
    IF CONDBUY and Strategyprofit >= 28000 and count<maxorders2 THEN
    ONCE Positionsize = 10
    buy positionsize contract at market
    SET TARGET %PROFIT 4.2
    SET STOP %LOSS 3
    ENDIF
    
    IF CONDBUY and Strategyprofit >= 28000 and count<maxorders3 THEN
    ONCE Positionsize = 10
    buy positionsize contract at market
    SET TARGET %PROFIT 6.3
    SET STOP %LOSS 4.5
    ENDIF
    
    <span class="tlid-translation translation" lang="en"><span class="" title="">There is a first part that does it well, but then, as seen in the photos, it buys positions of € 20 and € 30, but they should all be € 10</span></span>
    
    Screenshot_4.png Screenshot_4.png Screenshot_5.png Screenshot_5.png
    #142387 quote
    robertogozzi
    Moderator
    Master

    ONCE means ONLY ONE TIME, so they will only be read ONCE on the very first bar.

    Remove the word ONCE.

    #142388 quote
    Fran55
    Participant
    Veteran

    Thanks Roberto.

    I see tomorrow.

    #142400 quote
    Vonasi
    Moderator
    Master

    Fran55 – Please be more careful/tidy when posting. Do not include your questions/comments within the inserted code. I have tidied up your post for you.

    #142406 quote
    Fran55
    Participant
    Veteran

    Ok, sorry.

    I quit “ONCE”, but the problem persist.

    Screenshot_5-1.png Screenshot_5-1.png
    #142409 quote
    robertogozzi
    Moderator
    Master

    We need:

    • to know what is the issue you are talking about
    • full code

    because part of the code you post rely on other parts.

    #142562 quote
    Fran55
    Participant
    Veteran

    I just want all the operations to be € 10.

    In the photos you can see that there are operations € 20 and € 30.

    #142563 quote
    robertogozzi
    Moderator
    Master

    If you want all operations to be 10, just use only one SL and TP set with 10 pips, instead of a percentage.

    #142566 quote
    Fran55
    Participant
    Veteran

    Eureka!

    “ELSE”

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

Doubts with cumulateorders = true


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Fran55 @fran55 Participant
Summary

This topic contains 12 replies,
has 3 voices, and was last updated by Fran55
5 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/23/2020
Status: Active
Attachments: 3 files
Logo Logo
Loading...