Hi guys
I have written a probacktest code which enters short and long trades based on an indicator signal. what I am wanting to do is optomise it so that it enters an optimised number of pips above or below the entry signal.
Please see attached ITF file which I hope will give you some idea of what I mean.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
ignored, indicator2 = CALL “123v2″[70, 30, 14]
c1 = (indicator2 < 0)
IF c1 and (tradeprice – (a)) THEN
BUY 1 PERPOINT AT MARKET
ENDIF
// Conditions to enter short positions
indicator5, ignored = CALL “123v2″[70, 30, 14]
c3 = (indicator5 > 0)
IF c3 and (tradeprice + (b)) THEN
SELLSHORT 1 PERPOINT AT MARKET
ENDIF
// Stops and targets
SET TARGET pPROFIT (c)
Many thanks in anticipation.
Line 7, (tradeprice – (a)), is always negative because it is missing something you need to compare (tradeprice – (a)) to something… what, maybe CLOSE?
Forthermore, condition C1 is always 0 (not met). You should check the value returned by indicator2, appending this instruction to your code:
GRAPH indicator2
Hi Roberto, many thanks for your reply
you are correct the indicator (see attached) is by default at “0” unless a divergence is identified.
I then have a proscreener (again attached) for which I’d appreciate a little guidance. I can search for the MA direction and the 4hr Bollinger periodically but when it comes to an indicator signal for the previous 8 x 1hr or 16 x 30 minutes but is there a way to search for the previous 16 candles without going [1], [2], [3] thru to [16] or can you go [1 – 16]
And finally, with the probacktest and entry is made at the close of the candle delivering the >0 (buy) or <0 (sell) signal, what I’m trying to ascertain is the optimum historical price above that close (based on previous entry points) to finally enter the trade, i suppose in a roundabout way the average drawdown based on previous trades.
Many thanks in anticipation
Chris
You should add PipSize as a multiplier for a, b and c, such as:
(tradeprice - (a*pipsize)
moreover, TRADEPRICE is always 0, what is exactly the price you want to use in the expression, why did you use TRADEPRICE?