la modification ne change rien…. 🙁
ci-dessous l’erreur remontée
// Définition des paramètres du code
Defparam CumulateOrders = False
Defparam Preloadbars = 30000
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
Distance = 15
LookBack = 15000
SR = 9
// Timeframe SRLevel
timeframe (30 minutes, updateonclose)
// --- icihmoku support and resistance
kijun = (highest[26](high)+lowest[26](low))/2
SSB = (highest[52](high[26])+lowest[52](low[26]))/2
kijunp = summation[SR](Kijun=Kijun[1])=SR
ssbp = summation[SR](SSB=SSB[1])=SR
if kijunp then
kijunPrice = kijun
endif
if ssbp then
ssbPrice = SSB
endif
if kijunprice = ssbprice then
SRlevel = kijunprice
endif
//Timeframe en UT de Trading
Timeframe (10 seconds, default)
//************************************************************************
levier = 2
capital = 500 + (strategyprofit*2/5)
z = (capital / (close/20)) * levier
//************************************************************************
//Position acheteuse
buycondition = rsi[14] crosses over 50
buycondition2 = x Crosses Over 0.7 and Summation[2](x > 0.5) = 2
if Buycondition and not onmarket and not daysForbiddenEntry then
allowtrading = 1
for iSRB = 0 to lookback -1 do
dist = abs(close-SRlevel[iSRB]) < distance*pipsize
if dist then
allowtrading = 0 //no trading is allowed we are near a SR!
break //break the loop, no need to continue, trading is not allowed anymore!
endif
next
If BuyCondition2 then
Entry = Barindex
endif
if Barindex-Entry <= 2 then
if allowtrading then
buy z share at market
endif
endif
endif
//Position Vendeuse
sellcondition = rsi[14] crosses under 50
sellcondition2 = x Crosses Over 0.7 and Summation[2](x > 0.5) = 2
if SellCondition and not onmarket and not daysForbiddenEntry then
allowtrading = 1
for iSRV = 0 to lookback -1 do
dist = abs(close-SRlevel[iSRV]) < distance*pipsize
if dist then
allowtrading = 0 //no trading is allowed we are near a SR!
break //break the loop, no need to continue, trading is not allowed anymore!
endif
next
if SellCondition2 then
Entry = Barindex
endif
If Barindex-Entry <= 2 then
if allowtrading then
sellshort z share at market
endif
endif
endif
//************************************************************************
//Stop Loss & Trailing function
Set stop $loss capital*levier*4/100
Set Target $Profit capital*levier*5/100
Ci-dessus, la partie du code qui semble poser problème.
je me demande si ce n’est pas un problème de preloadbars entre les deux timeframe…
Un lookback de 15.000 bars est énorme ! Une boucle sur 15000 chandeliers c’est beaucoup trop, même si celle-ci n’ira jamais jusqu’au bout, puisqu’on trouvera un support ou une résistance avant d’arriver au terme de celle-ci.
Bref, le problème principale dans ton cas, c’est surtout que ProOrder ne peut pas charger plus de 10.000 unités d’historique, donc ta boucle ne peut pas dépasser cette valeur !
Je vais faire quelques tests… Je te revient lorsque j’ai réglé le soucis…. Je vais baisser la valeur à 10.000 dans un premier temps….
Merci du retour
Bjr Nicolas,
Problème réglé!
baisser LookBack à 9999 à réglé les arrêts.
Merci pour le retour.
Defparam CumulateOrders = False
Defparam Preloadbars = 43200
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
Distance = 8
LookBack = 5000
SRk = 5
SRs = 8
// --- icihmoku support and resistance
kijun = (highest[26](high)+lowest[26](low))/2
SSB = (highest[52](high[26])+lowest[52](low[26]))/2
kijunp = summation[SRk](Kijun=Kijun[1])=SRk
ssbp = summation[SRs](SSB=SSB[1])=SRs
if kijunp then
kijunPrice = kijun
endif
if ssbp then
ssbPrice = SSB
endif
if kijunprice = ssbprice then
SRlevel = kijunprice
if SRLevel > Close then
ResLevel = SRlevel
elsif SRLevel < Close then
SupLevel = SRlevel
endif
endif
//************************************************************************
levier = 2
capital = 500 + (strategyprofit*2/5)
z = (capital / (close/20)) * levier
//************************************************************************
//Buy Conditions
buycondition = rsi[14] crosses over 50
buycondition2 = x Crosses Over 0.7 and Summation[2](x > 0.5) = 2
if Buycondition and not onmarket and not daysForbiddenEntry then
allowtrading = 1
for iSRB = 0 to lookback -1 do
dist = (Reslevel[iSRB] - Close) < distance*pipsize
if dist then
allowtrading = 0 //no trading is allowed we are near a SR!
break //break the loop, no need to continue, trading is not allowed anymore!
endif
next
If BuyConditionL then
Entry = Barindex
endif
if Barindex-Entry <= 2 then
if allowtrading then
buy z share at market
endif
endif
endif
//Sell Conditions
sellcondition = rsi[14] crosses over 50
sellcondition2 = x Crosses Over 0.7 and Summation[2](x > 0.5) = 2
if sellcondition and not onmarket and not daysForbiddenEntry then
allowtrading = 1
for iSRV = 0 to lookback -1 do
dist = (close-Suplevel[iSRV]) < distance*pipsize
if dist then
allowtrading = 0 //no trading is allowed we are near a SR!
break //break the loop, no need to continue, trading is not allowed anymore!
endif
next
if SellCondition2 then
Entry = Barindex
endif
If Barindex-Entry <= 2 then
if allowtrading then
sellshort z share at market
endif
endif
endif
//************************************************************************
//Stop Loss & Trailing function
Set stop $loss capital*levier*4/100
Set Target $Profit capital*levier*5/100
Quelques corrections sur le code.
De cette manière les Supports et Résistances sont clairement identifiés.
Dans le même registre, est ce qu’il est possible de créer une boucle sur les mêmes conditions de distance, avec les supports et résistances du pivot (pivot compris)
Pivot = (Dhigh(1) + Dlow(1) + Dclose(1) + Dopen(0))/4 //Pivot
Res3 = Dhigh(1)+(2*(Pivot-Dlow(1))) //Res3
Res2 = Pivot+(Dhigh(1)-Dlow(1)) //Res2
Res1 = (2*Pivot) - Dlow(1) //Res1
Sup1 = (2*Pivot) - Dhigh(1) //Sup1
Sup2 = Pivot-(Dhigh(1)-Dlow(1)) //Sup2
Sup3 = Dlow(1)-(2*(Dhigh(1)-Pivot)) //Sup3
Merci pour l’aide.
J’ai géré comme ci-dessous:
//Pivot (H + L + C + O)/4
If OpenDayOfWeek = 1 Then
Ht = DHigh(2)
Bs = DLow(2)
C = DClose(2)
O = DOpen(0)
Endif
If OpenDayOfWeek => 2 and dayofweek < 6 Then
Ht = DHigh(1)
Bs = DLow(1)
C = DClose(1)
O = DOpen(0)
Endif
Pivot = (Ht + Bs + C + O)/4
Res4 = Ht + (3*(Pivot - BS))
Res3 = Ht + (2*(Pivot - Bs))
Res2 = Pivot + (Ht - Bs)
Res1 = (2*Pivot) - Bs
Sup1 = (2*Pivot) - Ht
Sup2 = Pivot-(Ht - Bs)
Sup3 = Bs - (2*(Ht - Pivot))
Sup4 = Bs - (3*(Ht - Pivot))
// Position acheteuse
if close > pivot then
//above Pivot
iPivt = 1
while iPivt =< 4 do
if iPivt = 1 then
Floor = Pivot
Ceil = Res1
if close > Floor and close < Ceil then
break
endif
elsif iPivt = 2 then
Floor = Res1
Ceil = Res2
if close > Floor and close < Ceil then
break
endif
elsif iPivt = 3 then
Floor = Res2
Ceil = Res3
if close > Floor and close < Ceil then
break
endif
elsif iPivt = 4 then
Floor = Res3
Ceil = Res4
if close > Floor and close < Ceil then
break
endif
endif
iPivt = iPivt + 1
wend
elsif close < Pivot then
//below Pivot
iPivt = 1
while iPivt <= 4 do
if iPivt = 1 then
Floor = Sup1
Ceil = Pivot
if close > Floor and close < Ceil then
break
endif
elsif iPivt = 2 then
Floor = Sup2
Ceil = Sup1
if close > Floor and close < Ceil then
break
endif
elsif iPivt = 3 then
Floor = Sup3
Ceil = Sup2
if close > Floor and close < Ceil then
break
endif
elsif iPivt = 4 then
Floor = Sup4
Ceil = Sup3
if close > Floor and close < Ceil then
break
endif
endif
iPivt = iPivt + 1
wend
endif
For IPivt = 1 to 4 do
dist = (Ceil - Close) < distance*pipsize
If Dist then
allowtrading = 0
Break
endif
next
// Position vendeuse
if close > pivot then
//above Pivot
iPivt = 1
while iPivt =< 4 do
if iPivt = 1 then
Floor = Pivot
Ceil = Res1
if close > Floor and close < Ceil then
break
endif
elsif iPivt = 2 then
Floor = Res1
Ceil = Res2
if close > Floor and close < Ceil then
break
endif
elsif iPivt = 3 then
Floor = Res2
Ceil = Res3
if close > Floor and close < Ceil then
break
endif
elsif iPivt = 4 then
Floor = Res3
Ceil = Res4
if close > Floor and close < Ceil then
break
endif
endif
iPivt = iPivt + 1
wend
elsif close < Pivot then
//below Pivot
iPivt = 1
while iPivt <= 4 do
if iPivt = 1 then
Floor = Sup1
Ceil = Pivot
if close > Floor and close < Ceil then
break
endif
elsif iPivt = 2 then
Floor = Sup2
Ceil = Sup1
if close > Floor and close < Ceil then
break
endif
elsif iPivt = 3 then
Floor = Sup3
Ceil = Sup2
if close > Floor and close < Ceil then
break
endif
elsif iPivt = 4 then
Floor = Sup4
Ceil = Sup3
if close > Floor and close < Ceil then
break
endif
endif
iPivt = iPivt + 1
wend
endif
For IPivt = 1 to 4 do
dist = (Close - Floor) < distance*pipsize
If Dist then
allowtrading = 0
Break
endif
next
ça a l’air de fonctionner, mais j’ai l’impression que c’est interminable…!
y a t’il moyen de simplifier?
Très bien, j’ai créé une stratégie toute simple qui prendra ses ordres si “allowtrading” est égal à 1 (égal à 0 si trop proche d’un SR).
Dans la boucle on teste une proximité de “distance” avec un support/resistance détecté dans les “lookback” derniers chandeliers.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
defparam cumulateorders=false
// — settings
distance = 15 //no orders if there is a SR within X points
lookback = 1000 //lookback in bars to check recent SR
tp = 30 //takeprofit in points
sl = 10 //stoploss in points
// ———————————-
// — icihmoku support and resistance
kijun = (highest[26](high)+lowest[26](low))/2
SSB = (highest[52](high[26])+lowest[52](low[26]))/2
kijunp = summation[9](Kijun=Kijun[1])=9
ssbp = summation[9](SSB=SSB[1])=9
if kijunp then
kijunPrice= kijun
endif
if ssbp then
ssbPrice= SSB
endif
if kijunprice=ssbprice then
SRlevel= kijunprice
endif
// ———————————-
// — dummy strategy
buycondition = rsi[14] crosses over 50
sellcondition = rsi[14] crosses under 50
if buycondition or sellcondition then
//check if the current price is distant from at least “distance” from recent support or resistance
allowtrading=1
for i = 0 to lookback–1 do
dist= abs(close–srlevel[i])<distance*pointsize
if dist then
allowtrading=0 //no trading is allowed we are near a SR!
break //break the loop, no need to continue, trading is not allowed anymore!
endif
next
//trigger orders or not
if allowtrading then
if buycondition then
buy 1 contract at market
endif
if sellcondition then
sellshort 1 contract at market
endif
endif
set target pprofit tp
set stop ploss sl
endif
// ———————————-
graph allowtrading as “0=near a SR , don’t trade!”
|
Bjr Nicolas,
j’ai ajusté un peu les plats Kijun et SSB:
SRk = 5
SRs = 8
// --- icihmoku support and resistance
kijun = (highest[26](high)+lowest[26](low))/2
SSB = (highest[52](high[26])+lowest[52](low[26]))/2
kijunp = summation[SRk](Kijun=Kijun[1])=SRk
ssbp = summation[SRs](SSB=SSB[1])=SRs
if kijunp then
kijunPrice = kijun
endif
if ssbp then
ssbPrice = SSB
endif
if kijunprice = ssbprice then
SRlevel = kijunprice
if SRLevel > Close then
ResLevel = SRlevel
elsif SRLevel < Close then
SupLevel = SRlevel
endif
endif
Néanmoins codé tel quel, j’ai l’impression que ça ne trace les SRlevel que lorsque kijunP et SSBp sont strictement = à SRk et SRs.
je n’arrive pas à codé une alternative ou il faut Min SRk pour Kijunp et Min SRs pour SSBp.
une idée?