Profit Math
-
@jsauter86 ... Thanks for the inspiring response(in my mind).. No I am not selfish about my idea of a strategy because there is much more advance traders, and coders than me, with far more better ideas and strategies. I just feel embarrass about I am wasting anyone's time with my measly expert effort, but let me take you up on assisting me on what I want in this expert.
About trading forex, I have realized the following:
- There is no perfect expert or indicator
- My emotion messed with my trading especially if I am in a big DD
- I always quickly lose more easy as what I can win.
With this in mind I started to think how to manage price action instead of the probability of where the market is trending. This brought me to the idea to rather take as much profit as to concentrating on where to put my stop loss or how many pips can I squeeze out of a deal. The risks is a bit higher but the rewards is good. Normally when the PA hits your SL the PA miraculously will turn, so with this in mind I started on the following
This is the idea:
https://fxdreema.com/shared/0wmQh6UC
0_1600354221983_Stochastic MACD.mq5
Reference:
https://fxdreema.com/forum/topic/4246/example-for-each-trade/7
https://fxdreema.com/forum/topic/6813/add-a-new-trade-when-the-close-is-of-the-last-open-trade-20-pips-and-keep-the-same-take-profit-of-my-last-opened-trade/9
The problem I have is: I can get more profit if I change "Profit unrealized block"( as I have it now) to a Take Profit Average for all trades(Parent and children), which will always modify to get 20% profit of trades opened.
Optional and for safety: Limit the number of trades that the expert can open and have a Stoploss for each trade starting from the first trade place(parent)... As soon as the stoploss gets hit on the first trade that was opened it will open a new order at the current price action with the current lotsize increment percentage.When the modified Average profit percentage line goes into actual profit the Average profit line must be replace by the Average StopLoss line and trail the PA by etc. 10pips
This is in short what I would like to achieve. I have added my project and also the indicator I am using at the moment. I will want to add the Support and Resistance indicator as well.. This will be to restrict the expert to only Buy from Support and only Sell from ResistanceI thank you in advance and hope somebody would help me with this effort. I will pay if there is payment needed, most I would like to understand how to do the coding also.. Thank you
-
I'm glad I could assist with the moral decision...unfortunately it is in MT5 and I am unable to test for results.
So looking through I'm asking myself a few things;
- Why in the first 2 condition blocks on each side did you put symbol as "USDollar"? I would remove them, normally you can only place the EA on 1 pair at a time so why specify that one just 1 or 2 of the whole blocks in the chain?
- At the end of running a test do your buys and sells make the same profit with the same draw down or does the buy column do better than sell?
- I understand what you are saying about perfect experts and indicators...some people say that they're a waste of time as they are always telling you what you already know.
- The total concept of the strategy...I don't know if it could work well. Its almost as if you are fighting making a decision but I am hopeful it will work for you
-
@jsauter86
1 The Usdollar m15 condition is there because EurUsd pair have a very close correlation angle with each other. You will notice it is also on a lower time frame. I thought it a good idea to run it in front like this as a fore warning indicator to the Stochmach indicator which is running on the H1 time frame
2 The profit on Buys and Sells depends on the months... Some months Buys are better and some months Sells do better... For this last year Sells did the best, But.. the profit would be much better if it can be regulated with an average non static exit. For now its $20 profit unrealized block .. if one could move the TP forward when the PA is in 10pips reach and put the SL behind the PA 10pips and so move the "area" between the TP and SL forward with the PAction, it would be much more profit
3......
4 Thank you..... the half heart attempt is making profit at the moment... but I would not trust it on a real account -
Wow! What a strategy.

I can only think of a simple one.
As long as the entry direction if profitting. -
@josecortesllobat Somehow I cannot get this setup to work... I am sorry ... It always in the end spit out like 30 trades in the end ... maybe I am doing something terribly wrong here: I cannot get the average trade of all trades and move them together. The off blocks is the closest I got... They are all together but modify one by one, still not move all together
https://fxdreema.com/shared/kASrZhzQd -
@AlphaOmega It´s tough to understand what are you trying to reach if we don´t know what you would like to achieve. Said that, I will try to do my best in order to help you.
First of all, I would suggest you to read the information for the "For each position" block

We will focus on the main branch of your project because I would say that the reset branch looks correct at least in respect of the project´s logic.

If we assume that block with ID = 120 is true, next block is evaluated

