
이 전략의 주요 아이디어는 가격의 하락을 모니터링하여 구매 작업을 수행하는 것입니다. 가격이 이전 주기에 비해 5% 이상 떨어지면 구매 신호를 유발하여 현재 종료 가격으로 일정 수의 포지션을 구입합니다. 가격이 구매 가격보다 높을 때 평점으로 이익을 얻습니다. 이 전략은 시장의 변동성을 활용하여 가격의 단기 부진 기회를 잡으려고합니다.
이 전략은 가격의 단기 하락이 특정 범위를 초과하는 것을 구매 신호로 사용하여 가격의 반발 기회를 포착하여 수익을 얻습니다. 논리는 간단하고 이해하기 쉽습니다. 전략의 장점은 추세를 포착하고 위험을 통제하는 데 있습니다. 그러나 자주 거래, 깊이 회수, 가격 변동과 같은 위험도 주의해야합니다.
/*backtest
start: 2023-06-01 00:00:00
end: 2024-06-06 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Thgoodtrader
//@version=5
strategy("TGT Falling Buy", overlay=true, margin_long=100, margin_short=100)
var float buy_price = na
var float open_price = na
var float open_weekend = na
var float close_weekend = na
var bool trade=false
var float balance = 1000
// Definir el precio de compra inicial y la cantidad inicial
var float qty = na
// Verificar si el día de la semana es sábado (6) o domingo (0)
es_sabado = dayofweek == 1
es_domingo = dayofweek == 7
es_viernes = dayofweek == 6
// Calcular el valor del saldo inicial
balance_initial = balance
change_percent = ((close - close[1]) / close[1]) * 100
is_last_candle_negative = close < open
is_change_above_threshold = change_percent < -5
// Cambiar el color de la última vela si cumple las condiciones
barcolor(is_last_candle_negative and is_change_above_threshold ? color.yellow : na)
bgcolor(is_last_candle_negative and is_change_above_threshold ? color.yellow : na, transp=80)
// Guardar el precio de compra cuando se cumpla la condición del 5%
if is_change_above_threshold
// Calcular la cantidad basada en el precio de compra y el saldo
qty := balance / close
// Guardar el precio de compra
buy_price := close
open_price := open
strategy.entry("Buy Trading",strategy.long,qty)
alert("Comprar BTC", alert.freq_once_per_bar_close)
trade :=true
//if (((close - strategy.position_avg_price) / strategy.position_avg_price) * 100 ) > 2
if close > strategy.position_avg_price
// Calcular el valor de ganancia o pérdida
pnl = (close - strategy.position_avg_price) * qty
// Actualizar el saldo
balance := balance_initial + pnl
strategy.close("Buy Trading")
alertcondition(is_change_above_threshold, title = "Buy 5% Discount", message = "Buy Position")
alertcondition(close > strategy.position_avg_price, title = "Close Trade", message = "Close Buy Position")