Salut.
J’essaye de trouver un moyen pour que ma variable TSL ,qui est la taille de mon stop loss, soit utilisé dans mon calcul de risque, dans la variable StopLoss (ligne19, pour remplacer le 10)
Si vous avez une idée, je suis prenneur.
Merci
DEFPARAM cumulateOrders = False
Defparam flatafter = 160000
once StartE = 80000
once StartL = 113000
once Period = 15
once Period2 = 15
Series = (open+high+low+Close)/4
Seriesv2 = (open+high+low+Close)/4
OTD = Barindex - TradeIndex(1) > IntradayBarIndex
TSL = round(100/10000*close)
////////////////////////////////////
REM Money Management
Capital = 10000
Risk = 0.01
StopLoss = 10// Je voudrais ici que ma variable TSL soit utilisé.
REM Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*Risk)
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
//PUT AFR AND AFRv2 HERE//
Period = MAX(Period, 2)
alpha = 2 / (1 + Period)
IF BarIndex = 0 THEN
p1 = Series
p2 = Series
ELSE
p1 = p1[1] + alpha * (Series - p1[1])
p2 = p2[1] + alpha * (p1 - p2[1])
ENDIF
AFR = (((2 - alpha) * p1 - p2) / (1 - alpha))
Period2 = MAX(Period2, 1)
MA1 = ExponentialAverage[Period2](Seriesv2)
MA2 = ExponentialAverage[Period2](MA1)
MA3 = ExponentialAverage[Period2](MA2)
MA4 = ExponentialAverage[Period2](MA3)
MA5 = ExponentialAverage[Period2](MA4)
MA6 = ExponentialAverage[Period2](MA5)
MA7 = ExponentialAverage[Period2](MA6)
MA8 = ExponentialAverage[Period2](MA7)
AFRV2 = (8 * MA1) - (28 * MA2) + (56 * MA3) - (70 * MA4) + (56 * MA5) - (28 * MA6) + (8 * MA7) - MA8
/////////////////////////////////////
wAFR = exponentialaverage[30](AFR)
wAFRv2 = exponentialaverage[30](AFRv2)
if time >= StartE And time <= StartL and OTD then
IF wAFR > wAFRv2 and wAFR[1] < wAFRv2[1] then
BUY PositionSize CONTRACTS AT MARKET
SET STOP PLOSS TSL
//SET STOP PTRAILING TSL
//SET TARGET PPROFIT TSL
else
if wAFR < wAFRv2 and wAFR[1] > wAFRv2[1] then
SELLSHORT PositionSize CONTRACTS AT MARKET
SET STOP PLOSS TSL
//SET STOP PTRAILING TSL
//SET TARGET PPROFIT TSL
endif
endif
endif
De mémoire, voici ce que j’ai essayé.
Si l’ EURUD =1.15
Alors mon TSL =0.0115, soit 115 pips
Je ne peux pas mettre 0.0115. Et si jele multiplie par 10000, il me semble que ma perte maximale et superieur a 1% de mon capital. Ou que a 300$ de capital, le probacktest ne fonctionne plus et ne prend plus de positions.(de mémoire, je ne suis pas devant le pc)
Quelquechose comme :
StopLoss = TSL/pointvalue
Par contre puisqu’il est dynamique (TSL), attention à ne pas modifier la taille de ton stoploss lorsque tu es déjà au marché, et c’est ce que tu fais, sauf erreur de ma part, aux lignes 66 et 72.
Merci Nicolas.
Ma variable s’appelle TSL car je ne l’ai pas changer, mais mon stop loss est fixe.