We have that if the postions count is less than 1 (=0) for positions that match filters Group#=1 and Type=Buys, block passes. Then, do you want that the project´s execution passes if there is no buy position?
If we assue that there is no buy postion and block ID = 60 passes, it will not be true anymore and the false output will be active but there is nothing attached to the false output so I suppose that the project stops at this point.
As I said earlier, there are many questions to answer before reaching what you want.
-
@josecortesllobat Sorry, for some reason I did not get a flag that you responded? Thanks for helping. This is how far I have come with my truly low knowledge of coding and mainly your help. The forum and @roar contributed a lot, for which I am very grateful!
https://fxdreema.com/shared/pMEhJRUCc
This is what I want to achieve as the base of my averaging expert mainly:I apologize in front for my poor English as I am dutch, so maybe things will come out skew, but here goes,
In a BUY situation....The negative profit average (and future positive Stop loss average) will create some area to imprison the current price action.
So, a parent trade(0.01) gets triggered with its own TP, say 30 pips. Obviously, if the current price action moves in positive you get +30pips. When the price action moves in negative of the current buy order (say -40 pips away from current open price) a child trade(0.02) gets created with a TP of 30pips. When the child1 trade, is created the TP of the parent trade move to the negative profit average of the parent and child1 trade, +25% positive on the average profit line. It means the following:
((parent = -40pips(realized)) + (child1 = +30pips(unrealized)))/2(current trades) = new take profit will be -5pips + (25% positive on Profit Average line) of the 2 running trades.
If the price action moves further into negative, so it will continue:
((parent = -80pips(realized)) + (child1 = -40pips(realized))) + (child2 = +30pips(unrealized)))/3
(current trades) = New take profit will be -10pips + (25% positive on the Average Profit line)
and so forth
If the Take Profit in sequence gets hit all existing Buy trades must be closed as well.(Option to trail the last child trade, if hit then a new child trade must replace, with the same lot size to the taken one.)
Average Stop loss action:
If we have the parent and child trades positioned as mentioned above, The Stop loss Average of the open trades will be triggered to -30pips below the price action, when the new Take profit gets modified. The stop loss will not be fixed and move in parallel with the current price action. This movement of the Stop loss will continue till the current price action moves into positive price action and then the Stop loss will stay static, -10pips below current price action, in positive of our running trades. This will create and area between the modified take profit line and the -10pips Stop loss line with the price action imprisoned in between. If the price action moves further into profit the Stop loss line will trail by 5pips and the Take profit line will move +5pips. This criteria will be ongoing till either the price action hits the trailing Stop loss or the Take profit line.I hope I made sense enough for you to understand me clearly.... Thanks in advance for all your contribution thus far.
-
I could not reply your questions totally as Fxdreema was off-line.
This is my latest creation according to your advice: https://fxdreema.com/shared/wxUczDLRd
My biggest problem is that this expert is so fertile with orders, it is hard to control the orders to one at negative intervals of -40pips. Fore some reason the expert start with vigor and then it runs out of steam creating no orders at all? -
Hi guys .. Need some help here again please: I get strange modification of the take profit. I have tested this like a million different ways but cannot get to a solution. Could you point me in the right direction please?

https://fxdreema.com/shared/vGpLDdrPd -
Just a head-up on my very slow progress.. This is just the Buy side.. I have come to the realization that the counter 'ntrades' is not working properly with this negative strategy. The reason is that the comment counter and the 'ntrades' counter do not match the true trades count, therefor @roar 'avg formula blocks' is not working, which leads to the 'takeprofitav' not working, so no take profit's gets modified. I did manage to get a work around by the 'profit unrealized block' but it is not what I intended in my original strategy.. so profit gets wasted.
Comments counter false counter:

Here is the real Back test trades true counter:

-
Hello everyone. Hi @roar .
I'm using your formula here.
But it seems like something wrong when i add the "check profit (unrealized) block.
It doesn't catch the specified amount to start calculate the profit percentage.
Please have a look. what do i missed?
Thank you. -
@alphaomega @biztet I have scribbled up these formulas in 5 minutes, can't remember what they are for, but very probably full of bugs and logical errors lol
Please remind me of what you need and I'll think of something
-
Ok @roar . From what i understand from your blocks with formula is to secure some % of profit from the current profit reached. And it start storing the value in variable named "maxprofit". You've made just like my request few years back and the logic looks good. Only that i add the front block that is "check profit (unrealized)" to make it start the counting after profit reached specified amount like $12.
As for my request now since you could help make a better one, the request is still the same, after profit reached eg. $12, the calculation of %profit start.
Different from %trailing, it will modify the SL many times and brokers doesn't like the high usage of resources. While your formula is just a calculation, and execute the action when meet the rules.
Hope my english is clear to you.

-
@biztet logic error in block 34. When current profit is higher than earlier record -> update the record. When its not (= yellow output!) -> check how much profit has fallen.
Here's a simplified version of the same thing, no need for formula and ratio variable anymore.
https://fxdreema.com/shared/19ecZ8Qqb

-
Wow! The work of art. Really love this. Thank you so much @roar .
-
@roar Hallo .. thanks for the reply... I cannot get the formula to work out the negative profit average... @josecortesllobat gave me a start.. and this is where I am at:
https://fxdreema.com/shared/pMEhJRUCc
Please give some insight... This was your original code: https://fxdreema.com/shared/ucZlZvYcc
I want the average profit on all trades to modify the take profit.. I know it is a lot to ask but I have tried million of ways and are totally stuck.. Please give me your help.
Ps ... The average price is include the negative trades. so I add volume against the price and then the average TP must modify.. I am struggling with this because the formula does not work correctly.. this is my latest work: https://fxdreema.com/shared/dMHPN08wd -
Question : Why, when we do backtest using Control Point, the result can be like from $10 to millions? But when we do it using Every Tick, all the strategies we can think of is always like Garbage?? :((
-
@alphaomega first thing I note is these trade counter blocks of yours, they add +2 each time... It would be more secure if you just used a loop to sum up all open trades at once, not bit by bit as time goes.

-
@biztet My theory:
Control points = OHLC points.
First the tester reads the open price, and then your EA makes a buy trade with a super small TP. Next the tester reads high price -> your TP is probably activated here. However long the candle lower wick would have been, it doesnt matter because the trade is already closed. However small your SL was, it never activates, because the tester reads the high price first. 100% guaranteed profit.I'm probably wrong with this theory, but the real issue is something very similar. You get the idea. Crude data testing just doesnt work with delicate EAs (EAs with small stops or otherwise quick closing times).
-
@roar , but mine do have 50pips SL and doesn't close that fast.
Also close based on your formula, not candle close.