Bonjour,
je travaille sur un code dans lequel je voudrais que le trade (Achat ) soit clôturé
si la close passe sous SUPERTREND 3.10
J’ai un souci car ça ne fonctionne pas et je ne trouve pas la solution pour remédier au problème
DEFPARAM CumulateOrders = false // FALSE or TRUE
DEFPARAM Preloadbars = 3000
DEFPARAM flatafter = 214500
// TAILLE DES POSITIONS
level = 1
// TARGET ET STOP
tp = 33
//sl = 80
RSI14 = rsi[14]
ST = supertrend [3,10]
A1 = close > ST
A2 = RSI14 >= 50 and RSI14 <= 64.5
// HORAIRES DE TRADING
TimeAchat = time >= 080500 and time < 190000
//TimeVente = time >= 080500 and time < 190000
// CONDITION POUR ACHAT
IF not longonmarket and A1 and A2 and TimeAchat then
BUY level shares at market
SET TARGET pPROFIT tp
//SET STOP pLOSS sl
If close crosses under ST then
sell level shares at market
ENDIF
endif
// CLOTURE DÉFINITIVE DE TOUS LES TRADES -- 19 Heures --
IF Longonmarket and time >= 215500 THEN
SELL AT MARKET
ENDIF
d’où vient le problème.
Merci pour une aide sur le sujet
Cordialement
Bonjour,
tu as mis ton bloc “if endif” de vente du passage sous supertrend en lignes 35-37 à l’intérieur du bloc “if endif” d’achat des lignes 31-39, ce qui fait que ce n’est lu qu’une fois, en même temps que la décision d’achat, mais pas les bougies d’après. Il faut le mettre à part, comme le bloc des lignes 42-44
(dit autrement, essaye en déplaçant un endif ainsi:)
IF not longonmarket and A1 and A2 and TimeAchat then
BUY level shares at market
endif
SET TARGET pPROFIT tp
//SET STOP pLOSS sl
If close crosses under ST then
sell level shares at market
ENDIF
Merci Noobywan,
je vais corriger et tester ça
Bon après-midi
Cordialement