Hi all,
I would to create the following set up in Pro Real Time to then trade using IG Index.
Two trades, both entered on the same index at the same given price with defined stop loss.
One of these trades to close once a fixed number of points has been met (e.g. 20 points).
As soon as the first trade closes, move the other to break even
Second trade to close at a predefined level.
Example:
Short Dax @ 14,000
2x £5 per point
Position 1 – close when 20 points in profit
Position 2 – move to break even when Position 1 closes, with a predefined target of 13,950
Stop loss on both at opening of 50 points
The following should be able to be inputted each time:
– Opening Price
– Initial take profit for Position 1
– Take profit target for Position 2
– Stop loss
– Stake
– Valid til
Would be enormously grateful if someone could help me with this
Many thanks in advance,
Karl
<table border=”0″ width=”100%” cellspacing=”0″ cellpadding=”0″ bgcolor=”#fff”>
<tbody>
<tr>
<td><center>
<table width=”550″ cellspacing=”0″ cellpadding=”0″ align=”center” bgcolor=”#ffffff”>
<tbody>
<tr>
<td align=”left”></td>
</tr>
</tbody>
</table>
</center></td>
</tr>
</tbody>
</table>
JSParticipant
Senior
Hi
@kr2009
Is your idea to go Long and Short at the same time?
If that is your idea, this is not possible in ProOrder.
Hi there,
No, both positions are entered in the same direction.
i.e 2x short, or 2x long
Thanks
There you go:
DEFPARAM CumulateOrders = False
//
OpeningPrice = 14060
TP1 = 20
TP2 = 50
SL = 20
ValidTill = 210000 //set to 240000 to never stop it until either SL or TP is hit
Stake = 2
Distance = 6
EnterType = 2 //1=Long, 2=Short
//
OpenLots = abs(CountOfPosition)
IF OpenLots < OpenLots[1] THEN
a = 2
ENDIF
IF Not OnMarket THEN
ExitPrice = 0
Stake = max(2,Stake)
ExitStake = floor(Stake / 2,1)
//LONG trade
IF EnterType = 1 THEN
IF close > (OpeningPrice + Distance) THEN
BUY Stake CONTRACTS AT OpeningPrice LIMIT
ELSIF close < (OpeningPrice - Distance) THEN
BUY Stake CONTRACTS AT OpeningPrice STOP
ELSE
BUY Stake CONTRACTS AT Market //comment out (or delete) this line not to enter at
// market when distance is too close to the current price
ENDIF
ENDIF
//SHORT trade
IF EnterType = 2 THEN
IF close > (OpeningPrice + Distance) THEN
SELLSHORT Stake CONTRACTS AT OpeningPrice STOP
ELSIF close < (OpeningPrice - Distance) THEN
SELLSHORT Stake CONTRACTS AT OpeningPrice LIMIT
ELSE
SELLSHORT Stake CONTRACTS AT Market //comment out (or delete) this line not to enter at
// market when distance is too close to the current price
ENDIF
ENDIF
//
SET STOP pLOSS SL
SET TARGET pPROFIT TP2
ENDIF
//
IF OnMarket AND Not OnMarket[1] THEN
ExitPrice = TradePrice + (TP1 * PipSize)
ENDIF
//
IF OnMarket THEN
MyProfit = PositionPerf * PositionPrice / PipSize
IF MyProfit >= TP1 AND (abs(CountOfPosition) = Stake) THEN
IF LongOnMarket THEN
SELL ExitStake CONTRACTS AT MARKET
ELSE
EXITSHORT ExitStake CONTRACTS AT MARKET
ENDIF
ExitPrice = TradePrice
ENDIF
//
IF Time >= ValidTill THEN
SELL AT MARKET
EXITSHORT AT MARKET
ELSIF (abs(CountOfPosition) < Stake) AND MyProfit > 0 THEN
IF LongOnMarket THEN
SELL AT ExitPrice STOP
ELSE
EXITSHORT AT ExitPrice STOP
ENDIF
ENDIF
ENDIF
graphonprice ExitPrice
That’s great, thank you so much!
I’ll give it a go and let you know how I get on
Thanks again, really appreciate it
Hi Roberto,
Thanks again for your help.
How would I add to the code above, to say ‘when position is 10 number of points in favour, move S/L to -15 points’?
Karl
There you go:
DEFPARAM CumulateOrders = False
//
OpeningPrice = 14060
TP1 = 20
TP2 = 50
SL = 20
ValidTill = 210000 //set to 240000 to never stop it until either SL or TP is hit
Stake = 2
Distance = 6
EnterType = 2 //1=Long, 2=Short
//
IF Not OnMarket THEN
tempSL = SL
ENDIF
//
OpenLots = abs(CountOfPosition)
IF OpenLots < OpenLots[1] THEN
a = 2
ENDIF
IF Not OnMarket THEN
ExitPrice = 0
Stake = max(2,Stake)
ExitStake = floor(Stake / 2,1)
//LONG trade
IF EnterType = 1 THEN
IF close > (OpeningPrice + Distance) THEN
BUY Stake CONTRACTS AT OpeningPrice LIMIT
ELSIF close < (OpeningPrice - Distance) THEN
BUY Stake CONTRACTS AT OpeningPrice STOP
ELSE
BUY Stake CONTRACTS AT Market //comment out (or delete) this line not to enter at
// market when distance is too close to the current price
ENDIF
ENDIF
//SHORT trade
IF EnterType = 2 THEN
IF close > (OpeningPrice + Distance) THEN
SELLSHORT Stake CONTRACTS AT OpeningPrice STOP
ELSIF close < (OpeningPrice - Distance) THEN
SELLSHORT Stake CONTRACTS AT OpeningPrice LIMIT
ELSE
SELLSHORT Stake CONTRACTS AT Market //comment out (or delete) this line not to enter at
// market when distance is too close to the current price
ENDIF
ENDIF
//
SET STOP pLOSS tempSL
SET TARGET pPROFIT TP2
ENDIF
//
IF OnMarket AND tempSL = SL THEN
MyProfit = PositionPrice * PositionPerf / PipSize
IF MyProfit >= 10 THEN
tempSL = min(15,SL)
SET STOP pLOSS tempSL
ENDIF
ENDIF
//
IF OnMarket AND Not OnMarket[1] THEN
ExitPrice = TradePrice + (TP1 * PipSize)
ENDIF
//
IF OnMarket THEN
MyProfit = PositionPerf * PositionPrice / PipSize
IF MyProfit >= TP1 AND (abs(CountOfPosition) = Stake) THEN
IF LongOnMarket THEN
SELL ExitStake CONTRACTS AT MARKET
ELSE
EXITSHORT ExitStake CONTRACTS AT MARKET
ENDIF
ExitPrice = TradePrice
ENDIF
//
IF Time >= ValidTill THEN
SELL AT MARKET
EXITSHORT AT MARKET
ELSIF (abs(CountOfPosition) < Stake) AND MyProfit > 0 THEN
IF LongOnMarket THEN
SELL AT ExitPrice STOP
ELSE
EXITSHORT AT ExitPrice STOP
ENDIF
ENDIF
ENDIF
graphonprice ExitPrice