Hi guys – is there a way to place a label on entry and exits?
Context is that I have multiple entry and exit indicators and I would like to see how they interact with each other. It would be good to see which pieces of code trigger an entry or exit in the market if we’re able to label them when using ProBacktest.
I clearly see entry and exits labelled on the price chart – just wondering if we can add any further text to it to identify our trades without having to add all the relevant indicators to the chart.
See attached for an example of what I’m looking for.
The easiest way is to set flag variables to 1 when certain conditions are met and zero them at every bar entry. Then GRAPH the flags. For example:
slhit = 0
tphit = 0
condhit = 0
if longonmarket and close > high[1] then
sell at market
condhit = 1
endif
if longonmarket and close crosses under positionprice - sl then
slhit = 1
endif
if longonmarket and close crosses over positionprice + tp then
tphit = 1
endif
set stop ploss sl
set target pprofit tp
graph condhit as "Condition Exit"
graph slhit as "Stop Loss Exit"
graph tphit as "Take Profit Exit"
Not tested – just an idea to work with!
Thanks Vonasi – works well!
Even gives me an idea of how long each position stays open.
Both the GRAPHONPRICE and GRAPH functions are helpful depending on what you prefer to see
// BUY ENTRY ----------------------------------------------
if CONDITION AND NOT ONMARKET then
BUY n LOT AT MARKET
COD1 = 1
endif
// SELL ENTRY --------------------------------------------
if CONDITION AND NOT ONMARKET then
SELLSHORT n LOT AT MARKET
COD2 = 1
endif
// --- RESET CODE ----------------------------------------
//Reset the counters on the graphs to show which entry and exits being triggered
IF NOT ONMARKET THEN
COD1 = 0
COD2 = 0
ENDIF
// --- PRINT CODE ----------------------------------------
GRAPHONPRICE COD1 as "COD1"
GRAPHONPRICE COD2 as "COD2"
GRAPH COD1 as "COD1"
GRAPH COD2 as "COD2"
No problem. … and thank you for highlighting that the instruction GRAPHONPRICE exists as this one had passed me by. Following a discussion off forum it also appears that it has passed a lot of other PRT coders by as well. It is a powerful instruction now that MTF is available as we can use it to create MTF indicators on price – so weekly moving averages on daily charts for example. It is an exciting discovery!