Increase and decrease trade amount with profit and loss
Forums › ProRealTime English forum › ProOrder support › Increase and decrease trade amount with profit and loss
- This topic has 3 replies, 1 voice, and was last updated 4 years ago by Philstrading.
-
-
08/28/2020 at 7:24 PM #142860
So comments welcome, mods for other scenarios, but here I got to thinking about keeping my profits reasonably safe and increasing trade amounts without stopping the program. so below is the code. It works on backtest and sould reduce trade amount based on your profit elvel and setting for tolerance.. Comments and additions welcomed but for me this works well I think.. I’ve yet to backtest with losses but think it should work based on the logic.
Increase and decrease trade amount with profit123456789101112131415161718192021222324Mystartamount = 1 //your risk tolerance start amount based on stoplossSL=300// your stoplosstp=28 //your take profit levelmydiv=2 //factor by which to increase the trade amount by to limit stoploss but increase it with profits safely which will depend on stopout factorsMyabsloss=0 //the amount you want to tolerate as an absolute loss.x=strategyprofit/(SL*mystartamount)If strategyprofit<=(SL*mystartamount) thenMyamount=mystartamountEndifIf x>=2 then //x=the factor to increase risk calculation by when the profit has reached the stoploss multiple of xmyamount=(x*((mystartamount/mydiv))) //(x*mystartamount/2) is exponential growth and keeps stoploss at less than profits when profits above SL*2.endifIf strategyprofit<0 thenquitendifIF "your conditions" thenBUY Myamount contracts at marketset stop ploss SLSet target pprofit tpENDIFIf strategyprofit<myabsloss thenquitendif08/29/2020 at 12:29 AM #142876You will find that if you use an absolute gain it can increase yield and having a Mydiv greater than 2 will limit gains initially but minimise losses if it starts to fail and as it grows good wins/runs can become exponential in meeting absolute gains though thats in backtesting of course. Currently if you apply to the Dax Kama program I’ll have to dig out a link, it turns 9K to 21K with a £15K absolute gain when running from Jan 2019 and then quit the program.
Any suggestions on resetting the strategyprofit=0 would be appreciated as that could reset the program to restart from scratch after hitting target. If there’s any code snipbit for that be good i.e telling the program to set to strategyprofit=0 for a fresh start without closing the program.
08/29/2020 at 10:42 AM #142886Anyone looking I’m adding a margin tolerance and minimum trade tolerance level which will stop program shutting down if that became a factor but a means of strategy profit resetting or calculating strategy profit to rest be useful. I’ll scour the forum but a pointer be useful if its there
08/30/2020 at 3:34 PM #142976So this is a pic of my initial idea and how it works. I’ve not included the code yet thats been modded as it’s not quite finished owing to tweaking the margin tolerance, and snagging out any scenarious where calculation may stop the program continuing, but it’s looking promising – if needing refinement..
The idea is that when running well it will increase the trade amount in increments, and when experiencing a loss reduce the trade amount accordingly up to the initial trade amount starting the program. Potentially it could be reduced as well if experiencing too much program drawdown..
The 100% data in the pic attached highlights the incremental change, and it reduces back to the intial trade amount once it has hit a target amount which I call my absolute gain = myabsgain in the code.
As a reasonably newby I think its important to optimise potential success of a strategy at startup and put in risk tolerance before quitting, so this is to look to optimise profitable runs and it can be tweaked with the myabsgain, some code, and reduces trade amount accordingly if dropping profits… Not much interest in the idea It seems, so I’ll limit posting unless some interest shown..
-
AuthorPosts
Find exclusive trading pro-tools on