ProOrder and PositionPerf
Forums › ProRealTime English forum › ProRealTime platform support › ProOrder and PositionPerf
- This topic has 5 replies, 4 voices, and was last updated 4 days ago by PeterSt.
-
-
10/29/2024 at 12:36 PM #239691
ProOrder appears to not respect / act on PositionPerf < – ?
Attached:
First image from ProOrder shows (as most recent trade) a Long losing during a downturn.
Second image backtest (same code copied direct from ProOrder which gave the first image) shows the same period, but with a long reversal to a Short and then back to a long.
The reversal condition is below.
It appears that ProOrder is not respecting PositionPerf < -0.009
123IF Longonmarket AND (PositionPerf > 0.008 or PositionPerf < -0.009) THENSELLSHORT 1 CONTRACTS AT MARKETENDIFThere are several other instances of PositionPerf < -0.009 not being respected on the same System when compared to backtest of the exact same code.
I am posting this in case others are having the same problem??
10/30/2024 at 12:57 AM #239750I’m not sure if it hasn’t been working recently, but not long ago, I used “PositionPerf” as a kind of emergency stop in a “Long only” system…
I used it like this:
If PositionPerf*100<PP then
Sell at Market
EndIf
Where “PP” was an optimization parameter (in %) that could also be negative…
I believe it worked well at the time…10/30/2024 at 7:54 AM #23975210/30/2024 at 10:21 AM #239758Hi GraHal,
With Reversal more things go “wrong”. For IB different than with IG. I can’t help you with solutions because they are all specific for the issues. I can give a hint though :
With Inversion and for IB, you can see by means of manual trading that it is PRT which does the inversion. Notice that IIRC for IG there is not even such an “Invert” command on the chart. What you would notice of it, is that you’d require double the money for such a trade (while real Reversal would net out). Anyway, because this is so, it can be expected that with AutoTrading it is the same. This in itself incurs for various strangenesses, like for IB adding the Commission in between (yes, this is visible as a separate trade !). While for IG not in order (for CFDs), don’t ask me what *does* happen. All I know is that my code is historically full with “Reverse” counter-acting.
Below a 1:1 screen copy of what I find in the code accidentally on-screen. The hint in there is the usage of StrategyProfitPrev which you also see referred to in the comment. In some code somewhere, this has been worked out with comments and all (no idea where this code is – sorry), but the gist of it is that PositionPerf[1] brings off results, which is – or can be related to that in between real trades happenings, actually invisible to you (but they can be found).
Does this help you ? surely not ! But still you may get the hang of how to approach PositionPerf and that in some “light” occasions it could be better to keep track of the Position Performance yourself.
Also don’t underestimate what’s desired from the broker if it is indeed PRT doing the reversal (thus for Long, first Sell then Sell Short). This in itself is prone to error (broker and further chain can not digest it timely), though it won’t be what is bothering you right now.
I think, but not sure, that I never apply Reversals any more, just avoiding as many throw-outs as possible (which goes quite well lately for me). Thus then rather : one bar out, the other bar in.Peter
10/30/2024 at 10:23 AM #239760When you graph positionPerf [white] in backtest it appears to do what you expect, but it can be hit and miss if with a running demo trade.
As far as I can tell, positionPerf is calculated by ((tradeprice-close)/tradeprice) [green] but get a deviance at times when graphed together.
If you look at the value when they deviate, the values are the same but with a sign difference.
This appears to happen on the bar of the backtest position indicating the sellshort exit of trade.
Can’t think of anything that can causes this other than instrumentation and not able to display the same at that point due to timing.
PRINT gives the same values but not the last when trade is closed.
The [red] line is the positionPerf at entry and the [violet] are the two threshold level up and down.
I tried < and > , <= &>= , and cross over and under but didn’t notice any difference with running trade or exit consistency.
I’m currently out of idea’s on this one.
1234567891011121314151617181920212223242526272829303132333435363738defparam cumulateOrders= falsedefparam preloadbars = 0// variablesup = 0.0005dn = -0.0005pp = positionPerfgraph ((close-tradeprice)/tradeprice) coloured("lime")print ppprint tradepriceprint ((( tradeprice-close))/tradeprice)graph ppgraph up coloured("violet")graph dn coloured("violet")graph x coloured("red")graphonprice tradeprice// stop strategy if hit positionPerfIF pp crosses over up or pp crosses under dn thenerr = highest[0]endif// enter positionIf not longonmarket thenbuy 1 contract at marketendif// exit position if hit positionPerfIF Longonmarket AND (pp crosses over up or pp crosses under dn) THENSELLSHORT 1 CONTRACTS AT MARKETx=ppendif11/01/2024 at 5:39 AM #239851Careful here please :
What I did not mention (there is a lot to mention and think of !) is that the behavior of adding Commission *after* the exit as a separate trade, does not occur in Live. Worse : in Live we don’t see a thing of Commission whatsoever (and please note that this is about PRT-IB only). So regarding this phenomenon, it is quite impossible to perform backtests which rely on PositionPerf (I managed, but it is crazy stuff). Thus, might you have gotten hold of the behavior(s) of PositionPerf by means of backtesting and what you showed/tried, @druby, then in real Live this would be worthless.
And to have even more fun : the adding of Commission during Backtesting, also changes the TradePrice and TradeIndex. So for that too provisions need to be made in your code.
Now try to create a system with accumulating orders. Really great fun. Not.With PRT-IG we are no bothered by this (no Commission assumed).
-
AuthorPosts
Find exclusive trading pro-tools on