New position for a strategy.
Forums › ProRealTime English forum › ProOrder support › New position for a strategy.
- This topic has 6 replies, 2 voices, and was last updated 5 years ago by
robertogozzi.
-
-
08/21/2020 at 6:37 PM #142241
Just one more question:
In the strategy there can be a maximum of 2 positions.
After a first position, buy another position if the same conditions as the first position are met.
Or, buy another position, if the price falls 1% from the first position.08/23/2020 at 12:22 AM #142298Not tested:
1234567891011121314DEFPARAM CumulateOrders = trueIF Not OnMarket THENPriceFall = 0EntryPrice = 0ELSEPriceFall = (close <= (EntryPrice * 0.99))ENDIFAddPosition = abs(CountOfPosition) < 2IF (MyConditions OR PriceFall) AND AddPosition AND Not ShortOnMarket THENBUY 1 CONTRACT AT MARKETIF abs(CountOfPosition) = 0 THENEntryPrice = closeENDIFENDIF08/23/2020 at 9:32 AM #142299Thanks Grahal!
But there is a problem … I can’t get it to work the way I want.In the strategy there can be a maximum of 2 positions.
After a first position, buy another position if the price falls 1% from the first position.The strategy with your code buys the two positions when the same conditions are met.
What I want is that I only buy the first position with conditions, and the second position if the price falls 1% from the first position.
The first photo is what I have so far.
The second photo shows that it always buys the second position when the conditions of the first position are met, since it always buys the second position a few pips after the first position.08/23/2020 at 10:34 AM #142305That’s what you asked
“After a first position, buy another position if the same conditions as the first position are met.
Or, buy another position, if the price falls 1% from the first position.”I am not GraHal.
If you don’t want to buy the second position with the same conditions as the first one, change line 9:
1IF ((MyConditions AND (Countofposition = 0)) OR PriceFall) AND AddPosition AND Not ShortOnMarket THEN08/23/2020 at 11:06 AM #14231008/23/2020 at 1:26 PM #14232708/23/2020 at 1:45 PM #142332Post your code if you want help about it, instead of general examples.
-
AuthorPosts
Find exclusive trading pro-tools on