# Trade counter does not work

Forums ProRealTime English forum ProBuilder support Trade counter does not work

Viewing 6 posts - 1 through 6 (of 6 total)
• #211712

Hello

I started to evaluate wich day of the week, but its count wrong.

Here is an snippet from the code

Trigger = 1 //Trigger that a new position are open so you evalute the last one
endif

Once Trigger = 0

if Trigger = 1 then
if PositionPerf(1)< 0.0 then //If the last position whas bad count the day that trade whas made
if currentday =1 then
elsif currentday=2 then
elsif currentday=3 then
elsif Currentday=4 then
elsif Currentday=5 then
endif

currentday=Currentdayofweek //Set th current day for next trade
Trigger=0
endif

In the backtest I do, the calculator in the grah, for example tradecounterall, says that there have been 215 trades, and if I add upp all the bad days, it might be say 65pcs. But when I read the same values from the Detailed report it shows other numbers. Let say Totalt: 150, Losing:50.

What is wrong or can anyone suggest another way to do this?

#211722

Hi there Peli,

Remove the Once before Trigger. Put the line Trigger = 0 to the top of the code.

Good luck ! -Peter

#211723

Can you see the Graphonprice showing the bad trades as expected ? If Yes then what …

#211725

PositionPerf returns the temporary gain or loss candle by candle.

To tell if a trade gained or lost you have to compare the current StrategyProfit with that of the prior candle.

#211734

I use PositionPerf(1) so it should count the profit from the last ended trade. No temporary gain.

However, I realized that i have the setting defparam cumulateorders = false.

So even if there was no trade taking place when the buconditions were valid, the counter counted up.

So I changed to

if not shortonmarket and not longonmarket then
Trigger = 1 //Trigger that a new position are open so you evalute the last one
endif
endif

its works not perfect but good enough.

But I realy wanted to write something like

If cumulateorders=false and not shortonmarket and not longonmarket then

…….

elsif cumulateorders=true then

…….

endif

But the program does not accept it. I don´t know how to write to take the cumulateorders settings into account?

#211778

If you allow cumulating of orders, it means that you can be on market with more than 1 order at the same time, so just create a variable that count the quantity of BUY and quantity of  SELLSHORT in a row, and reset that variables when you invert the trade direction.

Viewing 6 posts - 1 through 6 (of 6 total)