Only trade if last trade was a win

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #60132 quote
    OscJoh
    Participant
    Average

    Hi,

    As topic reads – I’m curious to try a system that only trades “for real” if the last trade would have been profitable. I found some threads (mainly this: https://www.prorealcode.com/topic/trading-equity-curve/) but I’m not sure how to code this feature in practice.

    The approach I assume, would be to track some sort of fake trades separately and evaluate that performance somehow.

    Any help is appreciated!

    Thanks

    #60133 quote
    jebus89
    Participant
    Master

    Im just gonna say this, if you get a loss, what is your intentions? Pausing the algo and the manually turning it on when you decide is the right time?

    If your gonna start it again “manually” im going to assume that you have some criteria for when to start it again? If thats so, you can just code it in as a starting condition that has to be true/false..

    #60139 quote
    OscJoh
    Participant
    Average

    It shouldn’t require manual handling, rather be fully automatic.

    If the last trade was a loss, it will not trade until a new win. To illustrate, something like this if # is loss and O is a win:
    O, O, O, O, #, #, O, # – 4 real trades.
    #,#,#,O,O,#,O,#,O,# – 1 real trade

    I have a system which seems to benefit doing this (in theory at-least). It’s an approach for trying to catch run-ups and limit draw-downs.

    #60172 quote
    jebus89
    Participant
    Master

    Hmm, so it will not be possible (at least as far as i know) to code in “if the last trade WOUD HAVE BEEN a win”. Because you cant “run the system” live but without actually taking the trade (again, as far as i know..) and you cant get the system to “call” another system to check how its going.

    What you can do is do the same operation manually, by running 1 in demo and 1 live. and just pausing the live strategy until you see a win on the demo.

    Im pretty sure you can do this in python (?) but not in PRT.

     

     

    O, O, O, O, #, #, O, # – 4 real trades.  <– That dosnt make sense. #1 win, #2 win, #3 win, #4 win, #5 lost, #6 skip, #7 skip, #8  win. 6 trade, no?
    #,#,#,O,O,#,O,#,O,# – 1 real trade <– That dosnt make sense. #1 lost, #2 skip, #3 skip, #4 skip, #5 win, #6 lost, #7 skip, #8 lost, 4 trades, no?

    #60179 quote
    Vonasi
    Moderator
    Master

    I wonder if you could create an indicator that simulates the system and just sets a flag if the last set of conditions resulted in a favourable simulated exit price compared to simulated entry price. You could then call this indicator to check on the status of the last simulated trade. Just an idea but I fear there may be some complications such as the simulated entry being different to the actual entry etc that might stop it working.

    #60182 quote
    OscJoh
    Participant
    Average

    Hmm, so it will not be possible (at least as far as i know) to code in “if the last trade WOUD HAVE BEEN a win”. Because you cant “run the system” live but without actually taking the trade (again, as far as i know..) and you cant get the system to “call” another system to check how its going. What you can do is do the same operation manually, by running 1 in demo and 1 live. and just pausing the live strategy until you see a win on the demo. Im pretty sure you can do this in python (?) but not in PRT. O, O, O, O, #, #, O, # – 4 real trades. <– That dosnt make sense. #1 win, #2 win, #3 win, #4 win, #5 lost, #6 skip, #7 skip, #8 win. 6 trade, no? #,#,#,O,O,#,O,#,O,# – 1 real trade <– That dosnt make sense. #1 lost, #2 skip, #3 skip, #4 skip, #5 win, #6 lost, #7 skip, #8 lost, 4 trades, no?

    Sorry I was probably unclear and you’re right it’s 5 actual trades. Imagine there is a fake system keeping track of and performing all trades. Then there’s the “real” system deciding when to permit trades based on the fake system’s trades. Sort of like:
    Fake system trades all:
    a O,
    b O,
    c O,
    d O,
    e #,
    f #,
    g O,
    h #
    Real system looks at the above and trades like:
    a skip (no previous trade to compare),
    b trade (last was winner),
    c trade (last was winner),
    d trade (last was winner),
    e trade (last was winner but we lost this trade),
    f skip (last was loss),
    g skip (last was loss but this would have won)
    h trade (last was winner but we lost this trade)

    Leaves us with 5 trades the real system would do.

    I wonder if you could create an indicator that simulates the system and just sets a flag if the last set of conditions resulted in a favourable simulated exit price compared to simulated entry price. You could then call this indicator to check on the status of the last simulated trade. Just an idea but I fear there may be some complications such as the simulated entry being different to the actual entry etc that might stop it working.

    Something along those lines was suggested in the other thread too. I’m just not sure where to start. Any code example would be appreciated 🙂

    #60187 quote
    Nicolas
    Keymaster
    Master

    You can also simulate fake orders in ProOrder, even if calling an external indicator which simulate them would be more clear and easier to debug though. A real problem is the lack of variable array, but we could probably try to code something!

    Equity curve trading with this code, did you try?

    a = 20
    
    if not onmarket then
     mystrategyprofit=strategyprofit
    elsif longonmarket then
     mystrategyprofit=strategyprofit+(close-tradeprice)/pointsize*pointvalue*countoflongshares
    elsif shortonmarket then
     mystrategyprofit=strategyprofit+(tradeprice-close)/pointsize*pointvalue*countofshortshares
    endif
    
    equitycurve = exponentialaverage[a](mystrategyprofit)
    
    GRAPH mystrategyprofit as "strategy profit"
    GRAPH equitycurve coloured(255,0,0) as "profit curve"

    It is based on time periods, not on trade one.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Only trade if last trade was a win


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
OscJoh @oscjoh Participant
Summary

This topic contains 6 replies,
has 4 voices, and was last updated by Nicolas
8 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/22/2018
Status: Active
Attachments: No files
Logo Logo
Loading...