Hi, from this topic I have designed a system which “buy” when price crosses over the latest minimum and close it when price crosses over the highest maximum. System works short changing the steps told before.
But, the question is that, I cannot accomplish that the price buys in the latest minimum price and short in the highest maximum:
Can anyone give me a hand?
Hola, a partir de este tema, diseñé un sistema que compra cuando el precio supera el mínimo más reciente y cierra cuando supera el máximo más alto. El sistema funciona en corto siguiendo los pasos descritos anteriormente.
Pero la pregunta es que no puedo lograr que el precio compre en el mínimo más reciente y venda en corto en el máximo más alto.
¿Alguien puede ayudarme?
///// 3 minimun/maximum
defparam cumulateorders = false // No permite ordenes acumuladas
defparam preloadbars = 1000 // Precarga del histórico de velas
prd= 30
ph1 = high < high[prd]
ph2 = highest[prd](high) < high[prd]
ph3 = high[prd] > highest[prd](high)[prd+1]
////////pivotlow
pl1 = low > low[prd]
pl2 = lowest[prd](low) > low[prd]
pl3 = low[prd] < lowest[prd](low)[prd+1]
// Condiciones para entrada de posiciones LARGAS
IF NOT LONGONMARKET AND close crosses OVER lowest[prd](low)[prd+1] THEN
BUY 1 CONTRACTS AT MARKET nextbaropen
ENDIF
// Condiciones de salida de posiciones largas
If LONGONMARKET AND close > highest[prd](high)[prd+1] THEN
SELL AT MARKET
ENDIF
// Condiciones para entrada de posiciones SHORT
IF NOT shortOnMarket AND close crosses under highest[prd](high[1])[prd+1] THEN
sellSHORT 1 CONTRACTS AT MARKET nextbaropen
ENDIF
// Condiciones de salida de posiciones LONG
If SHORTONMARKET AND close < lowest[prd](low)[prd+1] THEN
exitshort AT MARKET
ENDIF