
এই কৌশলটি পিন স্ক্রিপ্টের পুনর্বিবেচনার সময় লিভারেজ সেট করতে অক্ষমতার সমস্যা সমাধানের জন্য তৈরি করা হয়েছে। কৌশলটি কৌশলটির ক্রেডিট, সেট করা লিভারেজ গুণক এবং সমাপ্তির দাম, গতিশীলভাবে খোলা পজিশনের সংখ্যা গণনা করে।
Lev = math.max(math.round(strategy.equity * leverage / close), 0)এবং এটাকে সুদ এবং লিভারেজের সাথে সমানুপাতিক করে তুলুন।এই কৌশলটি পাইন স্ক্রিপ্টে লিভারেজ সেটিং বাস্তবায়ন করে, প্রতিক্রিয়াশীলতা লিভারেজ অনুকরণ করতে পারে না সমস্যাটি সমাধান করে, খোলার পজিশনার সংখ্যা এবং অধিকার ও স্বার্থের সাথে সংযুক্ত করে গণনা করে, লিভারেজ রিটার্ন সম্পন্ন করে। কৌশলটি সহজ এবং কার্যকর, আরও অনুকূলিতকরণযোগ্য এবং শেখার যোগ্য।
/*backtest
start: 2022-12-22 00:00:00
end: 2023-12-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RingsCherrY
//@version=5
strategy("How to use Leverage in PineScript", overlay=true, pyramiding=1, initial_capital=1000000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_order_fills=false, slippage=0, commission_type=strategy.commission.percent, commission_value=0.04)
//////////////////////////////////////////
////////////////Indicators////////////////
//////////////////////////////////////////
length = input( 14 )
overSold = input( 30 )
overBought = input( 70 )
price = close
vrsi = ta.rsi(price, length)
co = ta.crossover(vrsi, overSold)
cu = ta.crossunder(vrsi, overBought)
//////////////////////////////////////////
/////////////////Leverage/////////////////
//////////////////////////////////////////
//The number of decimal places for each position opening, i.e., the accuracy
precision = input.int(1,title='Precision')
//Leverage, the default is 1, here is not recommended to open a high leverage
leverage = input.int(1,title='Leverage',minval = 1, maxval = 100 ,step = 1)
//Calculate the number of open contracts, here using equity for calculation, considering that everyone compound interest is used for trading equity
Lev = math.max(math.round(strategy.equity * leverage / close , precision), 0)
if (not na(vrsi))
if (co)
strategy.entry("RsiLE", strategy.long,qty = Lev, comment="RsiLE")
if (cu)
strategy.entry("RsiSE", strategy.short,qty = Lev, comment="RsiSE")
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)