ট্র্যাকিং ক্রয় কৌশল

লেখক:চাওঝাং, তারিখ: ২০২৩-০৯-০৯ 14:53:02
ট্যাগঃ

সারসংক্ষেপ

ট্রেলিং কিনে নেওয়ার কৌশল হল একটি প্রবণতা অনুসরণকারী কৌশল। যখন দ্রুত চলমান গড়টি ধীর চলমান গড়ের উপরে অতিক্রম করে, এটি একটি খোলা অবস্থান সংকেত ট্রিগার করে। সরাসরি খোলার অবস্থানের বিপরীতে, এই কৌশলটি খোলা অবস্থানের সংকেত ট্রিগার হওয়ার পরে অবিলম্বে বাজারে প্রবেশ করবে না, তবে দাম নির্দিষ্ট শর্তে পৌঁছলে কেবল ক্রয় অর্ডার কার্যকর করবে। এটি কৌশলটির লাভকে কিছুটা বাড়িয়ে তুলতে পারে।

নীতিমালা

এই কৌশলটি দুটি চলমান গড়ের সাথে একটি চলমান গড় ক্রসওভার সিস্টেমের উপর ভিত্তি করে। দ্রুত চলমান গড় এবং ধীর চলমান গড় যথাক্রমে গণনা করা হয়। যখন দ্রুত চলমান গড় ধীর চলমান গড়ের উপরে অতিক্রম করে, তখন একটি দীর্ঘ সংকেত উত্পন্ন হয়।

ট্রেলিং কেনার অপশনটি সক্ষম হলে এক্সিকিউশন লজিক আলাদা হবেঃ

  1. যখন লং সিগন্যাল ট্রিগার হয়, তখন সরাসরি কেনার পরিবর্তে, সেই সময়ে সর্বনিম্ন মূল্য রেকর্ড করুন।

  2. তারপর ক্রয় মূল্যের থ্রেশহোল্ডটি সর্বনিম্ন ক্রয় শতাংশ, অর্থাৎ সর্বনিম্ন মূল্য * (1 + শতাংশ) অনুযায়ী গণনা করুন।

  3. পরবর্তী বারগুলিতে, বর্তমান বারটির সর্বনিম্ন মূল্যের সাথে ক্রয়ের মূল্যের প্রান্তিকের তুলনা চালিয়ে যান।

  4. যখন সর্বনিম্ন মূল্য ক্রয় মূল্যের সীমা অতিক্রম করে, তখন ক্রয় অর্ডার কার্যকর করা হয়।

  5. এইভাবে, প্রবণতা নিশ্চিত হওয়ার পর আমরা বাজারে আরও ভাল মূল্যে প্রবেশ করতে পারি।

সুবিধা বিশ্লেষণ

এই কৌশলটির সুবিধাগুলো হল:

  1. ট্রেলিং কেনার মাধ্যমে ট্রেন্ডটি আরও স্পষ্ট হওয়ার পরে বাজারে প্রবেশ করে মিথ্যা ব্রেকআউটের ঝুঁকি এড়ানো যায়।

  2. ট্রেলিং কেনার মাধ্যমে, আরও ভাল দাম অর্জন করা যায়, কিছু পরিমাণে মুনাফা বৃদ্ধি পায়।

  3. এই কৌশলটি সহজ এবং বাস্তবায়ন করা সহজ।

  4. ট্রেলিং ক্রয় স্টেপিং শতাংশ কাস্টমাইজযোগ্য, কৌশল আরো নমনীয় করে তোলে।

  5. বিভিন্ন বাজারের পরিবেশের সাথে মানিয়ে নিতে চলমান গড় সময়ের কাস্টমাইজ করা যেতে পারে।

ঝুঁকি বিশ্লেষণ

এই কৌশলের কিছু ঝুঁকিও রয়েছেঃ

  1. ক্রেতাদের পিছনে থাকা কিছু সময় নষ্ট করতে পারে এবং প্রবেশের সুযোগ হারাতে পারে।

  2. অবশিষ্ট ক্রয়ের প্রান্তিককরণের অনুপাতের ভুল নির্ধারণের ফলে ক্রয় করা অসম্ভব হতে পারে।

  3. ভুল চলমান গড় সময়কাল আরও মিথ্যা সংকেত তৈরি করতে পারে।

  4. এই কৌশলটি বিভিন্ন বাজারে মারাত্মক ক্ষতির সম্মুখীন হতে পারে।

  5. এটি প্যারামিটার অপ্টিমাইজেশনের জন্য একটি সহজ কৌশল।

