StrategyProfit function stopped working
Forums › ProRealTime English forum › ProOrder support › StrategyProfit function stopped working
- This topic has 20 replies, 7 voices, and was last updated 3 years ago by
yasuhisa.
-
-
04/07/2022 at 6:44 PM #191388
Hallow forum,help me.
StrategyProfit function stopped working. It does not work properly.
It seems to return a smaller value than it should be.– real trade, prooder autotrade.
– IG (Japan)
– USD/JPY
– maybe from about March 2022,It worked properly until then.
– It still work properly on back test.I use this function to adjust lots.
123ONCE FirstNumOfTrade = 42NumOfTrade = FirstNumOfTrade +(STRATEGYPROFIT/50000)BUY NumOfTrade CONTRACT AT MARKETFor example,if sysytem loses 50,000JPY, STRATEGYPROFIT should return 50,000 and NumOfTrade should be 41.
but actually the system orders 41.99 lot. WHY?04/08/2022 at 8:44 AM #191398Hellow forum,help me.
StrategyProfit function stopped working. It does not work properly.
It seems to return a smaller value than it should be.
– real trade, prooder autotrade.
– IG (Japan)
– USD/JPY
– maybe from about March 2022,It worked properly until then.
– It still work properly on back test.
I use this function to adjust lots.
<!– Crayon Syntax Highlighter v_2.7.2_beta –>
<textarea class=”crayon-plain print-no” style=”tab-size: 4; font-size: 14px !important; line-height: 16px !important; z-index: 0; opacity: 0; overflow: hidden;” readonly=”readonly” wrap=”soft” data-settings=”dblclick”>ONCE FirstNumOfTrade = 42
NumOfTrade = FirstNumOfTrade +(STRATEGYPROFIT/50000)
BUY NumOfTrade CONTRACT AT MARKET</textarea><table class=”crayon-table”>
<tbody>
<tr class=”crayon-row”>
<td class=”crayon-nums ” data-settings=”show”>123</td>
<td class=”crayon-code”><span class=”crayon-st”>ONCE</span> FirstNumOfTrade <span class=”crayon-o”>=</span> <span class=”crayon-cn”>42</span>NumOfTrade <span class=”crayon-o”>=</span> FirstNumOfTrade <span class=”crayon-o”>+</span>(<span class=”crayon-st”>STRATEGYPROFIT</span><span class=”crayon-o”>/</span><span class=”crayon-cn”>50000</span>)<span class=”crayon-st”>BUY</span> NumOfTrade <span class=”crayon-st”>CONTRACT</span> <span class=”crayon-st”>AT</span> <span class=”crayon-st”>MARKET</span></td>
</tr>
</tbody>
</table><!– [Format Time: 0.0002 seconds] –> For example,if sysytem loses 50,000JPY, STRATEGYPROFIT should return -50,000 and NumOfTrade should be 41.
but actually the system orders 41.99 lot. WHY?
04/08/2022 at 8:55 AM #191400Why did you double post?
Moreover, please do not quote yourself, it’s only you posting, I guess you know who posted!
Thank you 🙂
04/08/2022 at 10:12 AM #19140804/08/2022 at 10:32 AM #191411Hello @yasuhisa,
Good that you repeated the question because now I suddenly have an idea – two actually :
- In your FX pair the JPY is the one subject to change. Thus, when a larger change is implied, the result of your /50000 could suddenly be different from what you expect. Please notice that this is actually not related to the profit you make (you can make profit over Long and over Short).
- To me it seems that StrategyProfit/50000 *always* comes up with a fraction, and not an integer number. But somehow you imply it is integer ?
I may add to this that buying lots is allowed to be in fractions anyway (for IG). So how would it have happened that the system ordered 42 exact lots vs. 41 exact lots ? I think that can not be so …
Kind regards,
Peter1 user thanked author for this post.
04/08/2022 at 11:10 AM #191418Hi @yasuhisa,
Maybe this has something to do with it:
StrategyProfit is normally expressed in the currency of your account BUT it can also be expressed in the currency of the instrument.
When there is a difference between your account currency and the instrument currency then you must make a conversion.
1 user thanked author for this post.
04/08/2022 at 3:55 PM #191441thank you for your advices.
is it possible to force StrategyProfit expressing in the currency of my account at real trade?
is it needed any command?I wonder why StrategyProfit behaves differently between real trade and back test….
04/08/2022 at 5:36 PM #191447I wonder why StrategyProfit behaves differently between real trade and back test….
Interesting observation !
I never saw that, but this will be because I accidentally don’t do things which would make me notice. But it will be the same as I told about : the currency (the value of it) itself changes, and we can expect that no backtesting developer (at PRT) ever thought about that. This even becomes logic when we see that in our code we have no commands for looking at currency pair rates (which I would highly need !), unless it is am Fx pair itself.When you work in real time, obviously the rate continuously changes.
I hope I make sense ?
04/08/2022 at 5:49 PM #191448my account is in sterling but I trade in euros.
In my experience, strategy profit is always reported in the instrument currency, both backtest and actual trading.
Maybe this is different for FX ? ie dependent on which currency you are buying and which you are selling ???
04/08/2022 at 5:49 PM #191449is it possible to force StrategyProfit expressing in the currency of my account at real trade?
Of course. If you define a reference at the start of your Strategy (when the Strategy is handed to the ProOrder system) and you make that a factor for the always changing rate …
Something like
1234567891011121314Once BaseCurrencyFactor = 124.32 // USD/JPY. Set at April 8, 2022 (set prior to making it Live).Once PriceOf2ndCurrency = Close // This will be your JPY rate.If Not OnMarket then// Only do this at the start of the possible order; make robust to changing Price.PriceOf2ndCurrency = CloseendifCurrencyFactor = BaseCurrencyFactor / PriceOf2ndCurrency // This is the factor we can use when needed.StopLoss = StopLoss / CurrencyFactor // This is only an example of usage. Apply e.g. to StrategyProfit.Notice that this means should cover for the rate change throughout backtesting (-months) because you can use Close for the current rate (against USD in your case).
I hope you can sort out the remainder yourself ?
04/08/2022 at 6:15 PM #191451my account is in sterling but I trade in euros.
My account is in euros but I trade in USD. The account shows in USD.
1Once PositionAmount = 140000Here you see the importance. This is just an index.
I want to trade (invest) 140000 (and not mysterious points). The “result” in order amount always changes. This is the same what StrategyProfit shows.I never sorted out whether StrategyProfit could be subject to the account setting for what currency to show.
With Forex it is indeed more complicated but I forgot exactly how because I do all these conversions internally.
When you have an other account in yet another currency (I also have accounts in USD) then you can get even more mad. And in all cases you’d like to compare (results).
What you (OK, I) don’t want is see (jumping) results on a stock just because the currency rate of it changes. Of course this is some times unavoidable. So if I’d trade Dutch ASML the gain of it always changes. But I can use the USA version just the same.
Undoubtedly there is more to say. Like my USD account(s) nicely growing because my normal money is in EUR. Ha !
… but I recall worse times just the same …
🙂04/08/2022 at 6:41 PM #191458PS: Before nobody understands the last screenshots … I can hardly understand it myself. But this is because the asset itself also changes the price. And in this case (these markets) that also change wildly in a month’s time.
And to add to the confusion : in this particular case, I wanted to keep the number of contracts equal always. So here it counter-acts against itself.More madness in the below. Same instrument, different PointValue. Same trade, but different currency (left USD, right EUR, at a rate which at this moment is 1.087 (which was obviously not so at 17:01 my time).
Summarised, it already is confusing, but I can easily add to that. 🙁
04/09/2022 at 3:15 PM #19149604/15/2022 at 7:16 PM #191809I modified my code as StrategyProfit returns profit in the currency of the instrument,and tried it on real trade.But the result is same.
1234ONCE FirstNumOfTrade = 42JpyProfit = STRATEGYPROFIT * CloseNumOfTrade = FirstNumOfTrade +(( JpyProfit - (JpyProfit mod 50000))/50000) //Order after correcting to an integer<span class="crayon-st">BUY</span> NumOfTrade <span class="crayon-st">CONTRACT</span> <span class="crayon-st">AT</span> <span class="crayon-st">MARKET</span>After system lost 93,100JPY(=744.8USD),system ordered 41.99 lot.
I strongly doubt that there is a bug in ProOder for the following two reasons.
-On backtest,even now, STRATEGYPROFIT returns value in JPY(currency of my account).
-STRATEGYPROFIT returned value in JPY on real trade until about March 2022. (degrade happened?)I would like IT-FINANCE engineer to analyze this isue.
04/16/2022 at 4:08 AM #1918161234ONCE FirstNumOfTrade = 42JpyProfit = STRATEGYPROFIT * CloseNumOfTrade = FirstNumOfTrade +(( JpyProfit - (JpyProfit mod 50000))/50000) //Order after correcting to an integerBUY Floor(NumOfTrade) CONTRACT AT MARKET // Round down to IntegerAssumed that from your Mod(ulo) function comes something with sense, the above should buy 41 contracts.
But this from your first post should do it too :
123ONCE FirstNumOfTrade = 42NumOfTrade = Floor(FirstNumOfTrade +(STRATEGYPROFIT/50000)) // Round down to Integer.BUY NumOfTrade CONTRACT AT MARKET -
AuthorPosts
Find exclusive trading pro-tools on