Any reasons why this code is not working
Forums › ProRealTime English forum › ProOrder support › Any reasons why this code is not working
- This topic has 9 replies, 4 voices, and was last updated 5 years ago by verygrubby.
Tagged: countofposition, POSITIONPRICE
-
-
01/01/2019 at 11:56 AM #87817book profit or loss12345678910111213pr=2mp=40mp1=-30floatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gainsif floatingprofit>=(mp or mp1) thenSELL AT close-pr stopendiffloatingprofit = (((positionprice-close)*pointvalue)*countofposition)/pipsize //actual trade gainsif floatingprofit>=(mp or mp1) thenEXITSHORT AT close+pr stopendif
I want to close all open positions short or long
if loss is >=30
or profit >=40
01/01/2019 at 12:13 PM #87819Just a thought … below won’t work if, for example, you are trying to exit within the bid-ask spread range (spread = 4 or more?).
I guess you’ve tried higher values for pr?
12345pr=2SELL AT close-pr stopEXITSHORT AT close+pr stop01/01/2019 at 3:14 PM #8782401/01/2019 at 7:52 PM #8783501/01/2019 at 9:28 PM #87836Isn’t COUNTOFPOSITION either 0 or greater?
When can it be negative?
When you are short.
1 user thanked author for this post.
01/01/2019 at 10:18 PM #87839@rama try below (AND increase pr > spread) … let us know if it works.
123456789floatingprofit = (((close-positionprice)*pointvalue)*countoflongshares)/pipsize //actual trade gainsif floatingprofit>=(mp or mp1) thenSELL AT close-pr stopendiffloatingprofit = (((positionprice-close)*pointvalue)*countofshortshares)/pipsize //actual trade gainsif floatingprofit>=(mp or mp1) thenEXITSHORT AT close+pr stopendif01/02/2019 at 11:09 AM #8785901/02/2019 at 11:22 AM #8786001/03/2019 at 3:27 PM #8795901/03/2019 at 5:10 PM #87961COUNTOFPOSITION can be positive or negative
I think the definition in the manual should be tweaked to make that a bit more obvious. All it says at the moment is “Counts the number of open shares or lots.”
Can a clarification be added (eg “a buy position would should as +1 and a sell position would show as -1”)?
*when I say manual I mean here: https://www.prorealcode.com/documentation/countofposition/
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on