HOLA. QUIERO PROGRAMAR EL STOP LOSS DE UN SISTEMA, QUIERO QUE EL STOP LOSS INICIAL ESTE 1% DEBAJO DEL MINIMO DE LAS ULTIMAS 5 VELAS. Y QUE LUEGO DE QUE EL PRECIO DE LA ACCION SUBA UN 10% POR EJ, EL STOP LOSS SE CORRA AL PRECIO DE ENTRADA, Y DESDE AHI APLICAR TRAILING STOP DE X%. ¿ES POSIBLE O NO? MUCHAS GRACIAS!
NO escriba en mayúscula, excepto palabras simples u oraciones muy cortas para señalar algo.
Se considera que las mayúsculas son gritos cuando se habla, según netiquette.
Tiene poca educación y es más difícil de leer. Gracias 🙂
Hola…Gracias por tu comentario…lo tendre en cuenta….
Hola!! Alguien que me ayude…..
Este es mi código (no probado) para posiciones largas:
If not OnMarket then
NewStop = 0
Endif
If not OnMarket then //do not change while at market
StopLoss = lowest [5](low) * 0.99 //-1%
Endif
MyProfit = TradePrice * 1.1 //+10%
Result = TradePrice * (1 + PositionPerf)
If NewStop > 0 Then
MyProfit = NewStop * 1.05 //5% trailing stop
If close >= MyProfit Then
NewStop= MyProfit
Endif
Endif
If NewStop = 0 and OnMarket and Result >= MyProfit Then
NewStop = TradePrice
Endif
If MyConditions and Not OnMarket then
Buy 1 contract at Market
Sell at StopLoss STOP
Endif
If OnMarket then
Sell at max(StopLoss,NewStop) STOP
Endif
I edit my code above to correct a couple of errors.
This is a complete MTF version for both Long and Short trades:
DEFPARAM CumulateOrders = false
//
timeframe(1 day,updateonclose)
CondL = close > average[200] AND average[10] CROSSES OVER average[20]
CondS = close < average[200] AND average[10] CROSSES UNDER average[20]
//
timeframe(default)
If not OnMarket then
NewStop = 0
Endif
If not OnMarket then //do not change while at market
StopLossL = lowest [5](low) * 0.99 //-1%
StopLossS = highest [5](low) * 1.01 //+1%
Endif
IF LongOnMarket THEN
MyProfit = TradePrice * 1.10 //+10%
Result = TradePrice * (1 + PositionPerf)
ELSIF ShortOnMarket THEN
MyProfit = TradePrice * 0.90 //-10%
Result = TradePrice * (1 - PositionPerf)
ENDIF
If NewStop <> 0 Then
IF LongOnMarket THEN
MyProfit = NewStop * 1.02 //2% trailing stop
If close >= MyProfit Then
NewStop= MyProfit
Endif
ELSIF ShortOnMarket THEN
MyProfit = NewStop * 0.98 //2% trailing stop
If close <= MyProfit Then
NewStop= MyProfit
Endif
ENDIF
Endif
If NewStop = 0 THEN
IF LongOnMarket and Result >= MyProfit Then
NewStop = TradePrice
ELSIF ShortOnMarket and Result <= MyProfit Then
NewStop = TradePrice
ENDIF
Endif
If CondL and Not OnMarket then
Buy 1 contract at Market
Sell at StopLossL STOP
Endif
If CondS and Not OnMarket then
SellShort 1 contract at Market
ExitShort at StopLossS STOP
Endif
If OnMarket then
Sell at max(StopLossL,NewStop) STOP
ExitShort at min(StopLossS,NewStop) STOP
Endif
SET TARGET pPROFIT 50