algo de trading NASDAQ 5 MINUTES

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #199023 quote
    Marlaynicolas
    Participant
    New

    Bonjour à tous ,

    je vous partage une strategie nadasq en 5 minutes en algo.

    Je voudrais intégrer la condition ” si mon trade arrive à temps de bougies par exemple 1000 je voudrais qu’il me coupe la position total ou ce qu’il restera en contrat ” est ce que vous pouvez m’aider à intégrer celle ci dans ce qui suit.

    J’ai beau essayé ma tête fume et rien ne se passe, je ne sais pas ou mettre le paramètre et comment l’écrire.

    Et si quelqu’un pouvait travailler dessus pour réduire les pertes ca serait génial et me donner son avis. si cela vaut le coup de le mettre en route.

    Je vous remercie dans l’attente de vous lire.

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = false // pas de cumul de positions
    DEFPARAM Preloadbars = 1000000
    
    capital= 50000
    
    // 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 = 150000
    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 = 223000
    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 acheteuse
    indicator1 = SenkouSpanA[9,26,52]
    c1 = (close CROSSES OVER indicator1)
    indicator2 = SenkouSpanB[9,26,52]
    c2 = (close CROSSES OVER indicator2)
    c3 = (close > DOpen(0)[1])
    IF (c1 AND c2 ) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    BUY 2 CONTRACT AT MARKET
    partial=0
    ENDIF
     
    // sortie partielle
    if longonmarket and positionperf>1.7/100 and partial=0 then
    sell countofposition/1.5 contract at market
    partial = 1
    endif
    
    // Stops et objectifs
    set stop %loss 2.0
    set target %profit 1.73
    
    
    IF Not OnMarket THEN
    //
    // when NOT OnMarket reset values to default values
    //
    TrailStart    = 65          //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
    winnie37 thanked this post
    #199212 quote
    JC_Bywan
    Moderator
    Master

    Dans la mesure où tu es confiant que ton système ne sort pas pour rerentrer immédiatement, pour sortir à 1000 bougies tu peux tester:

    if summation[1000](longonmarket)=1000 then
    sell at market
    endif
    if summation[1000](shortonmarket)=1000 then
    exitshort at market
    endif
    Marlaynicolas thanked this post
    #199261 quote
    Marlaynicolas
    Participant
    New

    Bonjour merci pour retour,

    Est ce que tu pourrais me l’intégrer dans la stratégie dois je le mettre au début  avant les conditions achat ou âpres?

    Si tu as le temps de me montrer je t’en remerci.

    J’aurai une autre stratégie à partager sur des positions vendeuses cette fois si

    Qaund mon trade arrive à un nombre de bougies de 550 sur mon UT DE 3MIN par exemple je voudrais qu’il coupe toute ma position vendeuse

    Est ce que tu pourrais m’aider?

    Merci à toi

    #199262 quote
    Marlaynicolas
    Participant
    New

    Mon systeme de prend qu’un trade la plupart du temps ou 2 max je t’envoi apres midi une photo des trades pris sur une période de 2 ans

    #199362 quote
    Marlaynicolas
    Participant
    New

    Bonjour je te joins mon algo avec ta suggestion pourrais tu me dire si je l’ai bien placé et peux tu voir si tu diminues le nombre de bougies si les résultats te semble s’améliorer . Ce que je vois je vois ce n’ai que des trades long comment faire pour avoir des trades courts .

    merci a toi

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = false // pas de cumul de positions
    DEFPARAM Preloadbars = 1000000
    
    capital= 50000
    
    // 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 = 150000
    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 = 223000
    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 acheteuse
    indicator1 = SenkouSpanA[9,26,52]
    c1 = (close CROSSES OVER indicator1)
    indicator2 = SenkouSpanB[9,26,52]
    c2 = (close CROSSES OVER indicator2)
    c3 = (close > DOpen(0)[1])
    IF (c1 AND c2 ) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    BUY 2 CONTRACT AT MARKET
    partial=0
    ENDIF
     
    // sortie partielle
    if longonmarket and positionperf>1.7/100 and partial=0 then
    sell countofposition/1.5 contract at market
    partial = 1
    endif
    
    if summation[1000](longonmarket)=1000 then
    sell at market
    endif
    if summation[1000](shortonmarket)=800 then
    exitshort at market
    endif
    
    // Stops et objectifs
    set stop %loss 2.0
    set target %profit 1.73
    
    
    IF Not OnMarket THEN
    //
    // when NOT OnMarket reset values to default values
    //
    TrailStart    = 65          //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
    Capture-decran-86.png Capture-decran-86.png Capture-decran-87.png Capture-decran-87.png Capture-decran-88.png Capture-decran-88.png
    #199388 quote
    JC_Bywan
    Moderator
    Master

    Je l’aurais plutôt mis à la fin, mais davantage par discipline de mettre ce genre de décision de “dernier recours” en dernier le code étant lu de haut en bas que par nécessité spécifique, et/ou pour éviter de se creuser la tête pour voir si certaines lignes peuvent être écrites après, alors que si c’est ça qui est après tout, ça ira. Cela dit une décision de type “si 1000 bougies on cherche pas à savoir on sort”,  il est assez probable sans tout lire que tu obtiennes le même résultat là où tu l’as mis…

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

algo de trading NASDAQ 5 MINUTES


ProOrder : Trading Automatique & Backtests

New Reply
Author
Summary

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

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 08/13/2022
Status: Active
Attachments: 3 files
Logo Logo
Loading...