SET value at zero weird results.
Forums › ProRealTime English forum › ProRealTime platform support › SET value at zero weird results.
- This topic has 22 replies, 6 voices, and was last updated 5 years ago by robertogozzi.
-
-
01/15/2018 at 10:50 PM #59593
In the ProbackTest manual it says that when using the SET instruction with pPROFIT and pLOSS etc that if the value is zero the instruction is deactivated. Image attached.
During backtesting of a strategy I decided to turn off a Target by setting it to a value of zero to see what difference it made. I also had a Stop in the code that turned itself off if conditions were met with a value of zero and set a SELL Limit order instead. I was getting good results and then deleted each in turn and the results were worse. It seems clear that when set to zero they are not deactivated – either that or back testing cannot cope with a zero value. Strangely the results in the optimization box for the test with a SET instruction match the results in the test with no instructions – but not the performance report from the same test.
Any ideas on this?
01/15/2018 at 11:02 PM #5959801/16/2018 at 11:50 PM #59686No replies to this…… so is the PRT instruction manual completely wrong and should be amended or has the back testing got a bug that has a problem with SET having a zero value?
This could be a major issue if you set a target and then decide to deactivate it. At the moment I would suggest that it is better to set an unachievable high value than to trust zero to deactivate it until this is confirmed.
01/17/2018 at 1:44 AM #59689No replies to this…… so is the PRT instruction manual completely wrong and should be amended or has the back testing got a bug that has a problem with SET having a zero value? This could be a major issue if you set a target and then decide to deactivate it. At the moment I would suggest that it is better to set an unachievable high value than to trust zero to deactivate it until this is confirmed.
If required I been deactivating my stop losses by setting em to 100% the entire time anyway . Zero just doesnt sound right anyway
01/17/2018 at 10:24 AM #59695If required I been deactivating my stop losses by setting em to 100% the entire time anyway . Zero just doesnt sound right anyway
This makes good logical sense as you say whereas setting to zero is rather illogical and would suggest to me that you want to close the position.
01/17/2018 at 11:23 AM #5970201/17/2018 at 9:52 PM #59746Thanks for enquiring with PRT Nicolas. The strategy is not one that I am happy to share at the moment in its entirety but the following code is the same but just with the entry conditions removed and the trailing stop loss price types changed – but it will give you an idea as to how I was using the SET STOP pLOSS 0 within the strategy. Add any conditions you like and then remove the SET STOP pLOSS 0 and you should get different results to with it. At the moment in real life I have just deleted the SET STOP pLOSS 0 and the strategy is running just fine as the trailing stop is always above this value. I just thought that it would be neater to cancel the SET STOP pLOSS before putting a SELL STOP order on the market.
I am sure it is probably just something I am trying to do in my code that is wrong – it usually is!
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960DEFPARAM CumulateOrders = FalseMoneyManagement = 0//VariablesSLPercentage = 1.7//other variables deletedCapital = 10000Equity = Capital + StrategyProfitIF MoneyManagement = 1 THENPositionSize = Max(1, Equity * (1/Capital))PositionSize = Round(PositionSize*100)PositionSize = PositionSize/100ENDIFIF MoneyManagement = 2 THENPositionSize = Max(LastSize, Equity * (1/Capital))PositionSize = Round(PositionSize*100)PositionSize = PositionSize/100LastSize = PositionSizeENDIFIF MoneyManagement <> 1 and MoneyManagement <> 2 THENPositionSize = 1ENDIF//Conditions//deletedIF Not OnMarket and <conditions1> THENGetReady = 1ENDIFIF Not OnMarket and GetReady = 1 and <conditions2> THENGetSet = 1GetReady = 0ENDIFIF Not OnMarket and GetSet = 1 and <conditions3> THENBUY PositionSize Contracts AT MarketGetSet = 0SLStart = close * (SLPercentage/100)SL = Round(SLStart)SET STOP pLOSS SLENDIF//Trailing StopIF OnMarket and close < close[1] THENSL = SL - ((close[1] - close)*(2))SET STOP pLOSS 0 //Cancel Stop LossSELL AT (PositionPrice - SL) STOPENDIFIF OnMarket and close > close[1] THENSL = SL - ((close - close[1]))SET STOP pLOSS 0 //Cancel Stop LossSELL AT (PositionPrice - SL) STOPENDIF01/18/2018 at 9:29 AM #59768Sorry, but I got the exactly same results with or without the SET STOP PLOSS 0 , even with a 100k bars backtest.. DAX 5 minutes..
With this strategy:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162DEFPARAM CumulateOrders = FalseMoneyManagement = 0//VariablesSLPercentage = 1.7//other variables deletedCapital = 10000Equity = Capital + StrategyProfitIF MoneyManagement = 1 THENPositionSize = Max(1, Equity * (1/Capital))PositionSize = Round(PositionSize*100)PositionSize = PositionSize/100ENDIFIF MoneyManagement = 2 THENPositionSize = Max(LastSize, Equity * (1/Capital))PositionSize = Round(PositionSize*100)PositionSize = PositionSize/100LastSize = PositionSizeENDIFIF MoneyManagement <> 1 and MoneyManagement <> 2 THENPositionSize = 1ENDIF//Conditionsconditions1 = close>openconditions2 = close crosses over average[20]conditions3 = close crosses over average[10]IF Not OnMarket and conditions1 THENGetReady = 1ENDIFIF Not OnMarket and GetReady = 1 and conditions2 THENGetSet = 1GetReady = 0ENDIFIF Not OnMarket and GetSet = 1 and conditions3 THENBUY PositionSize Contracts AT MarketGetSet = 0SLStart = close * (SLPercentage/100)SL = Round(SLStart)SET STOP pLOSS SLENDIF//Trailing StopIF OnMarket and close < close[1] THENSL = SL - ((close[1] - close)*(2))SET STOP pLOSS 0 //Cancel Stop LossSELL AT (PositionPrice - SL) STOPENDIFIF OnMarket and close > close[1] THENSL = SL - ((close - close[1]))SET STOP pLOSS 0 //Cancel Stop LossSELL AT (PositionPrice - SL) STOPENDIF01/18/2018 at 10:44 AM #5978701/18/2018 at 5:24 PM #5982301/18/2018 at 9:43 PM #59837I can replicate the difference too. But, sorry if I’m wrong, why it should get the same result if we remove the stoploss and exit with another condition?
Sorry Nicolas but I am not quite sure what you mean.
The strategy opens a position and sets a SET STOP pLOSS at the same time to ensure that there is a stop loss from the moment a position is opened. Then at the close of the next candle whether it is an up or down candle the SET STOP pLOSS is cancelled by setting it to zero (as the PRT manual says to do) and from then on and at the close of each candle the stop loss is controlled by a SELL AT STOP order. The stop distance is always closer to the POSITIONPRICE than the first SET STOP pLOSS order (or even above it) so the original SET STOP pLOSS is technically irrelevant and could never be hit.
The SET STOP pLOSS with a zero value should just cancel the original SET STOP pLOSS order as a neat and tidy part of the code but it appears to alter the final strategy results when it should not.
01/18/2018 at 10:23 PM #5984101/18/2018 at 10:34 PM #59844Yes, you’re right, I must be tired..
You work too hard. Have a day off and get back to me whenever! The code works just fine without cancelling the SET STOP pLOSS order so it is really just about it not doing what it says in the manual. No panic – open a beer and put your feet up.
01/29/2018 at 10:19 AM #60813@Vonasi why don’t you get Mods to move this Thread to PRT Platform Support so then the PRT Mods can appraise themselves of the issue.
I have just asked for a same / similar issue to be moved to PRT Platform Support … so then we have two examples of an issue that has always been there (and we never noticed??) else this issue has appeared recently?
Either way, the Issue needs sorting and as all the info is on this Thread (and the Thread I’ve asked to be moved) then this is the most efficient way for us to advise PRT!?
Thank You
GraHal01/29/2018 at 4:55 PM #60875If the Moderators wish to move this to PRT Platform Support then please do so as that is now maybe a better location for it.
I was hoping that Nicolas would have time to look into it but I know that he is very busy and has also been ill recently (haven’t we all!)
-
AuthorPosts
Find exclusive trading pro-tools on