সংশ্লিষ্ট ব্যবস্থাঃ

  1. বিলম্ব হ্রাস করার জন্য সঠিকভাবে ট্রেলিং ক্রয় স্টেপিং শতাংশ সংক্ষিপ্ত করুন।

  2. সর্বোত্তম খুঁজে পেতে বিভিন্ন শতাংশ সেটিংস পরীক্ষা করুন।

  3. বাজারের মানোন্নয়নের জন্য চলমান গড় সময়ের অপ্টিমাইজ করা।

  4. বাজারের পরিসীমা এড়াতে অন্যান্য ফিল্টার যোগ করুন।

  5. ক্ষতি কমানোর জন্য স্টপ লস যোগ করার কথা বিবেচনা করুন।

অপ্টিমাইজেশান নির্দেশাবলী

কৌশলটি নিম্নলিখিত দিকগুলিতে অপ্টিমাইজ করা যেতে পারেঃ

  1. দাম-ভলিউম অসঙ্গতি এড়াতে ক্লিংগারের মতো মূল্য-ভলিউম সূচক যুক্ত করুন।

  2. ভলিউম কন্ডিশনের বিচার যোগ করুন, শুধুমাত্র ভলিউম বাড়লে কিনুন।

  3. বিভিন্ন পণ্যের জন্য চলমান গড় সময়ের অপ্টিমাইজ করুন।

  4. ভোল্টেবিলিটি ইন্ডিকেটর যোগ করুন যাতে ব্যাপ্তি অঞ্চলগুলি এড়ানো যায়।

  5. এটিআর স্টপ লস যোগ করুন।

  6. ধাপে ধাপে শতাংশকে গতিশীল করে তুলুন, যখন প্রবণতা বেশি স্পষ্ট হয় তখন দ্রুততর করুন।

সিদ্ধান্ত

সংক্ষেপে, ট্রেলিং কিনুন কৌশলটি সহজ রাখার সময় মূল্যকে আরও ভাল এন্ট্রি পয়েন্টগুলিতে ট্রেল করে কৌশলটি উন্নত করে। তবে এই কৌশলটিতে এখনও কিছু ঝুঁকি রয়েছে যা আরও বাজার পরিস্থিতির সাথে খাপ খাইয়ে নেওয়ার জন্য আরও অপ্টিমাইজেশান প্রয়োজন। সামগ্রিকভাবে, এই কৌশলটি পরিমাণগত ব্যবসায়ের জন্য একটি রেফারেন্সযোগ্য ধারণা সরবরাহ করে।


