Documentation / ProBacktest

Set a stop loss of x €,$ (in the currency of the instrument).

Syntax:

SET STOP $LOSS x

 

Example :

myMACD = MACD[12,26,9](close)
long = myMACD crosses over 0

IF NOT LongOnMarket AND long THEN
  BUY 1 CONTRACTS AT MARKET
ENDIF

//set stop loss at 200$ loss
SET STOP $LOSS 200

 

Set a target profit of x €,$ (in the currency of the instrument).

Syntax:

SET TARGET $PROFIT x


Example :

myMACD = MACD[12,26,9](close)
long = myMACD crosses over 0

IF NOT LongOnMarket AND long THEN
  BUY 1 CONTRACTS AT MARKET
ENDIF

//set profit target at 100$ 
SET TARGET $PROFIT 100

 

Set a trailing stop of x €,$ (in the currency of the instrument).

Syntax:

SET STOP $TRAILING x

 

Example:

We are setting here a trailing stop at 100$ from the current average price

//indis
i1 = average(close)[100]
i2 = average(close)[5]

tradeinitiate = Close>i1 AND Close<i2 AND Low[3]>Low[2] AND Low[2]>Low[1] AND Low[1]>Low

IF NOT LongOnMarket AND tradeinitiate THEN
   BUY 1 CONTRACTS AT MARKET
ENDIF

//set stop loss trailing at 100$ from the current average price
SET STOP $TRAILING 100

 

Set a stop loss x% from the average position price.

Note: the % loss is calculated and placed individually for each order with IG or PRT-CFD.

Syntax:

SET STOP %LOSS x

 

Example :

myMACD = MACD[12,26,9](close)
long = myMACD crosses over 0

IF NOT LongOnMarket AND long THEN
  BUY 1 CONTRACTS AT MARKET
ENDIF

//set stop loss at 2% from the average position price
SET STOP %LOSS 2

 

Set a target profit x% from the average position price.

Note: the % profit is calculated and placed individually for each order with IG or PRT-CFD.

Syntax:

SET TARGET %PROFIT x

 

Example :

myMACD = MACD[12,26,9](close)
long = myMACD crosses over 0

IF NOT LongOnMarket AND long THEN
  BUY 1 CONTRACTS AT MARKET
ENDIF

//set a target profit at 2% from the average position price
SET TARGET %PROFIT 2

 

Set a trailing stop x percent from average position price.

Syntax:

SET STOP %TRAILING x

Continue reading “%TRAILING” »

Instruction to open a long position.

Syntax:

BUY x SHARES

 

Example :

IF NOT LongOnMarket AND LongConditions THEN
   BUY 1 SHARES AT MARKET
ENDIF

 

Amount of cash used in the position.

Syntax:

BUY x CASH

 

Designates the number of contracts to buy. Equivalent to ‘SHARES’.

Syntax:

CONTRACT

 

Counts the number of open long shares or lots.

Syntax:

COUNTOFLONGSHARES

 

Example :

myMACD = MACD[12,26,9](close)
long = myMACD crosses over 0

//first order
IF NOT LongOnMarket AND long THEN
  BUY 1 CONTRACTS AT MARKET
ENDIF

MAXSHARES = COUNTOFLONGSHARES <= 3

//let's add another order while price continue to get higher (more than 10 points) than the last order taken with a condition of 5 bars elapsed since then
IF TRADEINDEX(1)>5 AND Close-TRADEPRICE(1)>10 AND LongOnMarket AND MAXSHARES THEN
  BUY 1 CONTRACTS AT MARKET
ENDIF

SET STOP TRAILING 50

 


Top