Stop order functioning in codes versus limits
Forums › ProRealTime English forum › ProOrder support › Stop order functioning in codes versus limits
- This topic has 6 replies, 2 voices, and was last updated 3 years ago by Philstrading.
-
-
03/09/2021 at 3:07 PM #163616
Hi guys n gals
A quick question around stop orders in the code and when executed. so on the selected pic attached I graphed in the area of the order for 1:1 whether used as a limit or stop order.
In backtesting the limit works fine takes out the desired profit, on stop orders it also takes out the orders howeve in some circumstances it doesn’t when the price rallies, however backtesting on Dax here I’m seeing it extend around 10 pips above and come back 5 pips below which even with spread should stop out and take partial profits but it doesnt. This is 08:45 a.m and looking onthe platform minimum stop is 5.
So my questionis do stop orders have to come past the minimum order distance when set as a stop?
Why do we think this isn’t stopping out?
In the meantime I’ll likely just code in a sell at market for 50% off instead of sitting orders but an explanation of the Stop order not stopping out in that picture be appreciated.
Thanks in advance.
03/09/2021 at 3:19 PM #163623Ok so the spread was 1.2 and when setting to 2pips it does stop out – so I may not understand something as my logic sugests it should stop out on that chart at some point as it passes and comes back down but allows the trade to continue without amount being reduced with 1.2 pips…
03/09/2021 at 3:24 PM #16362403/09/2021 at 5:17 PM #163642Yes, the line you see is where the order is taken for limit orders and the stop order where spread is set to 2. to be clear it executes the stop order at 2 pips spread and not at 1.2 pips spread.. not sure why…. the order actually executes at the start of the line and the line and is “graphonprice pipslim” which is where pipslim is >= the 1:1 in pips the order level whichremains unable to re-execute a second time around.
stop order12345678910y=myamount/2If not onmarket thenstopstop=0endifif stopstop=0 thenpipslim=tradeprice*positionperfIf longonmarket and pipslim>=(tradeprice+SLL)-tradeprice thensell y contracts at tradeprice+sll stopstopstop=1endifI just had a crash on the platform and it didnt save but without re-testing believe that was the code.
Works for 2 pip spread backtest but not for 1.2 pips but I think based on the 1 second chart price action it shouldn’t matter in relation to those spread differences so a query on what it’s doing really.
It is a backtest
03/09/2021 at 5:39 PM #163645I’ll try the below code and see if it has the same anomaly
code12345678910111213141516171819If not OnMarket thenNewSLim = 0EndifIf take50>0 thenif NewSLim = 0 and PositionPerf > 0 thenPipslim = tradeprice * PositionPerfIf longonmarket and Pipslim >= (SLL*pipsize) thenNewSLim = tradeprice + sllstopstop=1elsif shortonmarket and Pipslim >= (SLS*pipsize) ThenNewSLim = tradeprice - slsstopstop=1EndifendifIf NewSLim > 0 ThenSELL y contracts at NewSLim STOPbuy y contracts at NewSLim STOPendifendif03/09/2021 at 5:52 PM #163646might have to add direction there methinks
03/09/2021 at 7:00 PM #163652My simplest solution
code123456789101112131415y=myamount/2/////////////////////////////////////////////////////////////////////////If not onmarket thenstopstop=0endifif stopstop=0 and take50=1 thenpiplim=tradeprice*positionperfIf longonmarket and piplim>=(tradeprice+SLL)-tradeprice thensell y contracts at marketstopstop=1elsif shortonmarket and piplim >=tradeprice-(tradeprice-SLS) thenexitshort y contracts at marketstopstop=1endifendifBroker orders… pwfff!
-
AuthorPosts
Find exclusive trading pro-tools on