StrategyProfit function stopped working

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #191388 quote
    yasuhisa
    Participant
    New

    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.

    ONCE FirstNumOfTrade = 42
    NumOfTrade = FirstNumOfTrade +(STRATEGYPROFIT/50000)
    BUY NumOfTrade CONTRACT AT MARKET

    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?

    #191398 quote
    yasuhisa
    Participant
    New

    Hellow 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 –>

    <!– [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?

    #191400 quote
    robertogozzi
    Moderator
    Master

    Why did you double post?

    Moreover, please do not quote yourself, it’s only you posting, I guess you know who posted!

    Thank you 🙂

    #191408 quote
    yasuhisa
    Participant
    New

    sorry,I made a mistake.

    #191411 quote
    PeterSt
    Participant
    Master

    Hello @yasuhisa,

    Good that you repeated the question because now I suddenly have an idea – two actually :

     

    1. 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).
    2. 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,
    Peter

    yasuhisa thanked this post
    #191418 quote
    JS
    Participant
    Senior

    Hi @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.

    yasuhisa thanked this post
    #191441 quote
    yasuhisa
    Participant
    New

    thank 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….

    #191447 quote
    PeterSt
    Participant
    Master

    I 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 ?

    #191448 quote
    nonetheless
    Participant
    Master

    my 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 ???

    #191449 quote
    PeterSt
    Participant
    Master

    is 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

    
    
    Once 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 = Close
    endif
    
    CurrencyFactor = 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 ?

    #191451 quote
    PeterSt
    Participant
    Master

    my account is in sterling but I trade in euros.

    My account is in euros but I trade in USD. The account shows in USD.

    Once PositionAmount = 140000

    Here 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 …
    🙂

    image_2022-04-08_190336.png image_2022-04-08_190336.png image_2022-04-08_190407.png image_2022-04-08_190407.png
    #191458 quote
    PeterSt
    Participant
    Master

    PS: 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. 🙁

    image_2022-04-08_193746.png image_2022-04-08_193746.png
    #191496 quote
    yasuhisa
    Participant
    New

    Thanks everyone for your kind advices.
    I will try to modify my code as StrategyProfit returns profit in the currency of the instrument,and try it in real trade.

    #191809 quote
    yasuhisa
    Participant
    New

    I modified my code as StrategyProfit returns profit in the currency of the instrument,and tried it on real trade.But the result is same.

    ONCE FirstNumOfTrade = 42
    JpyProfit = STRATEGYPROFIT * Close
    NumOfTrade = 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.

    #191816 quote
    PeterSt
    Participant
    Master
    ONCE FirstNumOfTrade = 42
    JpyProfit = STRATEGYPROFIT * Close
    NumOfTrade = FirstNumOfTrade +(( JpyProfit - (JpyProfit mod 50000))/50000) //Order after correcting to an integer
    BUY Floor(NumOfTrade) CONTRACT AT MARKET   // Round down to Integer

    Assumed 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 :

    ONCE FirstNumOfTrade = 42
    NumOfTrade = Floor(FirstNumOfTrade +(STRATEGYPROFIT/50000))   // Round down to Integer.
    BUY NumOfTrade CONTRACT AT MARKET
Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.

StrategyProfit function stopped working


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
yasuhisa @yasuhisa Participant
Summary

This topic contains 20 replies,
has 7 voices, and was last updated by yasuhisa
3 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/07/2022
Status: Active
Attachments: 3 files
Logo Logo
Loading...