Hi everyone,
I am new to PRT. Can anyone please help me. I would like to execute buy or sell orders based on my target price variable. Unfortunately, I cannot get the below code in PRT 10.3 via IG Index UK to work.
Ideally, I would like to achieve the following:-
- Execute two orders, if the current price is ± of myPrice. So between 10533 and 10553 say.
- Set one order limit to 10 points/pips
- Once the first order hits the 10 point/pip limit, the second order stop loss is set to break even. The idea is to then swing trade the second order. Is this possible to achieve in ProOrder?
- Is it possible to manage two orders placed manually with ProOrder to acieve the above?
Many thanks in advance.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
myPrice = (10543)
myTradeSize = (5)
// Conditions to enter long positions
c1 = (close > myPrice-10 AND close < myPrice+10)
IF c1 THEN
BUY myTradeSize PERPOINT AT MARKET
SET STOP LOSS 20
SET TARGET $PROFIT 100
ENDIF
// Conditions to exit long positions
c2 = (close CROSSES UNDER myPrice-30)
IF c2 THEN
SELL AT MARKET
ENDIF
Hi Nate
At first glance the code looks like it should work to me, but you sure you don’t want
SET STOP pLOSS 20 (20 points)
which is 20 units, but I’ve forgotten what a Unit is??:) (Its late!)
A Unit may be $1 if you are trading in dollars, not sure.
Cheers
GraHal
Does below work? Just an idea. Need sleep now 🙂
c1 = close > myPrice-10
C2 = close < myPrice+10
If C1 and C2 Then
Buy ... etc
Hi Nate,
Bit pushed for time atm but you might get some ideas from this link..
This was programmed using 10.2 and I’m not really up to speed with 10.3 ..( mind you, I wasn’t with 10.2 either LoL !)
https://www.prorealcode.com/blog/learning/breakeven-code-automated-trading-strategy/
Also I was thinking you could split them into two different codes – one to take 10 Point and another to bring Stops to b/e.
Hope this helps a little…
@Big Hug hahaha keep the humour coming … we need it to make the day go round!! 😉
@Nate now I’ve slept, Stop Loss and TP are usually the last 2 lines of code (outside of an IF statement, unless you have different SL & TP for Longs or Shorts) … does that make it work?
IF c1 THEN
BUY myTradeSize PERPOINT AT MARKET
SET STOP LOSS 20
SET TARGET $PROFIT 100
ENDIF