Equity Curve – How to identify a new trade
Forums › ProRealTime English forum › ProOrder support › Equity Curve – How to identify a new trade
- This topic has 14 replies, 3 voices, and was last updated 9 months ago by robertogozzi.
-
-
01/23/2024 at 3:07 PM #226760
Hi @Moderators and all,
I am struggling getting the right signal of a new trade on the Equity Curve of a backtest.
I am using this kind of trickEquityData <> EquityData[1] (meaning the Equity was flat for a while)
But sometimes when the equity curve does not have the time to turn flat, I am unable to get the signal;
>> Is there a function I am missing or is there no solution to get this information in the backtest window?
Thanks a lot ^^
01/23/2024 at 6:05 PM #226784That line should work whenever EquityData <> EquityData[1], not just when it was flat and currently it is not. I donìt know how and when you used it, but there should be no need to wait for it to be flat before a change is detected.
1 user thanked author for this post.
01/23/2024 at 6:35 PM #226790Maybe the same story as with the “StrategyProfit”…
I have noticed that when you go from long to short or from short to long in one go, the “StrategyProfit” is not updated (or a bar too late)
The solution is to do an intermediate step and close the positions in the “right way”:
So instead of all at once: Long => Short
Long => Sell => Short => ExitShort
This kind of instruction only works when the positions are closed in the “right way”…?
1 user thanked author for this post.
01/23/2024 at 6:40 PM #226791thanks for your quick answer;
to be clearer,
- this is the code I wrote in order to identify the number of trades as the ProOrder functions are not allowed in indicators for Equity Curve
It should but it cannot identify this
12345678910111213141516if EquityData <> EquityData[1] and TradeFlag = 0 thenOpenTrade = 1TradeFlag = 1TradeCounter = Max(1,TradeCounter + 1)elsif EquityData = EquityData[1] and TradeFlag = 1 then //and EquityData[1] = EquityData[2] and EquityData[2] = EquityData[3]OpenTrade = 0TradeFlag = 0elseOpenTrade = 0endif- and enclosed is the problem I face, in case the equity curve does not turn flat ; the vertical lines indicate the identified new trades (and some are missing as you can see)
thanks ^^
01/23/2024 at 6:52 PM #226794Maybe the same story as with the “StrategyProfit”…
I have noticed that when you go from long to short or from short to long in one go, the “StrategyProfit” is not updated (or a bar too late)
The solution is to do an intermediate step and close the positions in the “right way”:
So instead of all at once: Long => Short
Long => Sell => Short => ExitShort
This kind of instruction only works when the positions are closed in the “right way”…?
thanks JS but in fact you cannot even use these ProOrder functions in indicators PRT world 😉
01/23/2024 at 7:37 PM #226796Check that you are executing the line (and the following lines):
1if EquityData <> EquityData[1] and TradeFlag = 0 thenin the DEFAULT timeframe.
If you are using a 1-minute TF, but those lines are in the 4-hour TF, they will be updated ONCE every 4 hours, if UpdateOnClose is used. That might be an issue.
01/23/2024 at 8:25 PM #226800Check that you are executing the line (and the following lines):
1if EquityData <> EquityData[1] and TradeFlag = 0 thenin the DEFAULT timeframe.
If you are using a 1-minute TF, but those lines are in the 4-hour TF, they will be updated ONCE every 4 hours, if UpdateOnClose is used. That might be an issue.
Ok thanks, but do you see another way to identify consecutive trades in the context of an Equity Curve Indicator?
01/24/2024 at 6:53 PM #226877Try this one:
12TradeClosed = strategyprofit <> strategyprofit[1]Conescutive = OnMarket AND TradeClosed01/24/2024 at 9:37 PM #226879Try this one:
12TradeClosed = strategyprofit <> strategyprofit[1]Conescutive = OnMarket AND TradeClosedThanks Roberto but these are all functions working solely in the context of algos and not indicators
01/26/2024 at 12:32 PM #226904You will need to simulate trading, like any backtesting software:
1234567891011ONCE TradeIsOpen = 0TradeClosed = EquityData <> EquityData [1]// set TradeIsOpen whenever the conditions to enter a position are met,// then clear it as soon as the trade needs to be closed (like backtest// does).// ProBackTest is actually an indicator (well... quite difficult and time// consuming to code!)IF MyConditions THENTradeIsOpen = 1ENDIFConescutive = TradeIsOpen AND TradeClosed1 user thanked author for this post.
02/01/2024 at 4:48 PM #227257You will need to simulate trading, like any backtesting software:
1234567891011ONCE TradeIsOpen = 0TradeClosed = EquityData <> EquityData [1]// set TradeIsOpen whenever the conditions to enter a position are met,// then clear it as soon as the trade needs to be closed (like backtest// does).// ProBackTest is actually an indicator (well… quite difficult and time// consuming to code!)IF MyConditions THENTradeIsOpen= 1ENDIFConescutive = TradeIsOpen AND TradeClosed
Hi Roberto,
Are you telling me indirectly that I cannot indentify every trade through an indicator that I apply on the Equity Curve?02/01/2024 at 6:16 PM #227260It’s not possible, try this code (apply it to the equity line):
12345678910111213ONCE EquityLine = customcloseONCE TradeCount = 0EquityChange = 0IF (BarIndex > 0) THENIF (EquityLine <> customclose) THENEquityChange = 1ENDIFENDIFIF (not EquityChange AND EquityChange[1]) AND (close <> close[1]) THENDrawText("*●",BarIndex,customclose) coloured("Red")ENDIFEquityLine = customcloseRETURNit will plot a large red dot whenever the equity line changes, but it requires at least two bars NOT ONMARKET to detect trades properly.
02/02/2024 at 7:16 PM #227342The EquityLine changes every bar, as it combines StrategyProfit + PositionPerf.
To use STRATEGYPROFIT only, you have to append this line to your backtest:
1GRAPH StrategyProfitThen add this indicator to the variable window where STRATEGYPROFIT is plotted:
1234567891011121314ONCE EquityLine = customcloseONCE TradeCount = 0EquityChange = 0IF (BarIndex > 0) THENIF (EquityLine <> customclose) THENEquityChange = 1ENDIFENDIFIF EquityChange THENTradeCount = TradeCount + 1DrawText("#TradeCount#",BarIndex,customclose,serif,bold,16) coloured("Red")ENDIFEquityLine = customcloseRETURNmy attached pic shows the results.
02/07/2024 at 5:20 PM #227593The EquityLine changes every bar, as it combines StrategyProfit + PositionPerf.
To use STRATEGYPROFIT only, you have to append this line to your backtest:
1GRAPH StrategyProfitThen add this indicator to the variable window where STRATEGYPROFIT is plotted:
1234567891011121314ONCE EquityLine = customcloseONCE TradeCount = 0EquityChange = 0IF (BarIndex > 0) THENIF (EquityLine <> customclose) THENEquityChange= 1ENDIFENDIFIF EquityChange THENTradeCount= TradeCount + 1DrawText(“#TradeCount#”,BarIndex,customclose,serif,bold,16) coloured(“Red”)ENDIFEquityLine = customcloseRETURNmy attached pic shows the results.
Thanks for your help Roberto
We are getting closer but the indicator does not apply on the equity curve of course; moreover strategyprofit as I understand it, will only update at the end of the last trade right?
So I wonder how our little hack could solve the problem I am facing on the Equity curve; am I missing something?
My goal is to add on the Equity Curve an indicator that detects every new beginning trade.
Thanks
02/08/2024 at 9:48 AM #227643It’s not possible to add indicators to the equity curve in ProBackTest to detect new trades.
You can only achieve your goal simulating trading, or using GRAPH for the variable window as stated above.
- this is the code I wrote in order to identify the number of trades as the ProOrder functions are not allowed in indicators for Equity Curve
-
AuthorPosts
Find exclusive trading pro-tools on