The root cause

There are multitudes of reasons for explaining why an automatic trading system did not open a position at the right time.

If the late is only on one or two candles, this is maybe the normal lag of your indicators. ProOrder can only open or close a position at the opening of the next candle. That means, there is necessarily one candle late for each trade. Nonetheless, if a STOP, TARGET, or LIMIT order is touched, this order should be immediately completed.

However, if the late is over one or two candles, or if your automatic trading system sends bad orders, the most likely cause of a timing problem is a variable that is not reinitialised.

Find the root cause in source code thanks to GRAPH instruction

The best way to find the root cause of variable or condition problem in ProRealCode source consists to print their value evolution during the backtest. The GRAPH instruction allows you to print variables.

GRAPH myVariable AS "myVariableName"

How to use GRAPH instruction effectively ?

When you find a problem thanks to GRAPH instruction, the most important consists to set it at the right place in source code. You should place GRAPH instruction out of the « IF NOT LongOnMarket » block. (Obviously, if your automatic system is a short system, you should set GRAPH instruction out of « IF NOT ShortOnMarket ») In this way, there will appear more information about your variable.

Print several variables thanks to GRAPH

It’s possible to print as much as you want variables thanks to GRAPH, however, the visibility could become difficult. It is therefore at your disposal the possibility to colored variable while printing.

GRAPH myVariable1 coloured(255, 0, 0) AS "myVariableName1"
GRAPH myVariable2 coloured(0, 255, 0) AS "myVariableName2"
GRAPH myVariable3 coloured(0, 0, 255) AS "myVariableName3"

Print variables on the price chart

You can enhance the visibility any more by printing a variable directly on the price chart. That is very convenient for see when your buying and selling orders are positioned and to see the STOP, TARGET, and LIMIT order evolution. To do that, please use GRAPHONPRICE instruction in this way :

GRAPHONPRICE buyingLimitVariable AS "buy order price"

The GRAPHONPRICE instruction accepts colored variables as GRAPH instruction.

graphonprice stopOrderPrice coloured(255, 0, 0) as "STOP"
graphonprice targetOrderPrice coloured(0, 255, 0) as "TARGET"

Subscribe to our newsletter!

Leave a Reply

Your email address will not be published. Required fields are marked *