Backtester help


I'm looking for assistance with the backtester and forex trading.

If I'm testing forex trades, and setting a target exit of 50 pips, does the TARGETTYPE = Point stay as is? Is the value 50 or 0.005 ?

How do I set an entry with a setup bar and then an entry bar. Ie a setup bar is given when a set of entry criteria are met. (Could be anything such as a moving average cross, etc), but then a trade is only entered on the subsequent bar if that subsequent bar breaks the high of the setup bar (for a long entry).

Same for exit. How can I create an exit so that there is an exit setup bar (which meets certain criteria), but then the exit is only triggered if the subsequent bar to the exit setup bar breaks the low of the exit setup bar.

Hope this makes sense!



Hi Steve,

For you for query i believe 0.005 is what you would use in this scenario.

For your second query, you can set the Back Testers Enter Trade Price and Exit Trade Price to Signal, then in your entry and exit scripts add the two criteria you are after.

For example, if you wanted the Entry signal to be when the Close crosses above a 50SMA line, and have the entry placed on the next day, but only if the high of that bar is higher than the previous bar, you could use something like this:

V1 = CLOSE() CrossesAbove MA(BARS=50) ;
V2 = HIGH() > HIGH(1) ;
V1[1] and V2

The square brackets after V1 are used to offset the criteria, so we’re looking for that to have occurred the day before the High of the current bar is higher than the previous days bar.


Hi Matthew

Sort of!

In your example, where is the actual entry? (Let's call the trigger bar in your chart bar 1, then the next one bar 2 and so on.)

I can see in the backtester how to enter the trade at the open of bar 3, or at the close of bar 2. (Or for that matter the open or close of any bar) What I would like to do however is to enter at the very exact time that bar 2 moves one tick /pip / cent higher than the high of bar 1. (Not wait until the bar closes).

Is this something that the backtester can acheive? I know it's hard to do if we're not looking at the chart in real time, however can the backtester look at the bars and go, right - bar 2 has broken the high of bar 1 at some point of that session, let's attach an entry the high of bar 1 (plus a pip say). This would allow (in my case) a more accurate approximation of my entries.

Hope this makes sense.

Thanks Steve

Hi Steve,

As far as i am aware this can’t be done for the type of criteria you are after.

Hi Steve,

I think the following script might do what you want, which I understand to be that the script return the entry value. The following script, which adds 0.1 to the High of the signal bar as the Entry price, will do that:

V1 = CLOSE(0) CrossesAbove MA(BARS=50) ;

V2 = HIGH(0) > (HIGH(1) +0.1) ;

Entry = If(V1[1] and V2, HIGH(1) + 0.1, 0);


The results of that script are shown in Blue on the following chart. The Magenta Showbar arrows are from the script Matthew suggested.

Now, as to using my script in the Backtester, I'm afraid I'm no help there as I haven't done very much work with it. However, if the Backtester only uses Boolean values, ie this is a signal or there it isn't, then knowing the entry value is not going to help.That's a point that Matthew may be able to clarify.

20190325 Steve's Script - Ticket #51995 20190325

Let's know if that helps.



Thank you Trevor - this is what I'm looking for.


I assume though that this script cannot be used in the backtester. (Is that correct Matthew?)





Hi Steve,

The script would produce the result you wanted on the chart but would not work with the back tester. The output of the script is not a Boolean value which is required for use with the back testers Entry / Exit criteria.