Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © Dark_Trader-x01
- //@version=4
- //########################################################################################################//
- strategy(title="ENVOLVENTE_VIP_strategy_v1", overlay=true, default_qty_type=strategy.cash, default_qty_value=1000, initial_capital=1000, currency=currency.USD)
- //########################################################################################################//
- //########################################################################################################//
- // DECLARACION DE VARIABLES
- bool env_BUY = false
- bool env_SELL = false
- var float sl_long = na
- var float sl_short = na
- var float tp_long = na
- var float tp_short = na
- //########################################################################################################//
- //########################################################################################################//
- // FUNCIONES
- longstop = lowest(low, 2)
- shortstop = highest(high, 2)
- //########################################################################################################//
- //########################################################################################################//
- // VELA ENVOLVENTE VIP ALCISTA
- if (close > open) and (open[1] > close[1]) and (close > open[1]) and (open < close[1])
- env_BUY := true
- // VELA ENVOLVENTE VIP BAJISTA
- if (open > close) and (close[1] > open[1]) and (open > close[1]) and (close < open[1])
- env_SELL := true
- //########################################################################################################//
- //########################################################################################################//
- // STOP-LOSS y TAKE-PROFIT
- /// ALCISTA
- if env_BUY and strategy.position_size == 0
- sl_long := longstop
- tp_long := close
- /// BAJISTA
- if env_SELL and strategy.position_size == 0
- sl_short := shortstop
- tp_short := close
- //########################################################################################################//
- //########################################################################################################//
- // ESTRATEGIA ALCISTA
- strategy.entry(id="LONG", long=true, when=env_BUY)
- strategy.exit(id="LONG_EXIT", from_entry="LONG", stop=sl_long) // STOP-LOSS
- strategy.close(id="LONG", when=(close > tp_long) or (open > tp_long)) // TAKE-PROFIT
- // ESTRATEGIA BAJISTA
- strategy.entry(id="SHORT", long=false, when=env_SELL)
- strategy.exit(id="SHORT_EXIT", from_entry="SHORT", stop=sl_short) // STOP-LOSS
- strategy.close(id="SHORT", when=(close < tp_short) or (open < tp_short)) // TAKE-PROFIT
- //########################################################################################################//
- //########################################################################################################//
- // PLOTS
- plotshape(env_BUY, style=shape.arrowup, text="env_BUY", location=location.abovebar, color=color.green)
- plotshape(env_SELL, style=shape.arrowdown, text="env_SELL", location=location.belowbar, color=color.red)
- //########################################################################################################//
Advertisement
Add Comment
Please, Sign In to add comment