Chiusura parziale dell’operazione

Viewing 7 posts - 16 through 22 (of 22 total)
  • Author
    Posts
  • #197393 quote
    Marlaynicolas
    Participant
    New

    Ciao roberto,

    Avrò bisogno del tuo aiuto per l’integrazione di vendita parziale su una strategia algoritmica di 2 minuti di euro che ho condiviso. E non posso integrare la formula è quello che puoi aiutarmi ringraziandoti e avendo la tua opinione in merito.

    Cordiali saluti

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
     
    // Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiée
    noEntryBeforeTime = 080000
    timeEnterBefore = time >= noEntryBeforeTime
     
    // Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiée
    noEntryAfterTime = 192000
    timeEnterAfter = time < noEntryAfterTime
     
    // Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
     
    // Conditions pour ouvrir une position en vente à découvert
    indicator1 = SenkouSpanB[9,26,52]
    c1 = (close >= indicator1)
    indicator2 = SenkouSpanB[9,26,52]
    c2 = (low[1] < indicator2)
     
    IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry and tally < maxTrades THEN
    sellshort 1 CONTRACT AT MARKET
    ENDIF
     
    //---------------------------------------------------------------------------------------------------------------
    once maxTrades = 3                               //maxNumberDailyTrades
    once tally = 0
    if intradayBarIndex = 0 then
    tally = 0
    endif
     
    newTrades =  (onMarket and not onMarket[1]) or ((not onMarket and not onMarket[1]) and (strategyProfit <> strategyProfit[1])) or (longOnMarket and ShortOnMarket[1]) or (longOnMarket[1] and shortOnMarket) or ((tradeIndex(1) = tradeIndex(2)) and (barIndex = tradeIndex(1)) and (barIndex > 0) and (strategyProfit = strategyProfit[1]))
     
    if newTrades then
    tally = tally +1
    endif
    //------------------------------------------------------------------------------------------------------------------------
    //---------------------------------------------------------------------------------------------------------------
    //Max-Orders per Day
    once maxOrdersL = 1  //long
    once maxOrdersS = 1  //short
    if intradayBarIndex = 0 then //reset orders count
    ordersCountL = 0
    ordersCountS = 0
    endif
     
    if longTriggered then //check if an order has opened in the current bar
    ordersCountL = ordersCountL + 1
    endif
    if shortTriggered then //check if an order has opened in the current bar
    ordersCountS = ordersCountS + 1
    endif
    //------------------------------------------------------------------------------------------------------------------------
    // Stops et objectifs
    set stop %loss 0.58
    set target %profit 0.81
     
    IF Not OnMarket THEN
    //
    // when NOT OnMarket reset values to default values
    //
    TrailStart    = 1.79         //30     Start trailing profits from this point
    BasePerCent   = 0.000       //20.0%  Profit percentage to keep when setting BerakEven
    StepSize      = 1          //10     Pip chunks to increase Percentage
    PerCentInc    = 0.000       //10.0%  PerCent increment after each StepSize chunk
    BarNumber     = 10          //10     Add further % so that trades don't keep running too long
    BarPerCent    = 0.235       //10%    Add this additional percentage every BarNumber bars
    RoundTO       = -0.5        //-0.5   rounds always to Lower integer,   +0.4 rounds always to Higher integer,     0 defaults PRT behaviour
    PriceDistance = 9 * pipsize //7      minimun distance from current price
    y1            = 0           //reset to 0
    y2            = 0           //reset to 0
    ProfitPerCent = BasePerCent //reset to desired default value
    TradeBar      = BarIndex
    ELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN                              //LONG positions
    //
    // compute the value of the Percentage of profits, if any, to lock in for LONG trades
    //
    x1 = (close - tradeprice) / pipsize                                     //convert price to pips
    IF x1 >= TrailStart THEN                                                //    go ahead only if N+ pips
    Diff1         = abs(TrailStart - x1)                                 //difference from current profit and TrailStart
    Chunks1       = max(0,round((Diff1 / StepSize) + RoundTO))           //number of STEPSIZE chunks
    ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc)) //compute new size of ProfitPerCent
    // compute number of bars elapsed and add an additionl percentage
    // (this percentage is different from PerCentInc, since it's a direct percentage, not a Percentage of BasePerCent)
    // (if BasePerCent is 20% and this is 10%, the whole percentage will be 30%, not 22%)
    BarCount      = BarIndex - TradeBar
    IF BarCount MOD BarNumber = 0 THEN
    ProfitPerCent = ProfitPerCent + BarPerCent
    ENDIF
    //
    ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))         //make sure ProfitPerCent doess not exceed 100%
    y1 = max(x1 * ProfitPerCent, y1)                                     //y1 = % of max profit
    ENDIF
    ELSIF ShortOnMarket AND close < (TradePrice - (y2 * pipsize)) THEN                             //SHORT positions
    //
    // compute the value of the Percentage of profits, if any, to lock in for SHORT trades
    //
    x2 = (tradeprice - close) / pipsize                                     //convert price to pips
    IF x2 >= TrailStart THEN                                                //      go ahead only if N+ pips
    Diff2         = abs(TrailStart - x2)                                 //difference from current profit and TrailStart
    Chunks2       = max(0,round((Diff2 / StepSize) + RoundTO))           //number of STEPSIZE chunks
    ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc)) //compute new size of ProfitPerCent
    // compute number of bars elapsed and add an additionl percentage
    // (this percentage is different from PerCentInc, since it's a direct percentage, not a Percentage of BasePerCent)
    // (if BasePerCent is 20% and this is 10%, the whole percentage will be 30%, not 22%)
    BarCount      = BarIndex - TradeBar
    IF BarCount MOD BarNumber = 0 THEN
    ProfitPerCent = ProfitPerCent + BarPerCent
    ENDIF
    //
    ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))         //make sure ProfitPerCent doess not exceed 100%
    y2 = max(x2 * ProfitPerCent, y2)                                     //y2 = % of max profit
    ENDIF
    ENDIF
    IF y1 THEN                                                                 //Place pending STOP order when y1 > 0   (LONG positions)
    SellPrice = Tradeprice + (y1 * pipsize)                                 //convert pips to price
    //
    // check the minimun distance between ExitPrice and current price
    //
    IF abs(close - SellPrice) > PriceDistance THEN
    //
    // place either a LIMIT or STOP pending order according to current price positioning
    //
    IF close >= SellPrice THEN
    SELL AT SellPrice STOP
    ELSE
    SELL AT SellPrice LIMIT
    ENDIF
    ELSE
    //
    //sell AT MARKET when EXITPRICE does not meet the broker's minimun distance from current price
    //
    SELL AT Market
    ENDIF
    ENDIF
    IF y2 THEN                                                                 //Place pending STOP order when y2 > 0   (SHORT positions)
    ExitPrice = Tradeprice - (y2 * pipsize)                                 //convert pips to price
    //
    // check the minimun distance between ExitPrice and current price
    //
    IF abs(close - ExitPrice) > PriceDistance THEN
    //
    // place either a LIMIT or STOP pending order according to current price positioning
    //
    IF close <= ExitPrice THEN
    EXITSHORT AT ExitPrice STOP
    ELSE
    EXITSHORT AT ExitPrice LIMIT
    ENDIF
    ELSE
    //
    //ExitShort AT MARKET when EXITPRICE does not meet the broker's minimun distance from current price
    //
    EXITSHORT AT Market
    ENDIF
    ENDIF
    #197394 quote
    robertogozzi
    Moderator
    Master

    Va bene, dimmi quanti lotti vuoi vendere (adesso ne vende solo 1) e quanti ne vuoi chiudere parzialmente e le condizioni per chiuderli.

    #197395 quote
    Marlaynicolas
    Participant
    New

    Salve a tutti, inserisco la mia richiesta.

    Ho condiviso una strategia algo di 2 minuti eurusd e sto cercando di integrare in questa strategia la vendita parziale in percentuale quando quella arriva (ad esempio a 15 euro. Vorrei che mi vendesse lo 0,5% della posizione.)

    Ho provato quello che mi è stato suggerito ma non ha funzionato. non sta succedendo niente. Se potessi aiutarmi penso che potrebbe migliorare i guadagni.

    E a proposito, cosa ne pensi della strategia?

    Non vedo l’ora di leggerti e grazie.

    #197396 quote
    Marlaynicolas
    Participant
    New

    Scusa, ho dovuto inviare più messaggi. Quindi vorrei come puoi vedere quando mi prende un contratto in vendita e quando la posizione arriva a +12 o + 15 o +20 euro non importa voglio che mi compri 0,5 il contratto mira a quello secondo i contratti che prendo voglio che mi metta al sicuro la metà e che il commercio scivoli via.

    #197407 quote
    Marlaynicolas
    Participant
    New

    désolé roberto la traduction Français italien n’ai pas correcte.
    Je te le transmet en Français.
    Je voudrais dans le cas de mon alogo qu’il rachète 0.5 contrat sur les 1 contrat qu’il a pris sur le mini eurusd lorsque que le trade arrive à +12 euros par exemple ou + 15 par exemple.
    et laisser filer le trade avec les contrats restant. Mais je n’arrive pas à l’intégrer dans ma formule donc si tu pouvais m’aider. c’est un algo qui tourne avec 5 contrats à l’origine.
    jt’en remercie d’avance.

    scusa roberto la traduzione francese italiano non era corretta. Te lo mando in francese. Nel caso del mio alogo, vorrei che riacquistasse 0,5 contratti su 1 contratto che ha preso sul mini euro quando lo scambio raggiunge ad esempio +12 euro o +15 ad esempio. e lascia perdere il commercio con i restanti contratti. Ma non posso integrarlo nella mia formula quindi se potessi aiutarmi. è un algoritmo che funziona originariamente con 5 contratti. Ti ringrazio anticipatamente.

    #197429 quote
    robertogozzi
    Moderator
    Master

    @Marlaynicolas

    Pubblica solo nella lingua del forum in cui stai postando. Ad esempio solo l’inglese nei forum di lingua inglese e il francese solo nei forum di lingua francese.

    Grazie 🙂

    #197435 quote
    robertogozzi
    Moderator
    Master

    @Marlaynicolas

    NON DUPLICARE i tuoi post, per favore, mi sembra questo sia identico a https://www.prorealcode.com/topic/strategie-eur-usd-2-min/.

    Mi sembra ti sia già stato risposto, almeno inizialmente, nel forum Francese.

Viewing 7 posts - 16 through 22 (of 22 total)
  • You must be logged in to reply to this topic.

Chiusura parziale dell’operazione


ProOrder: Trading Automatico & Backtesting

New Reply
Author
Summary

This topic contains 21 replies,
has 6 voices, and was last updated by robertogozzi
3 years, 6 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 11/26/2020
Status: Active
Attachments: No files
Logo Logo
Loading...