Hola a todos. Me gustaría saber como poder aplicar un TARGET %PROFIT a una estrategia en un sistema dentro de ProOrder, ya que te deja aplicar la orden ” SET TARGET %PROFIT ” en Backtesting pero a la hora de pasarlo a ProOrder te dice un mensaje que no es posible, únicamente “PPROFIT” o “$PROFIT”. Y me gustaría saber si hubiera alguna manera de aplicarlo mediante otras instrucciones o lineas de código. Gracias
Ejecuté este código en el autotrading (ProOrder) y no se me informó ningún error:
if close crosses over average[200,0](close) and not Onmarket then
buy at market
endif
set target %profit 2
set stop %loss 1
Disculpa Roberto….con tantas pruebas me confundí….se trata de “SET STOP %TRAILING”. Y por eso me gustaría saber si hubiera alguna manera de aplicarlo mediante otras instrucciones o lineas de código. Gracias
Este es el mismo ejemplo, al que agregué el trailing stop de Nicolás, que modifiqué para poder usar porcentajes en lugar de pips:
if close crosses over average[200,0](close) and not Onmarket then
buy at market
endif
//*********************************************************************************
// Trailing Stop by Nicolas
// https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
// (lines 17- 56)
// modified to use Percentages
//
//trailing stop function
//
StartPerCent = 0.5 //Trailing Stop will activate after 0.5% gain
StepPerCent = 0.1 //Trailing Steps will occur at any further 0.1% gain
//
trailingstart = PositionPrice * StartPerCent / 100 / PipSize
trailingstep = PositionPrice * StepPerCent / 100 / PipSize
//
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-PositionPrice>=trailingstart*pipsize THEN
newSL = PositionPrice+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = max(newSL,newSL+trailingstep*pipsize)
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND PositionPrice-close>=trailingstart*pipsize THEN
newSL = PositionPrice-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = min(newSL,newSL-trailingstep*pipsize)
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//*********************************************************************************
//graphonprice PositionPrice coloured(0,0,255,255)
//graphonprice newSL coloured(255,0,0,255)
//graph TrailingStart
//graph TrailingStep
Si elimina las barras de comentarios de las últimas 4 líneas, podrá ver los valores de las variables, tanto en el precio como en un pip (después de convertir sus porcentajes).
thanked this post
Muchas gracias Roberto. Lo pongo en marcha en ProOrder Demo y a ver qué tal. Muchas gracias por la ayuda. Un saludo