/*backtest
start: 2023-10-01 00:00:00
end: 2023-10-08 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ 
//  -----------------------------------------------------------------------------
//  Copyright 2022 Iason Nikolas | jason5480
//  Trailing Buy script may be freely distributed under the MIT license.
//
//  Permission is hereby granted, free of charge, 
//  to any person obtaining a copy of this software and associated documentation files (the "Software"), 
//  to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 
//  publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 
//  subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
//  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
//  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//  -----------------------------------------------------------------------------
//
//  Authors:  @jason5480
//  Revision: v1.0.0
//  Date:     15-Feb-2022
//
//  Description
//  =============================================================================
//  This strategy will go long if fast MA crosses over slow MA.
//  If the trailing buy is checked then the strategy instead of entering into the position
//  directly it will follow the price downwards (percentagewise) with small steps
//  If the price raise by this percentage then the entry order will be executed
//
//  The strategy has the following parameters:
//
//  Fast SMA Length - How many candles back to calculte the fast SMA.
//  Slow SMA Length - How many candles back to calculte the slow SMA.
//  Enable Trailing - Enable or disable the trailing
//  Training Buy Deviation % - The step to follow the price when the open position condition is met.
//  Source Buy - The price to compare the current buyPrice in order to trigger the buy order when trailing
//  
//  -----------------------------------------------------------------------------
//  Disclaimer:
//    1. I am not licensed financial advisors or broker dealer. I do not tell you 
//       when or what to buy or sell. I developed this software which enables you 
//       execute manual or automated using TradingView. The 
//       software allows you to set the criteria you want for entering and exiting 
//       trades.
//    2. Do not trade with money you cannot afford to lose.
//    3. I do not guarantee consistent profits or that anyone can make money with no 
//       effort. And I am not selling the holy grail.
//    4. Every system can have winning and losing streaks.
//    5. Money management plays a large role in the results of your trading. For 
//       example: lot size, account size, broker leverage, and broker margin call 
//       rules all have an effect on results. Also, your Take Profit and Stop Loss 
//       settings for individual pair trades and for overall account equity have a 
//       major impact on results. If you are new to trading and do not understand 
//       these items, then I recommend you seek education materials to further your
//       knowledge.
//
//    YOU NEED TO FIND AND USE THE TRADING SYSTEM THAT WORKS BEST FOR YOU AND YOUR 
//    TRADING TOLERANCE.
//
//    I HAVE PROVIDED NOTHING MORE THAN A TOOL WITH OPTIONS FOR YOU TO TRADE WITH THIS PROGRAM ON TRADINGVIEW.
//    
//    I accept suggestions to improve the script.
//    If you encounter any problems I will be happy to share with me.
//  -----------------------------------------------------------------------------
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// SETUP ============================================================================================================

strategy(title = 'Trailing Buy',
         shorttitle = 'TB',
         overlay = true,
         pyramiding = 0,
         default_qty_type = strategy.percent_of_equity,
         default_qty_value = 100,
         initial_capital = 100000)

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// FILTERS ==========================================================================================================

// INPUT ============================================================================================================
usefromDate = input.bool(defval = true, title = 'From', inline = "From Date", group = "Filters")
fromDate = input(defval = timestamp('01 Jan 2021 00:00 UTC'), title = '', inline = "From Date", group = 'Filters')
usetoDate = input.bool(defval = false, title = 'To ', inline = "To Date", group = "Filters")
toDate = input(defval = timestamp('31 Dec 2121 23:59 UTC'), title = '', inline = "To Date", group = 'Filters')

// LOGIC ============================================================================================================
isWithinPeriod() => true

// PLOT =============================================================================================================
bgcolor(color = isWithinPeriod() ? color.new(color.gray, 90) : na, title = 'Period')

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// STRATEGY =========================================================================================================

// INPUT ============================================================================================================
fastMALen = input.int(defval = 21, title = 'Fast/Slow SMA Length', inline = 'MA Length', group = 'Strategy')
slowMALen = input.int(defval = 49, title = '', tooltip = 'How many candles back to calculte the fast/slow SMA.', inline = 'MA Length', group = 'Strategy')

// LOGIC ============================================================================================================
fastMA = ta.sma(close, fastMALen)
slowMA = ta.sma(close, slowMALen)

bool openLongPosition = isWithinPeriod() and ta.crossover(fastMA, slowMA)
bool closeLongPosition = ta.crossunder(fastMA, slowMA)

bool longIsActive = openLongPosition or strategy.position_size > 0

// PLOT =============================================================================================================
var fastColor = color.new(#0056BD, 0)
plot(series = fastMA, title = 'Fast SMA', color = fastColor, linewidth = 1, style = plot.style_line)
var slowColor = color.new(#FF6A00, 0)
plot(series = slowMA, title = 'Slow SMA', color = slowColor, linewidth = 1, style = plot.style_line)

plotshape(series = openLongPosition and strategy.position_size <= 0 ? fastMA : na, title = 'Buy', text = 'Buy', style = shape.labelup, location = location.absolute, color = color.new(color.green, 0), textcolor = color.new(color.white, 0), size = size.tiny)

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// BUY ==============================================================================================================

// INPUT ============================================================================================================
enableTrailing = input.bool(defval = true, title = 'Enable Trailing', tooltip = 'Enable or disable the trailing for buy.', group = 'Buy')
trailingBuyDeviationPerc = input.float(defval = 4.0, title = 'Trailing Buy Deviation %', minval = 0.01, maxval = 100, step = 0.05, tooltip = 'The step to follow the price when the open position condition is met.', group = 'Buy') / 100
srcBuy = input.source(defval = high, title = 'Source Buy', tooltip = 'The price to check to trigger the buy order', group = 'Buy')

// LOGIC ============================================================================================================
int barsSinceOpenLong = nz(ta.barssince(openLongPosition), 999999)
int barsSinceCloseLong = nz(ta.barssince(closeLongPosition), 999999)
bool tryOpenLongPosition = isWithinPeriod() and barsSinceCloseLong >= barsSinceOpenLong and not (strategy.position_size > 0)

float longBuyPrice = na
longBuyPrice := if openLongPosition and not (strategy.position_size > 0)
    low * (1 + trailingBuyDeviationPerc)
else if tryOpenLongPosition
    math.min(low * (1 + trailingBuyDeviationPerc), nz(longBuyPrice[1], 999999))
else
    na

bool executeLongPosition = enableTrailing ? isWithinPeriod() and srcBuy > longBuyPrice : openLongPosition

// PLOT =============================================================================================================
var buyColor = color.new(#419388, 0)
plot(series = enableTrailing ? longBuyPrice : na, title = 'Long Buy Price', color = buyColor, linewidth = 1, style = plot.style_linebr, offset = 1)

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// POSITION ORDERS ==================================================================================================

// LOGIC ============================================================================================================
// getting into LONG position
strategy.entry(id = 'Long Entry', direction = strategy.long, when = executeLongPosition, alert_message = 'Long(' + syminfo.ticker + '): Started')
// submit close order on trend reversal
strategy.close(id = 'Long Entry', when = closeLongPosition, comment = 'Close Long', alert_message = 'Long(' + syminfo.ticker + '): Closed at market price')

// PLOT =============================================================================================================
var posColor = color.new(color.white, 0)
plot(series = strategy.position_avg_price, title = 'Position', color = posColor, linewidth = 1, style = plot.style_linebr)

// ==================================================================================================================

আরো