Cerrar la mitad de la posición en x porcentaje

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #93567 quote
    KALIA
    Participant
    Junior

    Buenas tardes,

    Backtesteando una estrategia quiero cerrar la mitad de las acciones compradas cuando llega al 15%. Lo que ocurre es que al día siguiente si la posición se mantiene sobre el 15% me vuelve a vender la mitad de las acciones que quedan. Lo que quiero hacer es que solo venda la mitad un vez y que el resto de la posición se cierre con otra condición.

    IF c1 AND c2 AND c3 OR c9 THEN
    BUY 2500 CASH AT Average[50](close) * 1.0001 LIMIT
    ENDIF
    
    // Condiciones de salida de posiciones largas
    indicator5 = Average[10](close)
    indicator6 = Average[50](close)
    c4 = (indicator5 CROSSES UNDER indicator6)
    
    
    IF POSITIONPERF > 0.15 THEN
    SELL 1250 CASH AT MARKET
    ELSIF c4 THEN
    SELL AT MARKET
    ENDIF
    #93574 quote
    robertogozzi
    Moderator
    Legend

    El cierre parcial no es posible en el comercio automático, solo en backtesting.

    #93587 quote
    KALIA
    Participant
    Junior

    Yo lo quiero para BackTesting. Lo que ocurre es que quiero vender la mitad de la posición solo una vez cuando este llega al 15%. En el BackTest me vende en la vela que llega al porcentaje y en la siguiente también si el porcentaje se mantiene por encima del nivel marcado.

    #93628 quote
    robertogozzi
    Moderator
    Legend

    Debe utilizar una variable como señal de que, una vez que se realiza la primera venta, no hace ninguna otra, por ejemplo:

    IF c1 AND c2 AND c3 OR c9 THEN
    BUY 2500 CASH AT Average[50](close) * 1.0001 LIMIT
    ENDIF
     
    // Condiciones de salida de posiciones largas
    IF Not OnMarket THEN
       Vender = 1
    ENDIF
    indicator5 = Average[10](close)
    indicator6 = Average[50](close)
    c4 = (indicator5 CROSSES UNDER indicator6)
    IF POSITIONPERF > 0.15 AND Vender THEN
       SELL 1250 CASH AT MARKET
       Vender = 0
    ELSIF c4 THEN
       SELL AT MARKET
    ENDIF
    KALIA thanked this post
    #99926 quote
    KALIA
    Participant
    Junior

    Muchas gracias.

    Hacía muchos días que no entraba en la plataforma y acabo de ver tu respuesta. Lo pruebo como dices.

    Un saludo.

Viewing 5 posts - 1 through 5 (of 5 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

Cerrar la mitad de la posición en x porcentaje


ProOrder: Trading Automático y Backtesting

New Reply
Author
author-avatar
KALIA @kalia Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by KALIA
7 years, 3 months ago.

Topic Details
Forum: ProOrder: Trading Automático y Backtesting
Language: Spanish
Started: 03/13/2019
Status: Active
Attachments: No files
Logo Logo
Loading...