Graph number of trades
Forums › ProRealTime English forum › ProOrder support › Graph number of trades
- This topic has 3 replies, 4 voices, and was last updated 5 years ago by Vonasi.
-
-
02/11/2017 at 10:07 AM #24775
Hi coders
I’ve been trying to use the graph instruction to display number of trades as in the statistic of a backtest. But when accumulating orders it not straight forward with a counter.
Does anyone have an idea on how to graph this?
cheers Kasper
02/13/2017 at 3:26 PM #2497704/19/2019 at 1:47 AM #96797Hi all,
was looking at this problem myself, and have come up with the following code. In a cumulating trades setting, it counts number of total trades, and number of long/number of short.
A word of caution though – it slips up on same bar entry/exits – it won’t count a trade if it opens and closes on the same bar, or if a trade netts off to no position in the same bar – an example picture is attached. This same bar close count problem might be overcome with an additional condition?
Graph tradenum, longcount and shortcount to see results.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950If tradenum = 0 and not onmarket thentradenum = 0endifIf abs(countofposition-countofposition[1]) and tradenum=0 thentradenum = 1if shortonmarket thenshortcount = 1elseif longonmarket thenlongcount = 1endifendifendifif longonmarket[1] and shortonmarket thentradenum = tradenum[1]+1shortcount = shortcount[1]+1endifif shortonmarket[1] and longonmarket thentradenum = tradenum[1]+1longcount = longcount[1]+1endifif longonmarket[1] and longonmarket thentradenum = tradenum[1]longcount = longcount[1]endifif shortonmarket[1] and shortonmarket thentradenum = tradenum[1]shortcount = shortcount[1]endifIf onmarket[1] and not onmarket thentradenum = tradenum[1]longcount = longcount[1]shortcount = shortcount[1]endifIf not onmarket[1] and longonmarket thentradenum = tradenum[1]+1longcount = longcount[1]+1endifIf not onmarket[1] and shortonmarket thentradenum = tradenum[1]+1shortcount = shortcount[1]+1endifRegards,
Finning
04/19/2019 at 7:30 AM #96804You could do something like this to record mid candle trades. It does not allow for spread so you might want to factor that in in some way when comparing to the high and low of a candle.
This is the long only version. Not tested and written during first cup of coffee of the day!
1234567891011121314151617181920212223242526272829303132333435if longlimitorderon and low < x thenlongcount = longcount + 1endiflonglimitorderon = 0if longstoporderon and high > x thenlongcount = longcount + 1endiflongstoporderon = 0////Your conditions and calculation of x price in here////Limit orderif (your long entry conditions at a LOWER price) thenbuy 1 contract at x limitlonglimitorderon = 1endif//Stop orderif (your long entry conditions at a HIGHER price) thenbuy 1 contract at x stoplongstoporderon = 1endif//Market orderif (your long entry conditions at MARKET price) thenbuy 1 contract at marketlongcount = longcount + 1endifgraph longcount -
AuthorPosts
Find exclusive trading pro-tools on