Untitled
//########################### İşlem Yönetimi ########################### ep = strategy.opentrades.entry_price(strategy.opentrades - 1) if (tradeDirection == "Long" or tradeDirection == "Both") if (Buy_Condition and Timerange()) chg_long := amount strategy.close("Short Entry", "Short Exit", qty=chg_short) strategy.entry("Long Entry", strategy.long, qty=chg_long) if (strategy.position_size > 0) if (numberOfAmount > 0) tp1 := ep * (1 + takeProfitPercent1 / 100) tp2 := ep * (1 + takeProfitPercent2 / 100) tp3 := ep * (1 + takeProfitPercent3 / 100) tp4 := ep * (1 + takeProfitPercent4 / 100) tp5 := ep * (1 + takeProfitPercent5 / 100) // Adımları sırayla kontrol etmek için değişken currentStep = 0 // Step 1 if (numberOfSteps >= 1 and currentStep == 0) strategy.exit("TP 1", from_entry="Long Entry", qty_percent=takeProfitAmount1, limit=tp1) currentStep := 1 // Step 2 if (numberOfSteps >= 2 and currentStep == 1) strategy.exit("TP 2", from_entry="Long Entry", qty_percent=takeProfitAmount2, limit=tp2) currentStep := 2 // Step 3 if (numberOfSteps >= 3 and currentStep == 2) strategy.exit("TP 3", from_entry="Long Entry", qty_percent=takeProfitAmount3, limit=tp3) currentStep := 3 // Step 4 if (numberOfSteps >= 4 and currentStep == 3) strategy.exit("TP 4", from_entry="Long Entry", qty_percent=takeProfitAmount4, limit=tp4) currentStep := 4 // Step 5 (Son kademede pozisyonun tamamını kapat) if (numberOfSteps == 5 and currentStep == 4) strategy.exit("TP 5", from_entry="Long Entry", qty_percent=100, limit=tp5) currentStep := 5 if (Sell_Condition and Timerange()) strategy.close("Long Entry", "Long Exit") if (tradeDirection == "Short" or tradeDirection == "Both") if (Sell_Condition and Timerange()) chg_short := amount strategy.close("Long Entry", "Long Exit", qty=chg_long) strategy.entry("Short Entry", strategy.short, qty=chg_short) if (strategy.position_size < 0) if (numberOfAmount > 0) tp1 := ep * (1 - takeProfitPercent1 / 100) tp2 := ep * (1 - takeProfitPercent2 / 100) tp3 := ep * (1 - takeProfitPercent3 / 100) tp4 := ep * (1 - takeProfitPercent4 / 100) tp5 := ep * (1 - takeProfitPercent5 / 100) // Adımları sırayla kontrol etmek için değişken currentStep = 0 // Step 1 if (numberOfSteps >= 1 and currentStep == 0) strategy.exit("TP 1", from_entry="Short Entry", qty_percent=takeProfitAmount1, limit=tp1) currentStep := 1 // Step 2 if (numberOfSteps >= 2 and currentStep == 1) strategy.exit("TP 2", from_entry="Short Entry", qty_percent=takeProfitAmount2, limit=tp2) currentStep := 2 // Step 3 if (numberOfSteps >= 3 and currentStep == 2) strategy.exit("TP 3", from_entry="Short Entry", qty_percent=takeProfitAmount3, limit=tp3) currentStep := 3 // Step 4 if (numberOfSteps >= 4 and currentStep == 3) strategy.exit("TP 4", from_entry="Short Entry", qty_percent=takeProfitAmount4, limit=tp4) currentStep := 4 // Step 5 (Son kademede pozisyonun tamamını kapat) if (numberOfSteps == 5 and currentStep == 4) strategy.exit("TP 5", from_entry="Short Entry", qty_percent=100, limit=tp5) currentStep := 5 if (Buy_Condition and Timerange()) strategy.close("Short Entry", "Short Exit")
Leave a Comment