MAE maximisation
Forums › ProRealTime English forum › ProOrder support › MAE maximisation
- This topic has 11 replies, 5 voices, and was last updated 2 years ago by Khaled.
-
-
09/05/2020 at 4:20 PM #143431
Hi guys,
I’ve been immersed in my bots for the past few weeks so apologies if the answer is already covered in the forum, I’m going to catchup on the threads this evening.
I have fine tuned an autotrading bot for good profit but I’m looking for a way to maximise the missed out MAE when I have a set take profit figure considering the trailing stop loss doesn’t kick in with my broker IG only the set stop loss.
All suggestions welcome and very much appreciated.
Thanks in advance,
Kovit
09/07/2020 at 9:15 AM #14351009/08/2020 at 5:15 PM #143640That sounds easy, but I struggled & failed to code it. Could you show us how it’s done properly to calculate an average of the maximum favorable excursion from all trades done? I question if it should be separated for long & short. It could be a very usefull snippet!
1 user thanked author for this post.
09/08/2020 at 6:13 PM #14364809/09/2020 at 9:37 AM #143693The 2D chart is indeed a good way to find the average of the MFE, good spot.
I was thinking of a more dynamic way by calculating the average of MFE inside the strategy. Easier with array:
long order only, rough idea, need deeper look12345678910111213141516171819202122232425262728293031323334353637defparam cumulateorders=false//dummy strategyif rsi[14] crosses over 50 thenbuy at marketendifset stop ploss 50//increase the array indexif not longonmarket and longonmarket[1] thenindex=index+1endif//compute the MFEif longonmarket thenmfe = max(mfe,high-tradeprice)$mfeArray[index] = maeendif//at least 10 orders to allow the average calculationif isset($mfeArray[2]) thensum=0for i = 0 to index dosum=sum+$mfeArray[i]nextavg = sum/indexendifgraph avgif avg>0 thenset target profit avgelseset target pprofit 200endif09/09/2020 at 9:39 AM #14369409/09/2020 at 10:23 AM #143702Thanks Nicolas,
unfortunately I don’t have acces to v11 to test and I ‘am not familiar with variables.
For my purpose I was looking at MFE. Having one example helps to create the other though.
Your code covers a few problems I had, such as having a minimum number of trades before calculation can happen. However I don’t understand where the minimum of 10 orders is specified.
It mentions mae (row19), is that correct because everything else is based on mfe?
09/09/2020 at 12:35 PM #143727yes sorry, I changed “isset($mfeArray[10])” with only 2 orders.
BTW, as i said, it is a rough idea, while it computes correctly the average, if we have a takeprofit defined in the strategy, therefore the MFE is already known: it is the takeprofit value! Do you see what I mean?
09/09/2020 at 12:36 PM #14372809/09/2020 at 12:54 PM #14373210/25/2020 at 12:43 PM #14839612/18/2021 at 2:20 AM #183524Bonsoir Nicolas, merci pour ce code que je vais tester. Je ne m’y connais pas en Arrays. Est-ce que le code Long/short suivant est correct?
Array MFE Long/Short123456789101112131415161718192021222324252627282930313233343536373839404142434445464748defparam cumulateorders=false//dummy strategyif rsi[14] crosses over 50 thenbuy at marketendifif rsi[14] crosses under 50 thensellshort at marketendifset stop ploss 50//increase the array indexif not longonmarket and longonmarket[1] thenindex=index+1endifif not shortonmarket and shortonmarket[1] thenindex=index+1endif//compute the MFEif longonmarket thenmfe = max(mfe,high-tradeprice)$mfeArray[index] = mfeendifif shortonmarket thenmfe = max(mfe,tradeprice-low)$mfeArray[index] = mfeendif//at least 2 orders to allow the average calculationif isset($mfeArray[2]) thensum=0for i = 0 to index dosum=sum+$mfeArray[i]nextavg = sum/indexendifgraph avgif avg>0 thenset target profit avgelseset target pprofit 200endifMerci encore
-
AuthorPosts
Find exclusive trading pro-tools on