I have a position, i want you to another position when the same conditions are met, but only if the first position has breakeven.
Only if the first one closed at breakeven (no profit at all)?
Fran55, could you please elaborate bit more?
Are you saying something like:
- Open first position
- When it has reached a profit of x points, move stoploss of first position to breakeven and open second position with similar conditions as position 1.
If this indeed is the case, there is a very nice grid strategy here which can be customised to your needs: https://www.prorealcode.com/topic/grid-orders-with-one-combined-stop-loss-and-limit-can-it-be-done/
If something else, please explain.
The page no found kaq52.
Please…Open other position with conditions, if the first position is on market and breakeven.
defparam CUMULATEORDERS = TRUE
Once OpenPositions=0
Ordersize = 1 //amend to reflect how many postions you want each time
// Conditions to enter long positions
IF Not LongOnmarket and YourConditions THEN //specify your buy conditions
BUY Ordersize CONTRACTS AT MARKET
SL = YourStopLoss //specify your original stop loss
OpenPositions = Ordersize
ENDIF
// Conditions to exit long positions
If (OpenPositions=OrderSize) AND YourConditions THEN //Opening Second position and updating stoploss
Once SL = positionPrice //this moves your stoploss to position-1 buyprice
//remove keyword "Once" if yuo want both positions to be at breakeven. That is, stoploss will be between buying prices of position1 and Position2,
BUY Ordersize CONTRACTS AT MARKET
ENDIF
<Specify Conditions to exit long positions>
set stop ploss SL
Similarly amend for short conditions.
I know there is an issue on copied links to work, so you couldn’t access above. Hopefully someone can advise how to access above link.
The outcome of the last closed position is returned by PositionPerf(1), so you just need to check it was 0:
If MyConditions and Not OnMarket and PositionPerf(1) = 0 then
.
. Buy/Sellshort.......
.
Endif
No valid… Thanks!
See…
The second position only open if the first position is on market and gain 0.6% or + and conditions.
This to accumulate a position after a 0.6% increase:
If MyConditions AND ((PositionPerf * 100) >= 0.6) then
.
. Buy/Sellshort.......
.
Endif
Ok.
And open new position after 0.6% increase at close bar 5 minutes?
Please.
Yes, if you use a 5-minute TF it will add a position when that bar closes.
And two or three máximum accumulated positions???
Please!
There you go:
If MyConditions AND (abs(Countofposition) < 3) Then
.
. Buy/Sellshort.......
.
Endif
Hello, I tried the following code without success, the second position does not execute:
If Not Longonmarket and CtimeAchat1 AND CaMom1bis AND CaMom2bis AND CaLoc4bis AND CaLoc5bis AND CaFig6bis AND CaFig7bis and CaWillA2 THEN
BUY n SHARES AT MARKET
set target %profit takeprofitbis
set stop loss Stoplossbis ptrailing 46
ENDIF
If longonmarket and ((positionperf*100)>=x1) AND (abs(Countofposition)<3) AND CtimeAchat1 AND CaMom1 AND CaMom2 AND CaLoc4 AND CaLoc5 AND CaFig6 and CaWillA1 THEN
Buy n shares at market
set target %profit takeprofit
set stop loss Stoploss ptrailing 50
endif
Bearing, independently, the positions run normally.
Could you help me ?
@Jigsaw20000
Try to abide by the basic rules, as highlighted in yellow below:
- Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
- Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
Thank you 🙂
Try GRAPHing as many variables as possible to spot any issue:
Graph N
Graph ((positionperf*100)>=x1)
Graph (abs(Countofposition)<3)
Graph .....