CODE TO CLOSE ALL TRADES BASED ON EQUITY OR PORTFOLIO VALUE

Forums ProRealTime English forum ProOrder support CODE TO CLOSE ALL TRADES BASED ON EQUITY OR PORTFOLIO VALUE

Currently, there are 0 users and 1 guest visiting this topic.
View all attachments
Viewing 13 posts - 1 through 13 (of 13 total)
  • #191010 Report

    Hi Everyone,

    Very much enjoying Prorealtime and have only been using it for a couple of weeks through IG, very much a beginner here, previously using MT4. I’ve managed to code my few strategies on here, reading and experimenting with the code library, i’m learning slowly!

    My question is, is there any code relating to being able to stop all ProOrder trading based on portfolio value (account balance)? I run my strategy on 3 or 4 non-correlating FX pairs (charts) running simultaneously (same strategy with different conditions). I would like to be able to somehow stop all trading on all charts based on the profit/loss of my overall account balance. Is this at all possible? My strategy has profit target on each different chart banking small profits and slowly growing equity. Through extensive back-testing I know i’m just missing the something that says STOP ALL TRADING on all ProOrder strategies once a certain balance is met. Any help/ advice gratefully appreciated.

    Thanks,

    Andy

    #191012 Report

    Hi Andy, – Sadly No, not possible. But I counted … you just asked the most asked question of all. So if ProRealTime listens …

    Kind regards and welcome !
    Peter

    #191033 Report

    you just asked the most asked question of all. So if ProRealTime listens …

    Sounds like Gibbo needs to submit a Suggestion direct to PRT, referring to this Topic, using the Form on the link below …

    https://www.prorealtime.com/en/contact?suggestion=1

    #191047 Report

    Thanks for the feedback. I will definitely write to PRT to suggest, really frustrating as every chart has your balance displayed, the stoploss and take profit obviously work on the value of the latent gain so surely a very simple addition. I really am loving the program, but this an absolute basic function required to auto trade. Finger’s crossed PRT listen.

    #191050 Report

    But do notice that the server which runs your strategy, doesn’t know anything about your charts. It doesn’t deal with your portfolio value as well (the broker does).
    In other words : this is not so easy as we hope it could be.

    #191053 Report

    It can be coded using a starting level of equity +/- the strategy profit … but only for that strategy, it won’t know what you’ve gained or lost elsewhere.

    There’s a money management snippet somewhere that has a quit function after x% drawdown that might help, I’ll post it when I find it.

    1 user thanked author for this post.
    #191059 Report

    Not sure I understand you? ProOrder runs 4 of my strategies simultaneously and  on the Auto-trading window each running system shows Total Gain. It would need to also show latent gain just like it does on every chart with open orders.  I’m no computer programmer, but surely its easy to display the sum total of all running systems of the latent and total gain somewhere in that window, its just another indicator. PRT (api)  has all the information it needs. It maybe i’m missing something, but if there was a 2 boxes on the auto-trading window one adding up the total gain and one the latent gain  (theses values is on the top of every chart with open positions and just need adding together).  Box 1, syntax = (TotLatGain) Box 2, syntax = (TotGain) then on every strategy code under stops and targets would read If (TotLatGain = (pick a number) then close all orders and STOP trading, same with total gain.  Happy to be corrected, and you would need to factor in slippage etc. Hopefully someone from PRT will read the thread which I’ve attached the feedback form and comment as to why this isn’t possible. As far as I can see its just a simple indicator that doesn’t exist at the moment??

    #191068 Report

    I’m no computer programmer,

    That’s the thing – haha.

    So No;
    You must see PRT – the charts you are looking at, as a derived spreadsheet. All you see in there, is data from the broker. 100% all. And indeed, if you’d add up all the different columns of that spreadsheet, you have derived new data. Put it in a new tab (new chart etc.)  and you have another base for a next base etc. Exactly as you propose it …

    But it is a server which runs your strategy. Not your screen or your PC. That server knows nothing of your charts (hence derived data from the broker). It only has that strategy code as how you gave it. And it runs it … It does nothing else.

    ALL you see on your screen is derived data. FYI : it contains 1000s (I am serious) of flaws and miscalculations, because that data is redundant indeed. It may tell you that you are losing 20K instead of breaking even (want to have some screenshots of that ? haha, better not). This is all because the broker systems (which rule) are a. quite complex and b. unknown to PRT development. Development can only think logically and guess how situations will be.

    FYI again : your Statement (be that from IG or IB or elsewhere) comes from them (thus the broker) indeed. This is because PRT does not know this. No database for that.

    By the time you start to believe me, let me know. 🙂


    What would be possible, is doing / achieving what you want in backtest or forward testing. Why ? well, because at that moment your charts are open. Indeed your portfolio data can be read from the screen. But once you hand the Strategy to the server, nothing will communicate with your screens any more.
    Btw, I am not saying it can’t be made. But forget the “being easy”.

    #191069 Report

    Apologies, just realised my initial post simply talked about account balance.  I’m basically looking for a tool that will stop all systems based on equity gain or loss for the trading period I have my systems set to trade. Maybe my the above explains better?

    #191071 Report

    Fair enough, and thank you for the feedback. I’m just a bit perplexed having used a few EA’s on MT4 that do what I’m describing, different syntax and code, but running off the same broker server? So you would not rely on total sum of  latent gains on running systems to be used as a tool to stop trading, bank profit or stop loss?

    #191083 Report

    So you would not rely on total sum of  latent gains

    I do what you describe above by keepng an eye on attached, both when I am near my screen and via the IG mobile App when I away from home etc.

    I know you want all above automatic via code, but thought I’d mention it anyway.

    Attachments:
    1 user thanked author for this post.
    #191102 Report

    this is the code i mentioned. Can be used to stop the system if it falls a certain % from max equity. Here it’s set to 35% but can be anything you want.

    To my mind this makes more sense, as it seems unlikely that all your systems will fail at the same time, so maybe better to only stop the ones that are losing.

     

    3 users thanked author for this post.
    #191103 Report

    Link to above code added as Log 316 here …

    Snippet Link Library

Viewing 13 posts - 1 through 13 (of 13 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login