Hi all,
I’ve tried out a little through ProOrder and wrote this code.
But it doesn’t generate any trades.
Timeframe M5.
Can anybody tell me, where the mistake is?
Thanks
Defparam cumulateorders = False
Defparam preloadbars = 150
DEFPARAM FlatAfter = 215500 // Positionen werden um 21:55 Uhr glattgestellt
// Variablen
// BBFaktor = 2 //Faktor Standardabweichung BB
// TB = 100 // neues BBwidth-Tief seit 100 Perioden
// FB = 1.2 // Faktor Bandbreite für Stoploss-Bestimmung
// CRV = 1.5 // gewünschtes CRV; TP = CRV*Stoploss
// BBBT = 10 // minimale Bandbreite für Einstieg
// BBBH = 40 // maximale Bandbreite für Einstieg
//Times for the strategy to work
IF (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31)) OR (Month = 1 AND (Day = 1 OR Day = 6)) OR (Month = 10 AND Day = 3) OR Time < 090000 OR Time > 204500 THEN
t = 0
ELSE
t = 1
ENDIF
//indicators
BBM = Average[20](close)
BBUp = BBM + BBFaktor * STD[20](close)
BBDown = BBM - BBFaktor * STD[20](close)
BBwidth = BBUp - BBDown
a1 = lowest[3](BBwidth) = lowest[100](BBwidth)
a2 = BBwidth > BBBT
a3 = BBwidth < BBBH
o1 = close > BBUp
o2 = close < BBDown
//Wert Stoploss
IF a1 AND a2 AND a3 AND o1 OR o2 THEN
SL = BBwidth * FB
ENDIF
//Wert Takeprofit
TP = SL * CRV
//Position size management
Capital = 5000
Risk = 0.01
Equity = Capital + StrategyProfit
MaxRisk = Equity * Risk
PositionSize = MaxRisk/SL
//conditions for entry long
IF not longonmarket AND t = 1 AND a1 AND a2 AND a3 AND o1 THEN
BUY Positionsize Contract AT Market
ENDIF
//conditions for entry short
IF not shortonmarket AND t = 1 AND a1 AND a2 AND a3 AND o2 THEN
SELLSHORT Positionsize Contract AT Market
ENDIF
//Stop and Target
Set Stop ploss SL
Set Target pProfit TP
You should uncomment lines 8-13.
Hello Roberto,
I’ve defined these variables in ProRealTime, as you can see in the attached itf-File.
The ambition is to optimize these variables, after a first strategy test.
But the strategy still doesnt’t bring any results. Is there maybe another fault in the syntax?
If there were variables used in a code, that are not defined, isn’t ProRealTime generating an error note then?
Thank you.
Not sure, but maybe the reason you don´t get any operation could be because of the minimun size of the instrument you are operating.
For instance the DAX have a minimun position size of 0,5 so as your “Position Size Management” calculates a lower position size the operation doesn´t execute
To avoid that you should code a minimun position size
Have you checked that all your conditions are actually ever true at the same time?
It might be worth creating an indicator just to test this. Something like this (not tested):
BBFaktor = 2 //Faktor Standardabweichung BB
TB = 100 // neues BBwidth-Tief seit 100 Perioden
FB = 1.2 // Faktor Bandbreite für Stoploss-Bestimmung
CRV = 1.5 // gewünschtes CRV; TP = CRV*Stoploss
BBBT = 10 // minimale Bandbreite für Einstieg
BBBH = 40 // maximale Bandbreite für Einstieg
//Times for the strategy to work
IF (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31)) OR (Month = 1 AND (Day = 1 OR Day = 6)) OR (Month = 10 AND Day = 3) OR Time < 090000 OR Time > 204500 THEN
t = 0
ELSE
t = 1
ENDIF
//indicators
BBM = Average[20](close)
BBUp = BBM + BBFaktor * STD[20](close)
BBDown = BBM - BBFaktor * STD[20](close)
BBwidth = BBUp - BBDown
a1 = lowest[3](BBwidth) = lowest[100](BBwidth)
a2 = BBwidth > BBBT
a3 = BBwidth < BBBH
o1 = close > BBUp
o2 = close < BBDown
//conditions for entry long
IF t = 1 AND a1 AND a2 AND a3 AND o1 THEN
flag1 = flag1 + 1
ENDIF
//conditions for entry short
IF t = 1 AND a1 AND a2 AND a3 AND o2 THEN
flag2 = flag2 + 1
ENDIF
return flag1 as "Long Conditions Hit", flag2 as "Short Conditions Hit"