Adjustment in code because combined stops can not be used with pro order
Forums › ProRealTime English forum › ProOrder support › Adjustment in code because combined stops can not be used with pro order
- This topic has 34 replies, 4 voices, and was last updated 4 years ago by Vonasi.
-
-
09/11/2019 at 8:00 AM #107151
Move line 39 to line 32.
09/13/2019 at 8:11 AM #107408Hi
I want to know if it is possible to keep orders open until one is filled then after candle close it must close other pending order. Reason why i ask is. the system now places 2 pending orders. But if they are not triggered in the first 5 min the system closes both of them. And like today it took more then 5 minutes for price to pass the point where pending order was. I hope its clear. Just keep orders open until 1 is filled and then close other order.
Thank you for all your help
09/13/2019 at 8:55 AM #107416Pending orders only last one bar and need to be placed again and again, if needed.
As you have written your conditions at present the two orders will be placed continuously if not OnMarket since STARTTIME is always true, being 090000.
09/13/2019 at 10:45 AM #107426This version allows 1 trade per day and keeps the orders on the market until one (or both) are filled.
I added a variable v as I couldn’t find any 20 pip breakouts on the Russell 2000 index.
1234567891011121314151617181920212223242526272829303132DEFPARAM CumulateOrders = falseDEFPARAM FLATBefore = 084500DEFPARAM FLATAfter = 210000DEFPARAM PreLoadBars = 2000v = 20nLots = 5ONCE MaxPrice = 999999ONCE MinPrice = 0starttime = 090000IF time = starttime THENMaxPrice = highest[6](high)MinPrice = lowest[6](low)flag = 0ENDIFif onmarket thenflag = 1endifif not onmarket and time >= starttime and flag = 0 thenbuy Nlots contract at MaxPrice + v * pointsize STOPset stop loss close- Minprice + v * pointsizeendifif not onmarket and time >= starttime and flag = 0 thensellshort Nlots contract at MinPrice - v * pointsize STOPset stop loss MaxPrice - close - v * pointsizeendifSET TARGET PROFIT 120Moderators Note: Code edited to remove incorrect lines 30 and 31.
09/13/2019 at 10:48 AM #107427Thank you
The thing is after 5 min both sell and buy orders were gone. today at 9:05 pending order were deleted. I dont know why an how to change the code so it places trades until one is triggered.
09/13/2019 at 12:07 PM #10744109/13/2019 at 12:10 PM #107442Here is an MTF version that can be used on the 1 second time frame to ensure that orders in the opposite direction are cancelled a soon as an order is filled.
1234567891011121314151617181920212223242526272829303132333435363738DEFPARAM CumulateOrders = falseDEFPARAM FLATBefore = 084500DEFPARAM FLATAfter = 210000DEFPARAM PreLoadBars = 2000v = 20nLots = 5starttime = 090000timeframe(15 minutes, updateonclose)ONCE MaxPrice = 999999ONCE MinPrice = 0IF time = starttime THENMaxPrice = highest[6](high)MinPrice = lowest[6](low)ENDIFtimeframe(1 second)IF time = starttime THENflag = 0ENDIFif onmarket thenflag = 1endifif not onmarket and time >= starttime and flag = 0 thenbuy Nlots contract at MaxPrice + v * pointsize STOPset stop loss close- Minprice + v * pointsizeendifif not onmarket and time >= starttime and flag = 0 thensellshort Nlots contract at MinPrice - v * pointsize STOPset stop loss MaxPrice - close - v * pointsizeendifSET TARGET PROFIT 12009/13/2019 at 1:48 PM #107457Hi
Thank you again for the help.. I have tried you new code from the post this morning.. It works great but if i remove line 30-31 it just keeps on placing orders during the day. What I want is for the system just to place pending orders until 1 is filled and when bar close it closes other pending order.
So it must only do the 1 trade per day but must keep orders at that level until it is activated. If for some reason both is activated one will close and we go in the other direction so that is ok. I just need it to keep order open until its triggered. But for example if buy trade is activated on the close of the bar where it is activated it must close the sell pending order. So keep orders open until 1 is activated. Thats it.
Thanks again
09/13/2019 at 2:49 PM #107477You must be doing something wrong then because it works just fine when I test it. In the image which is on the 1 minute chart the flag switch is graphed and when it is 1 it is impossible for another trade to be opened. It works exactly as it should.
09/13/2019 at 3:56 PM #107489No not the MTF code
this code
1234567891011121314151617181920212223242526272829303132DEFPARAM CumulateOrders = falseDEFPARAM FLATBefore = 084500DEFPARAM FLATAfter = 210000DEFPARAM PreLoadBars = 2000v = 20nLots = 5ONCE MaxPrice = 999999ONCE MinPrice = 0starttime = 090000IF time = starttime THENMaxPrice = highest[6](high)MinPrice = lowest[6](low)flag = 0ENDIFif onmarket thenflag = 1endifif not onmarket and time >= starttime and flag = 0 thenbuy Nlots contract at MaxPrice + v * pointsize STOPset stop loss close- Minprice + v * pointsizeendifif not onmarket and time >= starttime and flag = 0 thensellshort Nlots contract at MinPrice - v * pointsize STOPset stop loss MaxPrice - close - v * pointsizeendifSET TARGET PROFIT 12009/13/2019 at 4:21 PM #10749309/13/2019 at 6:40 PM #107501but if i remove line 30-31 it just keeps on placing orders during the day.
Did you see the note from Vonasi below as maybe you have removed Line 30-31 when Vonasi had already removed Line 30-31.
Just a thought / trying to help … don’t shoot the messenger! 🙂
Vonasi wrote:
Moderators Note: Code edited to remove incorrect lines 30 and 31.
09/13/2019 at 8:12 PM #107507Just a thought / trying to help … don’t shoot the messenger!
I edited it after my last post – I did worry that it might lead to confusion – hence the moderators note!
Why don’t you also test the code GraHal then if it works OK for you too then we know that it is definitely something Lombard974 is doing wrong?
09/17/2019 at 6:59 AM #107802Hello Guys
Yes i understand what you means and i saw the note.. If i removed the lines it just kept on placing trades during the day. I dont know how to limit it to just 1 trade. But keep orders open until 1 is filled.
This code below works great on testing with tick by tick and spread. But still orders are canceled after close of first 5 min candle and maybe trade comes a little later. So i want to keep orders open until 1 is filled. The biggest problem with this code is some days it doesnt trade at all? I dont know why? But what I think is system can place trades because its too close to price.. How can this be adjusted to place trade at the nearest available price?
Thanks
1234567891011121314151617181920212223242526272829303132333435363738394041424344//-------------------------------------------------------------------------// Main code : UltimateSAF//-------------------------------------------------------------------------//-------------------------------------------------------------------------// Main code : MySystem(8)//-------------------------------------------------------------------------DEFPARAM CumulateOrders = falseDEFPARAM FLATBefore = 084500 //09:00DEFPARAM FLATAfter = 210000 //21:00DEFPARAM PreLoadBars = 2000ONCE nLots = 5ONCE MaxPrice = 999999ONCE MinPrice = 0starttime = 090000SET TARGET PROFIT 120IF time = starttime THENMaxPrice = highest[6](high) //Il massimo/minimo delle ultime 12 barreMinPrice = lowest[6](low) // (ogni ora = 12 barre da 5 minuti)flag=0ENDIFif onmarket thenflag = 1endif//************************************************************************// LONGif not onmarket and time >= starttime and flag = 0 thenbuy Nlots contract at MaxPrice STOPset stop loss close- Minprice - 60 * pointsizeif not onmarket and time >= starttime and flag = 0 thensellshort Nlots contract at MinPrice STOPset stop loss MaxPrice - close + 60 * pointsizeMaxPrice = 999999MinPrice = 0endifendif09/17/2019 at 9:02 AM #107819So now we can see the problem. You have modified the code and you are not testing exactly the same code that I am!!!
You have changed your pending order levels and yes if they are calculated too close to price then the orders will be rejected. The only way to overcome this is to never send orders too close to price!
You can set a minimum distance using a MAX and a MIN in the order price calculation.
Obviously you are no longer buying at your desired 6 candle highest high and lowest low prices though.
12MaxPrice = max(close + 60, highest[6](high))MinPrice = min(close - 60, lowest[6](low)) -
AuthorPosts
Find exclusive trading pro-tools on