Stop Profit doesnt work
Forums › ProRealTime English forum › ProOrder support › Stop Profit doesnt work
- This topic has 24 replies, 5 voices, and was last updated 11 months ago by PeterSt.
-
-
01/05/2024 at 11:45 PM #226022
yes, its the same
01/06/2024 at 7:12 AM #226024One hour later … and after typing a post which headed the wrong direction, this is the short answer :
Because your trailing condition is not correct, you set the Set Stop Profit right away, and thus the exit happens right away.
1if high-tradeprice(1) > 100 and longonmarket thenthat.
Killer, I am sure you are not satisfied with this answer, so just let me know – then I may post that more vague text, but which will be explanatory just the same. But in brief (what I think of it) :
It comes down to using the Set Stop Profit on the wrong side of the price. You must first have profit, in order to set it Under the price. But because your condition is not correct, the command gets active right away and “profit” is taken accordingly.
Add to this that the documentation is written out of sufficient context, and you may be using the command wrongly. But I can’t be sure about that.
In any event, see below; the white line is your trailingsl. And you can see how it starts under the (entry) price. And the vagueness in all : let it start above the price does not work either. So it is the moment where you start using it, not being correct. And this just comes down to the If condition (see above) not being correct.123if onmarket thengraphonprice trailingslendifI made a new .itf I originally wanted to post, but *that* could be with the wrong assumptions on what you actually want to achieve. So I better not post that.
Regards,
Peter1 user thanked author for this post.
01/06/2024 at 10:06 AM #226026thx, but this i didnt understand.
1if high–tradeprice(1) > 100 and longonmarket thenmeans for example if the tradeprice is 15000 and den high of the last bar ist 15150 then set the stop proft at 15100. Whats wrong? What is my misunderstand? And what is the correct condition?
Maybe you can post your itf, so i can take a look at it.
01/06/2024 at 11:32 AM #226033Please remember what I said : this earlier made post will only make it more vague. But it gives some insight and from there you should be able to get it working.
Main culprit remains : That If condition does not work out for you and now the Set Stop Profit will work against you.
Ask questions when needed.
I don’t know exactly what the idea is behind Set Stop Profit, but it does not work out the way you use it (also see below at the Disclaimer).
https://www.prorealcode.com/documentation/set-stop-profit/The other day someone was fighting with Set Target Loss ? same thing I guess (but I did not try that). I think it was @ashehzi.
The commands feel a bit “bad” to me . So what you you mean set a Stop for profit ? we set TARGETs for profit. And we set STOPS for loss (protection).
I never used these commands, so undoubtedly I am wrong all over. Fact is, that it just does not work as advertised (which is without further context).
In between the lines 😉
I myself can be easily confused by the fact that I would use Set Stop Loss for the exact same, with the notice that I would set this when in profit. Notice that this just works (well) and that Set Stop Profit with that is redundant or not understood by me.
So Killer, try the one attached. See at the bottom.
123If OnMarket thenset target $Profit ProfitParam //80endifNow it works exactly as you would expect it. **
Notice that I (re)activated the spread, so that you can even better check that it works. Play with that; set it to e.g. 40 and see the results.Mind the ProfitParam I added for even easier checking.
The Set $Profit vs Set Profit does not make a difference in this 1 point instrument case (1 point is 1 euro).
I could be important that I tried this under V12, but I don’t think so, because you could not get it to work yourself either. However :
Your trailing is not working well. See the white GraphOnPrice line (line 60). But I am sure you will easily solve that now, now it starts to work in the base.
**): But it depends; the sheer fact that you use it under the condition of the trailing, suggests that you want to use it under the price, so that if the price drops the exit occurs and the profit is taken. This makes the culprit one thing only : your trailing condition is not right (and it isn’t).
Regards,
Peter
Disclaimer : I feel that Set Stop Profit can be used differently (like we can set Stops or Limits at the wrong side of the Price) and possibly this is related to having more contracts (or better : cumulated orders), but Nicolas’ documentation does not talk about that. And in any event without further context, the command as described places the exit at the wrong side of the Price and goes out immediately.
So to me it feels like Set Stop Profit can be used to lock in profit (price drops too much, so let’s take some of the profit). Thus from the documentation (I only read Nicolas’s) :Allows you to place a stop at X points / % / € / unit above the entry price of the position (for a buy order or below for a sellshort order).
It would imply that you first are above the entry price and then at a certian stage apply the Set Stop Profit.
1 user thanked author for this post.
01/06/2024 at 1:36 PM #226038Allows you to place a stop at X points / % / € / unit above the entry price of the position (for a buy order or below for a sellshort order).
It would imply that you first are above the entry price and then at a certian stage apply the Set Stop Profit.
Thx, but this is exactly what i have done: If the the trade is 150p in plus then set the stop in profit at 80 –> Allows you to place a stop at X points / % / € / unit above the entry price of the position (for a buy order or below for a sellshort order).
123if high-tradeprice(1) > 100 and longonmarket thenset stop Profit 80endifWith this condition the system will make only 1 trade or 1 trade and the following trades will be close in the same second.
- If the stop profit wont be filled the system will make only one trade
- If the stop profit will be filled the system will have this stop profit anymore and close all following trades in the same second
The solution could be to cancel the stop profit order, but how can i do this?
01/06/2024 at 1:42 PM #226039Thx, but this is exactly what i have done:
Thank you. That is good to know. So this takes out the confusion in the post I wrote at first, as it is now known that it is your intention indeed to take the profit under the price.
I am out for a bit of shopping and when back I will try to make it work for you.N.b.: Possibly you took this code from some regularly posted trailing code ? if so, can you give a link to that ?
1 user thanked author for this post.
01/06/2024 at 1:53 PM #226040Thx a lot for help, now it works.
This code must be at the end
123if not ONMARKET THENset stop profit 0ENDIF1 user thanked author for this post.
01/06/2024 at 2:05 PM #226042to take the profit under the price.
For Longs:
Yes this is my understanding, Set Stop Profit, example … profit currently at 100, lets preserve some of that if / when price falls back, I be happy to exit with 80 profit.
Similar (but kinda opposite logic) to Set Target Loss, example … Loss currently at 100, let’s see if I can get out with less loss if price rises, I be happy to exit at 20 loss.
2 users thanked author for this post.
01/06/2024 at 3:12 PM #226043This code must be at the end
Ah super. And yes, you gave that clue already; I did not look back, but something in the realm of “the command retains to be active” without something like that setting to 0 explicitly. Well done !
The real clue, of course, is that it always worked a first time and then stopped working. This exactly matches your solution. And your condition was correct at it. 🙂1 user thanked author for this post.
01/06/2024 at 3:22 PM #226045Similar (but kinda opposite logic) to Set Target Loss, example … Loss currently at 100, let’s see if I can get out with less loss if price rises, I be happy to exit at 20 loss.
And now we need a matrix of all these commands which will override each other. Example (made up and not tested) : A Set Stop Loss will not allowed to be combined with a Set Stop Profit. … Because they are both pending stops (?).
And will the Set Target Loss be a Stop or a Limit ? … that kind of things.Could be quite undoable to work out, because only in practice you will be able to find out for real (practice : Live or Demo, and possibly not even everything for Demo). I mean, only last week I found myself to be a happy camper to be able to graph (thus in backtest) a pending stop for real so that it would match reality. But I could only do that because I had reality in the first place (from past Live trades).
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on