@Despair, @Nicolas concerning arrays in PRT.
I have once thought about the idea of creating a preset number of arrays (up to whatever number) i.e. array1=0, array2=0, array3=0, etc, etc,
Then use a loop function with If statements to populate and retrieve them as required.
Well you won’t be able to use index notation and without the possibility to use indices there is no array. It is just a lot of variables.
For a small array this can be done (see the code of the meander bands) but it is impractical for larger arrays.
The If statements in the loop would kind of function as an index as there would be an If statement for each of the preset ‘array’ variables.
It is obviously going to be one heck of a long piece of code if you have for instance 50+ array variables 🙂
Long and slow.
and a long list of IF/THEN statements ..
@Nicolas, do you maybe know how far away PRT is from implementing arrays? Months? Years?
Hi All,
I tried this code and it seems to be working (slowly but surely). Please double check it and make sure there are no errors:
src=close-close[1]
i=0
f=0
delta=0.1
mem=0
maxdd=lowest[period](src)
while i<=1 do
w=1
for j=1 to period do
ppp=1
for r=1 to j do
ppp=ppp*(1+(i*src[period-j]/maxdd))
next
w=w*ppp
next
mem=w
if mem>mem[1] then
f=i
endif
i=i+delta
wend
return f,0
# Definire le variabili
Capital = 10000 # Il capitale iniziale
RiskPerTrade = 0.01 # Il rischio massimo per operazione
StopLoss = 50 # Lo stop loss in punti
TakeProfit = 100 # Il take profit in punti
WinRate = 0.6 # La probabilità di successo
# Calcolare il criterio di Kelly
KellyFraction = WinRate - (1 - WinRate) / (TakeProfit / StopLoss)
KellyFraction = max(0, KellyFraction) # Assicurarsi che sia positivo
# Calcolare la dimensione della posizione
PositionSize = Capital * RiskPerTrade / StopLoss * KellyFraction
# Aprire una posizione long se si verifica una condizione
if c1 then
buy PositionSize contract at market
endif
# Aprire una posizione short se si verifica una altra condizione
if c2 then
sellshort PositionSize contract at market
endif
# Chiudere la posizione con lo stop loss o il take profit
set stop ploss StopLoss
set target pprofit TakeProfit