Entrée longue en erreur

Forums ProRealTime forum Français Support ProBuilder Entrée longue en erreur

Viewing 10 posts - 1 through 10 (of 10 total)
  • #242752

    Bonjour,

    je rencontre un problème dans ce code. Je souhaiterai entrer long lorsque les cours sont au-dessus des Kama 150 sur les unités de temps 1h et 15 min. Or en faisant un back test, une entrée longue a été faite le 25 novembre 2024 (et ce n’est pas la seule date qui pose problème). Or d’après mon graphique en 1 heure, les cours étaient au dessous de la kama150 à cette période.

    Pourriez-vous m’indiquer ce qui cloche dans mon code ?

    merci.

    #242753

    le code en entier

    Timeframe (1 hour)

    Period1h = 150
    FastPeriod1h = 2
    SlowPeriod1h = 50

    Fastest1h = 2 / (FastPeriod1h + 1)
    Slowest1h = 2 / (SlowPeriod1h + 1)
    if barindex < Period1h+1 then
    Kama1h=close
    else
    Num1h = abs(close-close[Period1h])
    Den1h = summation[Period1h](abs(close-close[1]))
    ER1h = Num1h / Den1h
    Alpha1h = SQUARE(ER1h *(Fastest1h – Slowest1h )+ Slowest1h)
    KAMA1h = (Alpha1h * Close) + ((1 -Alpha1h)* Kama1h[1])
    endif

    Timeframe (15 minutes)
    /////////////////////////////////////////////////////////////////// parameters KAMA

    Period15min = 150
    FastPeriod15min = 2
    SlowPeriod15min = 50

    Fastest15min = 2 / (FastPeriod15min + 1)
    Slowest15min = 2 / (SlowPeriod15min + 1)
    if barindex < Period15min+1 then
    Kama15min=close
    else
    Num15min = abs(close-close[Period15min])
    Den15min = summation[Period15min](abs(close-close[1]))
    ER15min = Num15min / Den15min
    Alpha15min = SQUARE(ER15min *(Fastest15min – Slowest15min )+ Slowest15min)
    KAMA15min = (Alpha15min * Close) + ((1 -Alpha15min)* Kama15min[1])
    endif

    //————————————-//
    //PRC_RSI Cyclic Smoothed
    //version = 0
    //19.11.2024
    //Iván González @ http://www.prorealcode.com
    //Sharing ProRealTime knowledge
    //————————————-//
    //Inputs
    //————————————-//
    src15min=close
    domcycle15min=20
    cyclelen15min=domcycle15min/2
    vibration15min=10
    leveling15min=10
    cyclicmemory15min=domcycle15min*2

    once crsi15min=0
    //————————————-//
    // CRSI calculation
    //————————————-//
    torque15min=2/(vibration15min+1)
    phasinglag15min=floor((vibration15min-1)/2)

    length15min = cyclelen15min
    alpha15min = 1/length15min

    srcUp15min = max(src15min-src15min[1],0)
    if barindex = length15min then
    up15min = average[length15min](srcUp15min)
    else
    up15min = alpha15min*srcUp15min + (1-alpha15min)*up15min[1]
    endif

    srcDw15min = -min(src15min-src15min[1],0)
    if barindex = length15min then
    dw15min = average[length15min](srcdw15min)
    else
    dw15min = alpha15min*srcdw15min + (1-alpha15min)*dw15min[1]
    endif

    if dw15min=0 then
    myrsi15min=100
    elsif up15min=0 then
    myrsi15min=0
    else
    myrsi15min=100-100/(1+up15min/dw15min)
    endif
    if barindex>cyclicmemory15min then
    crsi15min=torque15min*(2*myrsi15min-myrsi15min[phasinglag15min])+(1-torque15min)*crsi15min[1]
    endif
    //————————————-//
    // LowBand and HighBand calculation
    //————————————-//
    Period15min=cyclicMemory15min
    percent15min = leveling15min/100
    periodMinusone15min = period15min-1
    maxima15min = -999999.0
    minima15min = 999999.0

    for i15min=0 to periodMinusone15min do

    if crsi15min[i15min] > maxima15min then
    maxima15min = crsi15min[i15min]
    elsif crsi15min[i15min] < minima15min then
    minima15min = crsi15min[i15min]
    endif
    next

    stepfactor15min = (maxima15min-minima15min)/100
    lowband15min = 0

    for steps15min=0 to 100 do
    testvalue15min = minima15min+stepfactor15min*steps15min
    below15min=0
    for m15min=0 to periodMinusone15min do
    if crsi15min[m15min]<testvalue15min then
    below15min=below15min+1
    endif
    next
    if below15min/period15min >= percent15min then
    lowband15min = testvalue15min
    break
    endif
    next

    highband15min=0
    for steps15min=0 to 100 do
    testvalue15min=maxima15min-stepfactor15min*steps15min
    above15min=0
    for m15min=0 to periodMinusone15min do
    if crsi15min[m15min]>=testvalue15min then
    above15min=above15min+1
    endif
    next
    if above15min/Period15min >= percent15min then
    highband15min=testvalue15min
    break
    endif
    next

    mbb15min = average[50](crsi15min)
    CRSISmooth15min = average[7](crsi15min)

     

    LongPos =  (kama1h > kama1h[1]) and (close > kama1h) and (kama15min > kama15min[1]) and (close > kama15min) and (CRSI15min crosses over CRSISmooth15min)

    if longpos then
    buy 1 contract at market
    endif

    ///trailing stop function
    trailingstart = 5 //trailing will start @trailinstart points profit
    trailingstep = 5 //trailing step to move the “stoploss”

    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF

    //manage long positions
    IF LONGONMARKET THEN
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF

    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF

    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF

    // points based STOP LOSS and TRAILING STOP
    // initial STOP LOSS
    SET STOP pLOSS 50

    // trailing stop
    SET STOP pTRAILING 50

     

    #242754

    regarder les deux screens
    un avec 1K unité et l’autre avec 5 K

    #242759

    Voici mon système  (J’ai ajouté UPDATEONCLOSE aux deux timeframe, puis j’ai ajouté le timeframe défaut):

     

     

    1 user thanked author for this post.
    #242784

    Grazie Roberto.

    Je vais regarder.

    Merci.

    #242785

    Pour revenir aux deux écrans, tu conseilles 5K unités ?

    #242789

    Pour les premières vérifications de code, 5K unités peuvent être suffisants, mais lorsque vous effectuez des backtests définitifs, je vous recommande d’en utiliser beaucoup plus. J’utilise 200K (le maximum).

    #242790

    D’accord. merci pour la rapidité de la réponse. Une dernière demande : l’indicateur corrigé par vous est-il transposable en screener ? Si oui, je ferai une demande dans le forum adéquat.

    #242792

    Pour revenir aux deux écrans, tu conseilles 5K unités ?
    oui

    1 user thanked author for this post.
    #242794

    merci fifi743

Viewing 10 posts - 1 through 10 (of 10 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login