Why are these stoplosses not removed?
Forums › ProRealTime English forum › ProOrder support › Why are these stoplosses not removed?
- This topic has 6 replies, 3 voices, and was last updated 6 years ago by
Vonasi.
-
-
03/20/2019 at 1:30 AM #94103
Hi everyone:
Am new to ProRealTime, and trying to get my head around the automated programming.
I’ve hit this stumbling block, which is completely baffling me, so am hoping someone can help me understand why the system is doing what it’s doing.
See attached screen capture.
I have code which is supposed to completely remove all stoplosses (point 1 on attachment)
When graphing the value of the variable “sl”, it says the value is “1” (point 2 on attachment)
That means, the stoploss should be set to the SuperTrend line, which it appears to be (point 3 on attachment)
Yet, it still has a stoploss associated with the line the PSAR is on, and all new orders are cancelled out immediately by it (point 4 on attachment)
Why is this? The 4 lines of code I purposely put in (directly from the pdf manual) should cancel out all the previously set stoplosses, correct? If so, why are the orders between the two stoploss lines being cancelled out by a stoploss? (the yellow square indicator above the bars says so 🙂 )
Thank you
PS: there is no trailing stoploss set anywhere in the code. Even if there was, it should be cancelled out too by the 4 lines of code highlighted in point 1, correct?
03/20/2019 at 9:03 AM #94121There is a similar discussion here:
https://www.prorealcode.com/topic/set-value-at-zero-weird-results/
It seems from your findings that SET STOP pLOSS 0 is still not working. I would use SET STOP %LOSS 100 instead as this should work and only ever get hit if price = zero which should never happen.
03/20/2019 at 9:09 AM #94122I’ve just read your code more closely and I think you mis-understand how SET STOP LOSS/pLOSS/%LOSS/$LOSS works. The code will only set the order for the last SET STOP instruction that is read. Usually people have it at the end of the code for this reason. Calculate the distance the stop needs to be in the code and then give one instruction at the end of the code. I assume your supertendindicator and psarindicator values are calculated as a distance in pips rather than as a price?
03/20/2019 at 9:25 AM #94124The code will only set the order for the last SET STOP instruction that is read. Usually people have it at the end of the code for this reason.
If that’s the case, I have changed my code to the following:
12345678910111213sl = 0SET STOP pLOSS 0IF (c20) THENSET STOP pLOSS SuperTrendIndicatorsl = 1GRAPHONPRICE SuperTrendIndicator as "StopLoss set to ST"ENDIFIF ((NOT c20) AND (c1 AND (PSARIndicator > SuperTrendIndicator))) THENSET STOP pLOSS PSARIndicatorsl = 2GRAPHONPRICE PSARIndicator as "StopLoss set to PSAR"ENDIFGRAPH sl as "Stop Loss"and it still doesn’t make a difference.
The last line ‘read’ could be one of the stoploss lines in the “IF” statements. By their very construct, only 1 can be true. If neither are true, then the last line read should be the one before the “IF” statements, correct?
If not, then how is it possible to set dynamic STOP LOSS values based on various calculations?
I assume your supertendindicator and psarindicator values are calculated as a distance in pips rather than as a price?
Those values are the actual value of the PSAR or SuperTrend. For example:
1PSARIndicator = SAR[0.02,0.02,0.2]Is that the correct way to go about it?
Thank you.
03/20/2019 at 9:30 AM #94126SET STOP PLOSS is a distance in full points/pips
SET STOP LOSS is a distance in price
Don’t use these instructions to set a stoploss with an indicator with a price level, but only with a distance.
1 user thanked author for this post.
03/20/2019 at 9:31 AM #94127Those values are the actual value of the PSAR or SuperTrend. For example: 1 PSARIndicator = SAR[0.02,0.02,0.2] Is that the correct way to go about it?
No. The value must be a distance in pips, $ or % of the opening price. So SET STOP PLOSS 20 would set a stop loss 20 pips below or above the position price. Any time a new SET STOP PLOSS instruction is read with a different value the stop loss is moved to the new distance from the position price.
1 user thanked author for this post.
03/20/2019 at 9:33 AM #94128Use SELL AT x STOP and EXITSHORT at x STOP if you want to sell at an exact price. You will have to place these orders at every bar open as they last one bar only and are cancelled at bar close.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on