missing code for closing order @ next bar open
Forums › ProRealTime English forum › ProOrder support › missing code for closing order @ next bar open
- This topic has 9 replies, 4 voices, and was last updated 5 years ago by Nicolas.
-
-
08/13/2018 at 1:21 PM #78080
Hi together,
I’d like to close a position at the open of the next bar. As i found out nextbaropen can not be used to close positions. Am I right?
Perhaps somebody can help me with the snippet.
123456789101112131415161718192021222324252627DEFPARAM CumulateOrders = FALSEA = ABS(Dclose(1))-ABS(Dopen(1)) //inner RangeB = ABS(dhigh(1))-ABS(Dlow(1)) //outer RangeC = 0.25 //Faktorn = 1//Lotsize// Conditions to enter long positionsIF NOT LongOnMarket AND CLOSE > OPEN AND (A/B) < C THENBUY 1 SHARES AT HIGH STOPENDIF// Conditions to exit long and short positionsIF LongOnMarket THENSELL n SHARES AT NextBarOpenENDIF// Conditions to enter short positionsIF NOT LongOnMarket AND CLOSE < OPEN AND (A/B) < C THENSELLSHORT n SHARES AT LOW STOPENDIF// Conditions to exit short long positionsIF ShortOnMarket THENEXITSHORT AT NextBarOpenENDIF08/13/2018 at 2:12 PM #7808108/13/2018 at 4:19 PM #78088Here is the amended code…
It’s ony working for long positions. Short didn’t work well.
1234567891011121314A = Close[1]-Open[1] //inner RangeB = High[1]-Low[1] //outer RangeC = y //Faktorn = 1//Lotsize// Conditions to enter long positionsIF NOT OnMarket AND (A/B) < C THENBUY n SHARES AT MARKETENDIF// Conditions to exit long and short positionsIF OnMarket THENSELL AT MarketENDIFFor C = 0,43 worked best
08/13/2018 at 7:31 PM #7809908/13/2018 at 7:52 PM #78100// Conditions to exit long and short positions
123IF OnMarket THENSELL AT MarketENDIFEnter short keyword is SellShort
Exit short keyword is ExiShort
Do you need above to get your code working because in the Marc version code you have no SellShort?? (Vonasi version code does have SellShort / ExitShort).
08/13/2018 at 8:15 PM #78102I think GraHal that he means that he has removed the short side of the strategy because it does not work on the DJI. Which is not surprising if you look at the DJI chart – low on the left and high on the right and virtually a straight line in between!
1 user thanked author for this post.
08/13/2018 at 8:22 PM #7810408/13/2018 at 8:26 PM #7810508/14/2018 at 2:02 PM #78148Hi together,
I have a suggestion regarding this system…perhaps somebody can help me amending this code.
I thought about following thing.
Each day I have a reference candle for example at 8 o’clock.
I enter a long trade (either at market or as High Stop order) when close of a following candle is above open of reference candle and range of High and Low is bigger compared with Open and Close (bigger than variable factor)
I enter a short trade (either at market or as Low Stop order) when close of a following candle is below open of reference candle and range of High and Low is bigger compared with Open and Close (bigger than variable factor)Exit shall be at open of next bar Open or Close of current bar after order was placed.
Can anybody help me?
Thank you in advance
Marc
08/16/2018 at 2:06 PM #78371Hi Marc, I think that it could be a good idea to learn to code a bit. What you request is easy to add to your strategy.
-
AuthorPosts
Find exclusive trading pro-tools on