Hello,
I’m quite new at this forum, been playing around with Prorealtime for a year now.
Here is some code which is profitable, but sadly also returns a “divide by zero error” (I already have the fix but does not work…)
//-------------------------------------------------------------------------
// Hoofd code : PSAR
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Hoofd code : sar
//-------------------------------------------------------------------------
// Hoofd code : OBV KOERS
//-------------------------------------------------------------------------
// Definitie van code parameters
DEFPARAM CumulateOrders = False // Opstapelen posities gedeactiveerd
//dive by zero fix
Gap = Close-CustomClose[1]
IF Gap = 0 THEN
Gap = 0.000001
ENDIF
// Condities om long posities te openen
indicator1 = SAR[0.02,0.02,0.2]
c1 = (indicator1 CROSSES UNDER close)
BUDGET = ((10000 + STRATEGYPROFIT) *5)/CLOSE
AANTAL = ROUND(BUDGET)
IF c1 THEN
BUY AANTAL CONTRACT AT MARKET
AANKOOP = CLOSE
ENDIF
IF CLOSE < (0.99*AANKOOP) THEN
SET STOP pTRAILING 1
ENDIF
IF CLOSE > (1.01*AANKOOP) THEN
SET STOP pTRAILING 1
ENDIF
Please let me know if you have an idea
Enjoy the code
Kind regards,
Reinier
To get a “division by 0” it needs a division, which I can’t spot.
In any case you have to check all divisions.
That fix can yield very incorrect results. Multiply or divide CLOSE by that number and you will see the result!