Bonsoir
En utilisant la fonction CumulateOrders =true, je souhaite néanmoins limiter à par exemple 2 le nombre de shares à engager en buy ou sellshort. Avez vous une solution à m’apporter à coder?
Merci par avance;
Tof
Bonjour, tu peux utiliser une des instructions dédiés à ProBacktest que tu retrouveras dans la documentation prorealtime en ligne du site, ce sont :
COUNTOFLONGSHARES pour la quantité de shares en long orders
et COUNTOFSHORTSHARES pour la quantité de shares en short orders.
Il y a un exemple dans chacune des 2 instructions:
myMACD = MACD[12,26,9](close)
short = myMACD crosses under 0
//first order
IF NOT ShortOnMarket AND short THEN
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
MAXSHARES = COUNTOFSHORTSHARES < 5
//let's add another order while price continue to get higher (more than 10 points) than the last order taken with a condition of 5 bars elapsed since then
IF TRADEINDEX(1)>5 AND TRADEPRICE(1)-Close>10 AND ShortOnMarket AND MAXSHARES THEN
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
SET STOP TRAILING 50
Dans cet exemple on limite le nombre de shares sur le marché en testant la variable MAXSHARES.