Orders are closing as soon as they are opened
Forums › ProRealTime English forum › ProOrder support › Orders are closing as soon as they are opened
- This topic has 21 replies, 5 voices, and was last updated 5 years ago by Nicolas.
-
-
08/14/2018 at 7:33 PM #78183
Hi,
Recently I have noticed when I have been doing back test that my orders are being closed as soon as they are opened(within miniseconds). I was wondering if anyone else has faced this same issue ?
I also experienced this issue when I tried to run the automated trading on an IG demo account. So as you can imagine I am very concerned about running a live test untill I find a fix for this issue.
08/14/2018 at 8:35 PM #78198To be able to replicate the trades you should post:
- code
- instrument
- TF
08/14/2018 at 8:53 PM #7819908/15/2018 at 9:04 AM #78225Hi Roberto,
sorry for that. I thought maybe they was an update or something as the code was working fine previously. Please find attached the code that I am using on the autotrade stystem.
1234567891011121314151617181920212223242526272829303132333435363738// code for brackets// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Cancel all pending orders and close all positions at the "FLATAFTER" timeDEFPARAM FLATAFTER = 204000// Setting Up Time FrameworknoEntryBeforeTime = 143000timeEnterBefore = time >= noEntryBeforeTimenoEntryAfterTime = 2040000timeEnterAfter = time < noEntryAfterTime// Conditions to enter short positionsignored, indicator2, indicator1 = CALL "Algo for dojo visualStudio"c1 = (indicator1 >= indicator2)ignored, indicator3 = CALL clampc2 = (indicator3 = -30)IF (c1 and c2) AND timeEnterBefore AND timeEnterAfter THENSELLSHORT 4 PERPOINT AT MARKETENDIF// Conditions to exit short positionsignored, indicator5, indicator4 = CALL "Algo for dojo visualStudio"c3 = (indicator4 CROSSES UNDER indicator5)ignored, indicator6 = CALL clampc4 = (indicator6 = 30)IF c3 and c4 THENEXITSHORT AT MARKETENDIF// Stops and targetsSET STOP pLOSS 20SET STOP pTRAILING 1408/15/2018 at 9:12 AM #78226Hi Vonasi,
Thanks for getting back to me. Just wondering if you have ever come across an issue like this before ?
I am using a 10 minute timeframe. Both on the chart and on the automated system.
The system is being used in conjunction with IG.
Kind Regards,
Simone
08/15/2018 at 9:17 AM #78227my orders are being closed as soon as they are opened(within miniseconds)
I’ve had above Issue before, but I can’t recall what caused it (it was a coding issue though) it will probably come to me as I go about my activities today.
I’ll let you know.
08/15/2018 at 9:20 AM #78228Sorry, I don’t have the code to replicate those indicators, if you post them then you should also specify TF and instrument used.
Try replacing line 32 with
1IF c3 and c4 AND ShortOnMarket THENbut that’s just guessing!
1 user thanked author for this post.
08/15/2018 at 9:33 AM #78234Yes I think line 32 is the problem because if at the time of entry c1, c2, c3 and c4 conditions are all met then it will place a sellshort order and an exitshort order at the same time. You need to make the conditions return a 1 or 0 and graph them to see what they are doing at each entry.
1 user thanked author for this post.
08/15/2018 at 10:11 AM #7824408/15/2018 at 10:14 AM #78245Yes I think line 32 is the problem because if at the time of entry c1, c2, c3 and c4 conditions are all met then it will place a sellshort order and an exitshort order at the same time. You need to make the conditions return a 1 or 0 and graph them to see what they are doing at each entry.
Still it’s odd, since ProOrder needs a full bar to be able to detect an ONMARKET status, thus line 33 should not be executed, unless ProOrder does not test the ONMARKET status but sends the order to the broker, instead, or he uses a 1-second TF!
08/15/2018 at 10:15 AM #78246Hi Roberto & Vonasi,
Thanks for taking the time to go through the code. I appreciate all the suggestions
I have simplified the code and started from scratch in an attempt locate the issue.
So please find attached the new simplified code that is throwing up the same issue of closing before it opens. However it should be noted that it is doing it less often than before.
Looking forward to your suggestions,
Regards
1234567891011121314151617181920212223242526272829// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 143000timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 210000timeEnterAfter = time < noEntryAfterTime// Conditions to enter short positionsignored, indicator1 = CALL airlineSpecc1 = (indicator1 >= indicator1)IF c1 AND timeEnterBefore AND timeEnterAfter THENSELLSHORT 4 PERPOINT AT MARKETENDIF// Conditions to exit short positionsignored, indicator2 = CALL airlineSpecc2 = (indicator2 CROSSES UNDER indicator2)IF c2 and shortonmarket THENEXITSHORT AT MARKETENDIF// Stops and targetsSET STOP pLOSS 20 pTRAILING 14INDICATOR12345678910111213141516171819202122currentHigh=High[0]previousHigh=High[1]currentClose=close[0]//Bearish signdiffCurrentVSPreviousHigh=previousHigh-currentCloseIF currentHigh>previousHigh THENrisingHigh=12elserisingHigh=2ENDIFreturn risingHigh,diffCurrentVSPreviousHigh08/15/2018 at 10:21 AM #78247Line 14 will always be true and line 22 will always be false.
Please post the correct lines!
08/15/2018 at 10:34 AM #78250Line 29 is not allowed (despite being documented), you cannot combine two kind of SL at the same time and, if you separate them on two lines the second line will overwrite the previous one!
08/15/2018 at 10:36 AM #78251Still it’s odd, since ProOrder needs a full bar to be able to detect an ONMARKET status, thus line 33 should not be executed, unless ProOrder does not test the ONMARKET status but sends the order to the broker, instead, or he uses a 1-second TF!
…..going back to that first code – there is no check for ONMARKET status to be met for line 33 so if the exit conditions c3 and c4 are met then an exit order will be sent at the same time as a buy order.
From that first code:
123IF c3 and c4 THENEXITSHORT AT MARKETENDIF08/15/2018 at 10:57 AM #78252EXITSHORT should NOT be interpreted as a BUY order, but the EXIT of a SHORT trade. If there’s no SHORT trade open then EXITSHORT should be ignored, isn’t it?
-
AuthorPosts
Find exclusive trading pro-tools on