set profit or stop loss after 3 bars
Forums › ProRealTime English forum › ProOrder support › set profit or stop loss after 3 bars
- This topic has 13 replies, 3 voices, and was last updated 8 years ago by James B Eddon.
-
-
06/29/2016 at 8:11 PM #10002
is it possible to set profit or stop loss if the trade is 3 bars in market ?
this doesn`t work
123456789101112IF ONMARKET AND (BarIndex - TradeIndex) >= 3 THENSET TARGET PPROFIT 20ENDIFIF ONMARKET AND (BarIndex - TradeIndex) >= 3 THENSET STOP PLOSS 20ENDIF06/30/2016 at 8:36 AM #1001306/30/2016 at 9:33 AM #1001606/30/2016 at 10:55 AM #1001906/30/2016 at 11:38 AM #1002006/30/2016 at 1:35 PM #10022Ok, but do you want your pending orders to have these TP/SL values after they have been placed for at least 3 bars or do you want the TP/SL to be set on these orders that have been triggered by price already (so now on market)?
06/30/2016 at 1:46 PM #1002506/30/2016 at 1:59 PM #10027If I asked you the question about kind of trades you’d like to have this condition met, it’s because pending orders can’t have more than 1 bar old : they are deleted and re-placed at each bar (as long as you put them on).
Ok, so the code I gave you should work for orders at market. Without your whole code strategy, I can’t be sure why it doesn’t work, so you can share me your code and I’ll be glad to debug it! 🙂
06/30/2016 at 3:02 PM #10032Hmm I get a clue from someone already affected by this.
Setting takeprofit and stoploss must be made before 3 bar elapsed, so I suggest this code instead:
1234567IF ONMARKET AND (BarIndex - TradeIndex(1)) >= 3 THENSET TARGET PPROFIT 20SET STOP PLOSS 20ELSESET TARGET PPROFIT 0SET STOP PLOSS 0ENDIFWhich should resolved the problem I believe.
06/30/2016 at 3:34 PM #10033thanks a lot .. i will test it.
and this is the code without all the filters, this works on dax 15 min ..
1234567891011121314151617181920212223242526272829303132333435a = 39b = 7Upper1 = HIGHEST[a](HIGH[1])Lower1 = LOWEST[a](LOW[1])Tenkan = (Upper1 + Lower1) / 2Upper2 = HIGHEST[b](HIGH[1])Lower2 = LOWEST[b](LOW[1])Kijun = (Upper2 + Lower2) / 2asien = ( TIME < 080000 )m = 8HOCH1 = highest[m](high)HOCH2 = highest[m](high)if asien thenHOCH = HOCH2elseHOCH = HOCH1endifichi = Kijun crosses over Tenkanbuy1 = HOCH[1]if ichi thenBUY 1 CONTRACT AT HOCH stopendifif ichi[1] thenBUY 1 CONTRACT AT buy1 stopendifIF (BarIndex - TradeIndex(1)) >= 3 THENSET TARGET PROFIT 20SET STOP PLOSS 40ENDIF06/30/2016 at 3:54 PM #10035Thanks for the code. I spotted some kind of “mistakes”, but don’t take it bad.
1/ HOCH1 and HOCH2 are the same variable (they return the same value).
2/ You can’t buy at a stop level of HOCH because it is the actual highest high and it’s currently moving if the price goes up. You should refer to HOCH[1] instead.
3/ As I told you already in my previous post, you need to set up your stop order at each bar because IG delete pending order at each new bar (because of no expiration possible). So when you place your pending orders into a conditional statement like you made from line 28 to 30, your order only last 1 bar (because your condition ichi[1] only occurred one time) which maybe not sufficient for them to trigger.
4/ Replace lines 32 to 35 with the code snippet I gave you.
06/30/2016 at 4:02 PM #1003706/30/2016 at 4:13 PM #10041- yes they are the same, in my system a add somme different pips to it
- in Realtime trading it works, hmm, i will try hoch[1]
- in Realtime trading i put this one in a if Statement with some filters, and the system open on every new bar a new stop buy orde
07/10/2016 at 7:24 AM #10370Hello Guy I’m looking for a similar code which is: after 3 bars from market open / set stop at market entry . If you can give me any help thanks James.
-
AuthorPosts
Find exclusive trading pro-tools on