Reply To: Backtest – Exit Criteria – Setup bar and Trigger price

Optuma Forums Optuma Scripting Backtest – Exit Criteria – Setup bar and Trigger price Reply To: Backtest – Exit Criteria – Setup bar and Trigger price

#51955
Trevor R
  • Topics: 107
  • Replies: 316
  • Posts: 423

Hi Joao,

I’m not 100% sure I got your extra criteria straight, so here are two options:

Option 1 (Script: //Ticket #51943 20190324) which requires the Entry Bar to meet:

  • Close of Entry bar and the Close preceding bar to be below to 50 EMA
  • Low of the Entry Bar to be below the Low of the preceding two Bars, regardless of the relationship of the Lows of those two preceding Bars

This script meets those criteria:

// Ticket #51943 20190324

EMA50 = MA(BARS=50, STYLE=Exponential, CALC=Close);

Sig1 = If(CLOSE(1) > EMA50 AND CLOSE(0) < EMA50, 1, 0);

Sig2 = If( LOW(0) < LOW(1) and LOW(0) < Low (2), 1, 0);

Entry = If(Sig1 and Sig2, 1, 0);

Entry

The SHOWBAR result from this script is shown in Red on the chart below.

Option 2 (Script: //Ticket #51943 20190324-A) which requires the Entry Bar to meet:

  • Close of Entry bar and the Close preceding bar to be below to 50 EMA
  • Low of the Entry Bar to be below the Low of the preceding Bar and the Low of the preceding Bar to be below the Low of the Bar preceding it

This script meets those criteria:

// Ticket #51943 20190324-A

EMA50 = MA(BARS=50, STYLE=Exponential, CALC=Close);

Sig1 = If(CLOSE(1) > EMA50 AND CLOSE(0) < EMA50, 1, 0);

Sig2 = If( LOW(0) < LOW(1) and LOW(1) < Low (2), 1, 0);

Entry = If(Sig1 and Sig2, 1, 0);

Entry

The SHOWBAR result from this script is shown in Blue on the chart below.

20190324 Joao's Script 3

Cheers

Trevor

The Auld Tyma at

Auld Tyma Data Logo with URL 1 cm

Pin It on Pinterest