Setting a pending order while on market
Forums › ProRealTime English forum › ProOrder support › Setting a pending order while on market
- This topic has 6 replies, 2 voices, and was last updated 7 years ago by kg6450.
-
-
02/18/2017 at 9:47 PM #25540
Hi all, I was scrolling through other forums looking for ideas and I came across one that looks interesting.
The link is here if anyone’s interested and the premise is to enter on the 9th bar (hour) of the day based on a certain pattern with a 10 point target and stop. If the stop is hit, a pending order is placed of twice the size 5 points away for reentry in the opposite direction.
The code I have so far is:
123456789101112131415161718192021222324252627DEFPARAM CumulateOrders = False//Buy patternsBuy1 = (Close[2] > Open[2]) AND (Close[1] > Open[1]) AND (Close > Open)Buy2 = (Close[2] > Open[2]) AND (Close[1] < Open[1]) AND (Close > Open)Buy3 = (Close[2] > Open[2]) AND (Close[1] > Open[1]) AND (Close < Open)Buy4 = (Close[2] < Open[2]) AND (Close[1] > Open[1]) AND (Close > Open)//Sell patternsSell1 = (Close[2] < Open[2]) AND (Close[1] < Open[1]) AND (Close < Open)Sell2 = (Close[2] < Open[2]) AND (Close[1] > Open[1]) AND (Close < Open)Sell3 = (Close[2] < Open[2]) AND (Close[1] < Open[1]) AND (Close > Open)Sell4 = (Close[2] > Open[2]) AND (Close[1] < Open[1]) AND (Close < Open)//Check pattern at 9th bar of the dayCheck = (INTRADAYBARINDEX = 8)IF Check THENIF Buy1 OR Buy2 OR Buy3 OR Buy4 THENBuy 1 SHARES AT MARKETELSIF Sell1 OR Sell2 OR Sell3 OR Sell4 THENSELL 1 SHARES AT MARKETENDIFENDIFSET TARGET pPROFIT 10SET STOP pLOSS 10What I’m struggling to set at the moment is the pending orders part, Does anyone know a way to set it?
02/19/2017 at 11:07 AM #25577So you have already coded the first part of the strategy? right?
and now you are stuck here? :If the stop is hit, a pending order is placed of twice the size 5 points away for reentry in the opposite direction.
02/19/2017 at 6:46 PM #2563202/19/2017 at 7:17 PM #2563802/19/2017 at 10:08 PM #25657Yeah that’s right, on the 8th bar, it will take a position depending based on what pattern formed. It will also set a pending order 5 points away from the stop loss level.
Sorry, by that I meant twice the size of the original position; so after the 8th bar we enter at £1 per point, and the pending order is set at £2 per point.
I’m sorry if I’m explaining it badly!
02/21/2017 at 12:06 PM #25881Ok good, this code attempt should be tested (forum coding):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748DEFPARAM CumulateOrders = Falseif intradaybarindex=0 thencount=0endif//Buy patternsBuy1 = (Close[2] > Open[2]) AND (Close[1] > Open[1]) AND (Close > Open)Buy2 = (Close[2] > Open[2]) AND (Close[1] < Open[1]) AND (Close > Open)Buy3 = (Close[2] > Open[2]) AND (Close[1] > Open[1]) AND (Close < Open)Buy4 = (Close[2] < Open[2]) AND (Close[1] > Open[1]) AND (Close > Open)//Sell patternsSell1 = (Close[2] < Open[2]) AND (Close[1] < Open[1]) AND (Close < Open)Sell2 = (Close[2] < Open[2]) AND (Close[1] > Open[1]) AND (Close < Open)Sell3 = (Close[2] < Open[2]) AND (Close[1] < Open[1]) AND (Close > Open)Sell4 = (Close[2] > Open[2]) AND (Close[1] < Open[1]) AND (Close < Open)//Check pattern at 9th bar of the dayCheck = (INTRADAYBARINDEX = 8)IF Check and count=0 THENIF Buy1 OR Buy2 OR Buy3 OR Buy4 THENBuy 1 SHARES AT MARKETcount=count+1direction = 1ELSIF Sell1 OR Sell2 OR Sell3 OR Sell4 THENSELLSHORT 1 SHARES AT MARKETcount=count+1direction = -1ENDIFENDIF//recovery tradeif count=1 and positionperf(1)<0 thenif direction>0 thensellshort 2 shares at positionprice-15*pointsize stopendifif direction<0 thenbuy 2 shares at positionprice+15*pointsize stopendifif onmarket thencount=count+1endifendifSET TARGET pPROFIT 10SET STOP pLOSS 1002/21/2017 at 8:30 PM #25976 -
AuthorPosts
Find exclusive trading pro-tools on