Add new position when + 50 points
Forums › ProRealTime English forum › ProOrder support › Add new position when + 50 points
- This topic has 11 replies, 4 voices, and was last updated 2 years ago by nonetheless.
-
-
08/15/2021 at 7:29 PM #175402
Hello
I am looking for a code that means that if I am +50 points, another position is opened with 1 contract.
But it should not be repeated more than once so max position size = 2.
Like this maybe?
123456789101112defparam cumulateorders = truePositionsize = 1maxpositions = 2if ”my conditions ” and not maxpositions and not not shortonmarket thenbuy positionsize contract at marketIF OnMarket and PositionPrice + (50 * PositionPrice) thenBuy positionsize contract at marketENDIF08/15/2021 at 9:56 PM #175413123456789101112defparam cumulateorders = truePositionsize = 1maxpositions = 2if ”my conditions ” and (not onmarket) thenbuy positionsize contracts at marketendifIf longonmarket and positionprice * positionperf >= 50 and countofposition < maxpositions thenBuy positionsize contracts at marketENDIFThis will buy 1 contract, when no position is open, and buy one further contract when the closing price of the first position is at least 50 points in plus. Not tested, however. Will work for indices, but I’m not sure about forex because they work with pips there.
12/08/2021 at 2:29 PM #183010Have previously asked about a new position be opened.
But it does not work.
It opens new positions all the time.
I want only 1 more position to be opened when my position is +40 points.
And the new position will be closed at the same time as the first
Does anyone know what such a code looks like?
12/08/2021 at 4:58 PM #18302612/08/2021 at 5:04 PM #18302712/08/2021 at 5:35 PM #183029Try this.
At current prices, positionprice * 1.0025 on the DAX is approx a 40 point gain. You can change the multiplier depending on what instrument you want to use.
It should make your backtest more accurate, as it keeps your gain relational to the historical index value.
12345678910111213DEFPARAM CUMULATEORDERS = TRUEif not onmarket thenflag = 1ENDIF// Conditions to enter long positionsIF not longonmarket and CONDITIONS THENBUY positionsize CONTRACT AT MARKETelsif longonmarket and CONDITIONS and flag and HIGH >= (positionprice * 1.0025) thenBUY positionsize CONTRACT AT MARKETflag = 0ENDIF1 user thanked author for this post.
12/08/2021 at 7:12 PM #18303112/08/2021 at 7:17 PM #183032What instrument are you using?
you could try
123G = (40/close) + 1HIGH >= (positionprice * G)or if you don’t mind if it’s not proportional you could just use
1HIGH >= (positionprice + 40)12/08/2021 at 7:18 PM #18303312/08/2021 at 7:28 PM #18303512/08/2021 at 7:45 PM #18303712345678910if not onmarket thenflag = 1ENDIFIF not shortonmarket and condsell THENsellshort positionsize CONTRACT AT MARKETelsif shortonmarket and condsell and flag and HIGH >= (positionprice - 40) thensellshort positionsize CONTRACT AT MARKETflag = 0ENDIFAnd short looks like this?
12/08/2021 at 8:19 PM #18304312345678910if not onmarket thenflag = 1flagS = 1ENDIFIF not shortonmarket and condsell THENsellshort positionsize CONTRACT AT MARKETelsif shortonmarket and condsell and flagS and LOW <= (positionprice – 40) thensellshort positionsize CONTRACT AT MARKETflagS = 0ENDIF -
AuthorPosts
Find exclusive trading pro-tools on