This strategy uses price action and pyramiding methods to open a position when the price drops by 5%, and then continues to add positions through pyramiding until the price rises by 5% to close the position. The main advantage of this strategy is that it enters the market early in the trend formation and increases profit opportunities through pyramiding. At the same time, the strategy also sets a 3% stop loss to control risk.
This strategy uses price action and pyramiding methods to enter the market early in the trend formation and increases profit opportunities through multiple position adding. At the same time, the strategy also sets a stop loss to control risk. Although the strategy may face some risks, through further optimization, such as adjusting the proportion of position adding and closing, introducing more technical indicators, etc., the stability and profitability of the strategy can be improved.
/*backtest start: 2023-04-24 00:00:00 end: 2024-04-29 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("G Strategija su piramidavimu", overlay=true) // Vartotojo įvestis investicijų sumai investment_amount = input(1000.0, title="Investicijų suma") // Nustatyti nuostolių ir pelno pasiekimo procentus lossPercentage = input(3, title="Nuostolio procentas (%)") / 100 // Kintamasis saugoti atidarytoms pozicijoms var int[] entryIndexes = array.new_int(0) var float[] entryPrices = array.new_float(0) // Kintamasis, nustatantis, ar turėtume atidaryti naują poziciją var bool should_buy = false var int open_candle_count = 0 var int positionCounter = 1 // Pozicijos skaitiklis // Įėjimo logika (pirkti, kai kaina krenta) if (hour >= 0 and hour <= 23) // Tikrina, ar yra 24 valandų should_buy := false for i = 1 to 5 should_buy := should_buy or (close < close[i] * (1 - lossPercentage)) if (should_buy and open_candle_count >= 5) strategy.entry("Pirkti_" + str.tostring(positionCounter), strategy.long, qty=investment_amount / close) array.push(entryIndexes, bar_index) // Įrašyti atidarymo laiko indeksą array.push(entryPrices, close) // Įrašyti atidarymo kainą open_candle_count := 0 positionCounter := positionCounter + 1 // Atnaujinti pozicijos skaitiklį else open_candle_count := open_candle_count + 1 // Išėjimo logika (uždaryti, kai pasiekiamas pelno lygis) for i = 0 to array.size(entryIndexes) - 1 var float takeProfitPrice = na // Nustatyti pradinę reikšmę "na" if array.size(entryPrices) > i and array.size(entryPrices) > 0 takeProfitPrice := array.get(entryPrices, i) * 1.05 // Skaičiuojamas pelno pasiekimo lygis: 5% aukščiau atidarymo kainos strategy.exit("TakeProfit_" + str.tostring(i+1), "Pirkti_" + str.tostring(i+1), limit=takeProfitPrice) // Pridėti pelno pasiekimo lygį kaip išėjimo lygį