Đoản khúc cuộc đời

Ui xịn xò vậy anh, anh tuyệt vời ạh, tks anh nhiều

2 Likes

Anh ơi em lại hỏi ngơ tiếp là màu của các đường kẻ ngang này màu đỏ là báo đỉnh - màu tým báo đáy hồi - màu xanh là ôm chặt.
Nó phù hợp cho uýnh T+ đúng ko ạ ?

Anh sử dụng với sóng Elliott, xác suất và SMA-ATR. Cái em hỏi là xu hướng, đường ở giữa là trung bình, có 3 cận trên và cận dưới, khi breakdown hoặc up thì xu hướng thay đổi ngược lại hay tiếp với xu hướng đang có. Xem xét các vấn đề cùng chỉ báo để bán hoặc mua dựa trên các mức xem xét để có tỉ trọng hợp lý. Kênh ngắn hay dài thì xem hành động giá đi lên hay đi xuống mạnh, yếu.

Điều chỉnh các thông số cài đặt để xem xét lịch sử khớp nhiều nhất có thể, khi đó kết hợp cùng các phương pháp phân tích khác để có điểm mua, bán, không bị mua sớm hay bán sớm. Mục định chỉ báo là cho cái nhìn trực quan cập nhật xu hướng, mục tiêu theo thời gian thực, là phương pháp kiểm tra chéo sóng E của anh.

12 Likes

Hình như là xu hướng tiến về 800 nhỉ bác N

1 Likes

Người cầm tiền thì càng muốn rẻ, ngược lại người cầm cổ không thích, thích và không thích thì cũng không làm được gì với thị trường. Giờ xu hướng tuần chưa bị breakdown 1k nên cứ tạm sống qua ngày đã. Chưa xuống luôn được và cũng chưa lên luôn được. Người cầm cổ thì lựa thời cơ để quyết định giữ hay bán hay hạ. Người cầm tiền có ý định cầm dài thì xem xét gom và gom với tỉ trọng bao nhiêu tùy khẩu vị. Người đánh sóng thì vị thế khác, tùy chiến lược cố định hay T+ thì có điểm bắt, bắt tỉ trọng bao nhiêu và bán khi mục tiêu bao nhiêu tùy xu hướng thị trường, xu hướng đang xấu thì mục tiêu thấp hơn, xu hướng tăng và thuận lợi thì mục tiêu cao hơn,…

17 Likes

mưa hôm nào mát hôm náy á bác Nam

2 Likes

VHM nay đã thủng đáy rồi còn kịch bản nào ko anh. thanks anh

1 Likes

cảm ơn bác

2 Likes

Bác nói chung chung quá bác N em k hiểu . 800 ha

Nếu không tiếp tục đi xuống thì chỉ là fakeout/fakey giống như đáy đầu năm 2023 với 2020. Khi đó nhịp ABC như hình vẫn giữ, chỉnh định lại giá trị. Trong quá trình đi nhịp C thì có sóng nhỏ hơn và có thể không đạt giá trị đó, cụ thể phải cập nhật lúc đó. Nếu tiếp tục di chuyển xuống, mục tiêu 36.5 và 32.5k, khi đó quan sát sự tạo đáy ở hai điểm đó nếu xảy ra. Label sóng sẽ như hình, khi đó sóng A vượt đỉnh 4 tím xác nhận đảo chiều fake, có thể rủi ro hệ thống (hệ sinh thái VIN), rủi ro phi hệ thống (nội tại mã: điều được thấy thì không có, có thể xảy ra vấn đề gì đó).

6 Likes

Nói rất rõ mà, điều kiện phải thủng 1k đã thì mới nghĩ đến trường hợp xuyên đáy. PE inndex đang ở 14.3 khi hôm nay chạm 1037 (gần mục tiêu nhịp C). Thông số kỹ thuật khi về đó vẫn đang tạo phân kỳ dương khung 1h, 4h, khung day thì sát với đáy liền trước và không bị breakdown. Các khung thấp hơn thì cho tín Long sớm hơn.

Dự đoán chỉ là dự đoán, nếu nó không về thì ngồi chơi xơi nước với người cầm dài? Vậy nên có lời khuyên chi tiết, mã nào về vùng gom thì gom, đánh sóng thì bắt tỉ trọng phù hợp khẩu vị rủi ro, có hàng thì tùy vị thế có thể hạ bớt hoặc cắt khi có tín hiệu xấu trong nhịp hồi,…

10 Likes

Nay e cũng nhặt ít HPG. Thấy k thủng 22.4 + phân kỳ

4 Likes

Cụ đánh ngắn đâu mà tính line thế, cụ BN tính xs mốc có thể đảo chiều 22.4 chứ chắc chắn 100% đâu. Tôi tóm tắt cách đánh of cụ BN, cụ nch nh vs cụ BN mà có vẻ k hiểu cụ. Cuối năm trc cụ gom đc 30% vốn HPG từ 13 về 11.8 đc 1,05tr cổ, cụ ns giảm ns tránh trên f là gom đc 50k, k giảm nữa cụ cg k gom thêm. Hồi 3 cây tím cụ bán số lượng= số lãi, lấy lãi về. Chỉnh k sâu như cụ tính nên cụ k mua lại. Cụ định giá 18-20k, cụ giữ lên khu vực đấy cụ bán dần lên 22k thu hết gốc, thu thêm lãi, cụ để lại 200k. Lên 25k cụ thu lãi tiếp, lên 28k cụ bán tiếp, cuối cùng cụ giữ 100k k bán dù cụ tính sẽ chỉnh. Cú chỉnh này cụ mất gần tỉ, nếu cụ giữ lâu slg cổ gom k bán thì cụ lãi nữa nhưng sao cụ k giữ slg lớn, cụ tính an toàn. Bản thân cụ cg đâu dám chắc chắn 100% và cụ ns cơ hội k thiếu, cứ thu về cho chắc ăn. Hqua tôi hỏi cụ mua gom hoặc lướt chưa, cụ ns mua rồi, mua 50k, có gì thì có sẵn cổ trg tk bán cho vui, sai thì giữ.

8 Likes

Em vẫn nhớ bình luận này của bác. Em theo dõi một thời gian không thấy bác chủ trá hình nên em tin bác chủ và bắt đầu nghiên cứu kiến thức của bác chủ.

2 Likes

Em lặn 3 lá, chân dấu kia 7 nước.

2 Likes

Em cảm ơn bác, em nghiên cứu trên lịch sử biểu đồ thấy khá hay ạ. Sử dụng mấy chỉ báo của bác rất hiệu quả ạ nhưng em sử dụng rsi, macd,…lúc xịt lúc nổ. Bác có phương pháp giao dịch nào không ạ. Em muốn học hỏi ạ.

4 Likes

ONE PIECE


:heartpulse: :heartbeat: :revolving_hearts: :two_hearts: :heart_decoration:

1 Likes

HRC hồi phục tốt tuần vừa qua nên hỗ trợ, còn lại xem xét thêm.

3 Likes

Không có cách nào tối ưu cả, chỉ có cách tối ưu nhất có thể, kết hợp nhiều điều kiện để chọn thời điểm đánh và ngừng đánh sóng để hạn chế rủi ro. Về chỉ báo kỹ thuật thì có cách thống kê xác suất khi dùng một hoặc hai hoặc nhiều hơn hai để tìm điểm vào có xác suất tốt nhất. Ví dụ DIG (mã đầu cơ tăng giảm nhiều trong thời gian chu kỳ gần đây).

Về chỉ báo, code bên dưới.

//@version=5
indicator("Winrate calculate table",overlay = true,max_lines_count = 500,max_labels_count = 500)

type Dat
    matrix<int> MTX
    matrix<float> PNL
    matrix<float> PLOT
    matrix<float> Maxprofit
    array<color> Col
    array<float> MAXPF
    array<float> MAXPNL
    array<float> MAXWin
    array<bool> Signals
    array<float> MAXBOX
    array<box> Box
    array<float> Highs
    array<float> LOWS
    array<label> Labels
    map<string, color> Colors

var BackTest = Dat.new(
     matrix.new<int>(7, 2, 0),
     matrix.new<float>(7, 2, 0),
     matrix.new<float>(7, 3, 0),
     matrix.new<float>(7, 3, 0),
     array.new_color(7,color.black),
     array.new_float(7),
     array.new_float(7),
     array.new_float(7),
     array.new_float(7),
     array.new_float(1,0),
     array.new_box(14),
     array.new_float(50),
     array.new_float(50),
     array.new_label(7),
     map.new<string, color>()
     
     )

if barstate.isfirst
    BackTest.Colors.put("Black" , color.black)
    BackTest.Colors.put("Green" , color.green)
    BackTest.Colors.put("Red"   , color.red)
    BackTest.Colors.put("Select" , color.green)

array<string> columns                  =
     array.from('Ratio','Total Trades','Wins','Losses','Winrate','PF','PNL % ')

EXTDeal             = false
var bool Shape      = false
string BACKDATE     =  "I. Backtest date range"
string DASHGROUP    =  "II. DASHGROUP Settings"
string ENTRYG       =  "III. Entry Setup Settings"
string DYNAMICSLG   =  "IV. Stoploss Settings"
string RISKGROUP    =  "V. Risk to Reward Settings" 
string VISUAL       =  "VI. Visuals Settings" 
string EXT          =  "      A. External indicator Settings" 
string INT          =  "      B. Internal Settings" 
string _AROON       =  "      1. Aroon Settings" 
string _AO          =  "      2. AO Settings" 
string _RSI         =  "      3. RSI Settings" 
string _MACD        =  "      4. MACD Settings" 
string _PSAR        =  "      5. PSAR Settings" 
string _STOCH       =  "      6. STOCH Settings" 
string _STOCHRSI    =  "      7. STOCH RSI Settings" 
string _MA          =  "      8. Moving Avg Settings" 
string _ST          =  "      9. SuperTrend Settings" 
string NAME         =  "Backtester table"
string SLZ2TOOL     = "Select Which Stoploss Type you wanna use ?! Dynamic SL or Fixed SL input"
string RRTPTIP      = "When Dynamic system is selected this acts as Level Ratio , else its Fixed Take profit input"
string EXTIP        = "Select external indicator plot"

bool limitRange     = input.bool(title='Backtest Date', defval=false, group=BACKDATE)
int Stime           = input.time(defval=timestamp('31 Dec 2000 00:00 +0000'), title='Start Time', group=BACKDATE)
int Etime           = input.time(defval=timestamp('31 Dec 2080 00:00 +0000'), title='End Time', group=BACKDATE)

string position                     = input.string("Bottom Right", 
     options = [
             "Middle Right",
             "Top Center",
             "Top Right",
             "Middle Left",
             "Middle Center",
             "Bottom Left",
             "Bottom Center",
             "Bottom Right"],
     title = 'Position',
     inline = "001",
     group = DASHGROUP
     )

string textSize      = input.string("Normal", 
     options = [
             "Tiny",
             "Small",
             "Normal",
             "Auto"],
     title = 'Size',
     inline = "001",
     group = DASHGROUP
     )

string MAXWHAT     = input.string("Winrate", 
     options = [
             "Winrate",
             "Profit Factor",
             "PNL"],
     title = '=> Highlight Max',
     inline = "002",
     group = DASHGROUP
     )



bool EntryType      = input.string("Internal", title="=> Entry Type          ",
     options=["External", "Internal"],
     group=ENTRYG,
     inline = "00",
     tooltip = "Internal") 
     == "Internal"

float external_indicator            = input.source(defval=close, title='         External indicator         ',
     group=EXT,
     tooltip=EXTIP,
     inline = "01")

float deal_start_value              = input.int(defval=100, title='         External Value               ',
     group=EXT,
     tooltip="Plot Value",
     inline = "02")


bool AOActive       = input.bool(false,"AO",group = INT,inline = "02")
bool MAActive       = input.bool(false,"MA",group = INT,inline = "02")
bool RSIActive      = input.bool(true,"RSI",group = INT,inline = "02")
bool MACDActive     = input.bool(false,"MACD",group = INT,inline = "02")
bool AroonActive    = input.bool(false,"Aroon",group = INT,inline = "06")
bool STActive       = input.bool(false,"SuperTrend",group = INT,inline = "06")
bool StochActive    = input.bool(false,"Stochastic",group = INT,inline = "06")
bool StochRSIActive = input.bool(false,"Stochastic RSI",group = INT,inline = "06",tooltip = "Indicators Activation")

int Aroonlength = input.int(14, minval=1,group = _AROON,title = "length",inline = "0001")
string AroonType                      = input.string("Crossover", title="Type",
     options=["Crossover", ">","<"],
     group=_AROON,inline = "0001"
     )

float AroonValue = input.float(40,"Value",group = _AROON,inline = "0001")

string AOType                      = input.string("Change to Green", title="Type",
     options=["Change to Green", ">","<"],
     group=_AO,inline = "0001"
     )

float AOValue = input.float(0.002,"Value",group = _AO,inline = "0001")

int RSIlength = input.int(14, minval=1,group = _RSI,title = "length",inline = "0001")
string RSIType                      = input.string("Crossover", title="Type",
     options=["Crossover", ">","<"],
     group=_RSI,inline = "0001"
     )

float RSIValue = input.float(40,"Value",group = _RSI,inline = "0001")

int MACDFast = input.int(12, minval=1,group = _MACD,title = "Fast",inline = "0001")
int MACDslow = input.int(26, minval=1,group = _MACD,title = "Slow",inline = "0001")
int MACDSmooth = input.int(9, minval=1,group = _MACD,title = "Smooth",inline = "0001")

string MACDType                      = input.string("Crossover", title="Type",
     options=["Crossover", ">","<"],
     group=_MACD,inline = "0002"
     )

float MACDValue = input.float(0.002,"Value",group = _MACD,inline = "0002")

int StochK = input.int(14, title="%K Length", minval=1,group = _STOCH,inline = "0001")
int StochSM = input.int(1, title="%K ", minval=1,group = _STOCH,inline = "0001")
int StochD = input.int(3, title="%D", minval=1,group = _STOCH,inline = "0001")
string StochType                      = input.string("Crossover", title="Type",
     options=["Crossover", ">","<"],
     group=_STOCH,inline = "0002"
     )

float StochValue = input.float(40,"Value",group = _STOCH,inline = "0002")

int StochRSIK   = input.int(14, title="K Smooth", minval=1,group = _STOCHRSI,inline = "0001")
int StochRSID   = input.int(1, title="D Smooth ", minval=1,group = _STOCHRSI,inline = "0001")
int StochRSILen = input.int(3, title="Length", minval=1,group = _STOCHRSI,inline = "0001")
string StochRSIType                      = input.string("Crossover", title="Type",
     options=["Crossover", ">","<"],
     group=_STOCHRSI,inline = "0002"
     )

float StochRSIValue = input.float(40,"Value",group = _STOCHRSI,inline = "0002")

int MA1 = input.int(7, title="MA1 Length", minval=1,group = _MA,inline = "0001")
string MAType  = input.string("SMA", title="Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"],inline="0001",group=_MA)
int MA2 = input.int(13, title="MA2 Length", minval=1,group = _MA,inline = "0001")
string MAType2  = input.string("SMA", title="Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"],inline="0001",group=_MA)

float factor = input.float(3,"Factor",group = _ST,inline = "0001")
int atrPeriod = input.int(14,"Period",group = _ST,inline = "0001")

string dynamicSelect  = input.string("ATR SL", title="SL Type                ",
     options=["ATR SL", "Pivot low", "VWAP SL"],
     group=DYNAMICSLG,inline = "02",
     tooltip = "Select how you want your Stoploss to be calculated")

float ATRSL           = input.float(1.,"ATR Factor           ",step = 0.1,
     group = DYNAMICSLG,
     inline = "03",
     tooltip = "Only used with ATR SL")

int LB                = input.int(8, minval=0,title="Pivot Lookback     ",
     group=DYNAMICSLG,
     inline = "04",
     tooltip = "looks for lower low ,Only used with Pivot Low")

float VWAPSL          = input.float(2.5,"Vwap Multiplier    ",step = 0.1,
     group=DYNAMICSLG,
     inline = "05",
     tooltip = "Gets the Vwap value ,Only used with Vwap SL")

CASH       = input.int(1,"Capital",group = RISKGROUP)
LV1        = input.float(0.618, step=0.01,title = "LV 1",group = RISKGROUP)
LV2        = input.float(1, step=0.01,title = "LV 2",group = RISKGROUP)
LV3        = input.float(1.414, step=0.01,title = "LV 3",group = RISKGROUP)
LV4        = input.float(2, step=0.01,title = "LV 4",group = RISKGROUP)
LV5        = input.float(2.414, step=0.01,title = "LV 5",group = RISKGROUP)
LV6        = input.float(3, step=0.01,title = "LV 6",group = RISKGROUP)
LV7        = input.float(3.414, step=0.01,title = "LV 7",group = RISKGROUP)

ShowTrades          = input.bool(true,"Show Trades" ,inline = "002",group = VISUAL)
ShowTP              = input.bool(true,"Show TP" ,inline = "004",group = VISUAL)
ShowHist            = input.bool(true,"Show histogram" ,inline = "005",group = VISUAL)

MAVG(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "Bollinger Bands" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "RMA" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)

ConditionSwitcher(type,val1,val2,val3)=>
    switch type
        "Crossover" => ta.crossover(val1,val2)
        "Change to Green" => ta.crossover(val1,val2)
        ">" => val1 > val3
        "<" => val1 < val3

TIMEfrom_seconds(seconds) =>
    if seconds >= 86400
        string string = str.tostring(math.round(seconds / 86400, 1)) + ' days'
    else if seconds >= 3600
        string string = str.tostring(math.round(seconds / 3600, 1)) + ' hours'
    else
        string string = str.tostring(math.round(seconds / 60, 1)) + ' mins'

switchsize(size) =>
    switch size
        'Tiny'         => size.tiny
        'Small'        => size.small
        'Normal'       => size.normal
        'Auto'         => size.auto

switchPos(Pos) =>
    switch Pos
        "Middle Right"  => position.middle_right
        "Top Center"    => position.top_center
        "Top Right"     => position.top_right
        "Middle Left"   => position.middle_left
        "Middle Center" => position.middle_center
        "Bottom Left"   => position.bottom_left
        "Bottom Center" => position.bottom_center
        "Bottom Right"  => position.bottom_right  

var DataTable          = table.new(switchPos(position),
      15,
      50,
      frame_color = color.white,
      frame_width = 0,
      border_width = 0
      )

G_Color(val)=>
    Pos = color.from_gradient(val,
         0,
         400,
         color.rgb(1, 165, 124),
         color.rgb(2, 85, 46, 24))
    Nig = color.from_gradient(val,
         -0,
         -400,
         color.red,
         color.orange)

    Col = val > 0  ? Pos : Nig

Cell(c,r,Text,bg)=>
    table.cell(DataTable,c,r,Text,
          bgcolor=bg,text_color = color.black,text_size = switchsize(textSize))

x2 = low - ta.rma(ta.tr(true), 14) * ATRSL
PVLOW =  ta.lowest(low,LB)
vwap = math.sum(ta.vwap(ta.tr(true)),14) * volume
volumz = math.sum(volume,14)
atr_vwap_volume = math.abs(vwap / volumz)
VWAPSLZ = low - atr_vwap_volume * VWAPSL

my_stop(SLC) =>
    switch SLC
        "ATR SL" => x2
        "Pivot low" => PVLOW
        "VWAP SL" => VWAPSLZ

sl = my_stop(dynamicSelect)

Aroonupper = 100 * (ta.highestbars(high, Aroonlength) + Aroonlength)/Aroonlength
Aroonlower = 100 * (ta.lowestbars(low, Aroonlength) + Aroonlength)/Aroonlength
ArronLONG = ConditionSwitcher(AroonType,Aroonupper,Aroonlower,AroonValue)

ao = ta.sma(hl2,5) - ta.sma(hl2,34)
diff = ao - ao[1]
AOLONG = ConditionSwitcher(AOType,diff,0,AOValue)

RSI = ta.rsi(close,RSIlength)
RMA = ta.sma(RSI,RSIlength)
RSILONG = ConditionSwitcher(RSIType,RSI,RMA,RSIValue)

[macdLine, signalLine, _] = ta.macd(close, MACDFast, MACDslow, MACDSmooth)
MACDLong = ConditionSwitcher(MACDType,macdLine,signalLine,MACDValue)

Stochk = ta.sma(ta.stoch(close, high, low, StochK), StochSM)
Stochd = ta.sma(Stochk, StochD)
StochLong = ConditionSwitcher(StochType,Stochk,Stochd,StochValue)

rsi1 = ta.rsi(close, StochRSILen)
StochRSIk11 = ta.sma(ta.stoch(rsi1, rsi1, rsi1, StochRSILen), StochRSIK)
StochRSId11 = ta.sma(StochRSIk11, StochRSID)
StochRSILong = ConditionSwitcher(StochRSIType,StochRSIk11,StochRSId11,StochRSIValue)

_MA1 = MAVG(close,MA1,MAType)
_MA2 = MAVG(close,MA2,MAType2)
MALong = ta.crossover(_MA1,_MA2)

[supertrend, direction] = ta.supertrend(factor, atrPeriod)
STlong = ta.crossunder(direction , 0)

internal = (MACDActive ? MACDLong : true) and
     (AroonActive ? ArronLONG : true) and 
     (AOActive ? AOLONG : true) and 
     (RSIActive ? RSILONG : true) and 
     (StochActive ? StochLong : true) and
     (StochRSIActive ? StochRSILong : true) and 
     (MAActive ? MALong : true) and 
     (STActive ? STlong : true)
    

EXTDeal := if external_indicator == deal_start_value
    true

Backdate() =>
    in_date_range = true
    if limitRange
        in_date_range := time >= Stime and time <= Etime
        
    else
        in_date_range := true
 
longDiffSL = math.abs(close - sl)


ENTRY = switch
    EntryType => internal and Backdate()
    not EntryType => EXTDeal and Backdate()


GenCol(i)=>
    ColGen = color.new(color.rgb((20 * (i + 1)) % 255, (70 * (i + 1)) % 255, (120 * (i + 1)) % 255), 80)
    ColGen
 

Backtest(bool sig,tp,i) =>
    
    var active_trade = false
    var TP1 = 0.0
    var SL = 0.0
    var En = 0.0
    var label TO_lab = na
    if sig and not active_trade
        
        TP1 := close + (tp * longDiffSL)
        SL  :=  close - longDiffSL
        En  := close
        active_trade:= true
        BackTest.Col.set(i,color.new(GenCol(bar_index), 0))

    if active_trade
        
        BackTest.Signals.set(i,true)
        
        BackTest.PLOT.set(i,0,En)
        BackTest.PLOT.set(i,1,TP1)
        BackTest.PLOT.set(i,2,SL)
        if high >= TP1
            
            if ShowTP
                TO_lab:=label.new(bar_index - 5 ,
                     TP1,
                     "LV " + str.tostring(float(tp),format= "#.00"),
                     color = color.red,
                     style =  label.style_none,
                     textcolor = chart.fg_color,
                     size = size.small)
            tpValue = ((TP1 - En) / En) * 100
            
            PnlV = math.round(tpValue * CASH / 100,2)

            
            if BackTest.Maxprofit.get(i,0) < PnlV
                BackTest.Maxprofit.set(i,0,PnlV)
                BackTest.Maxprofit.set(i,1,bar_index)
                BackTest.Maxprofit.set(i,2,time)
                
            BackTest.MTX.set(i,0,BackTest.MTX.get(i,0)+1)
            BackTest.PNL.set(i,0,BackTest.PNL.get(i,0)+PnlV)
            active_trade := false
            BackTest.Signals.set(i,false)

        else if low <= SL
            slValue = -((En - SL) / En) * 100
            PnlV = math.round(slValue * CASH / 100,2)
            BackTest.MTX.set(i,1,BackTest.MTX.get(i,1)+1)
            BackTest.PNL.set(i,1,BackTest.PNL.get(i,1)+(PnlV))
            active_trade := false
            BackTest.Signals.set(i,false)
            
Backtest(ENTRY,LV1,0)
Backtest(ENTRY,LV2,1)
Backtest(ENTRY,LV3,2)
Backtest(ENTRY,LV4,3)
Backtest(ENTRY,LV5,4)
Backtest(ENTRY,LV6,5)
Backtest(ENTRY,LV7,6)

ReturnCal(val,val2) =>
    rtn = val + val2
    math.round((rtn / CASH) * 100,2)
    


PFCal(x,y)=>
    math.round(x/(-y),2)


array<string> Ratios  =
     array.from(
             str.tostring(LV1),
             str.tostring(LV2),
             str.tostring(LV3),
             str.tostring(LV4),
             str.tostring(LV5),
             str.tostring(LV6),
             str.tostring(LV7)
             )


if barstate.islast
    
   
    for i = 2 to 8
        Cell(i,0,i == 2 ? NAME : "",color.gray)   

    table.merge_cells(DataTable, 2, 0, 8, 0)

    // lets build the columns
    for i = 0 to columns.size() -1
        Cell(i+2,1,columns.get(i),color.gray)    

    
    for i = 0 to Ratios.size() -1
        Col = color.from_gradient(i,
             0,
             Ratios.size(),
             bottom_color = color.gray,
             top_color = color.gray)

        Cell(2,i+2,Ratios.get(i),Col)          


for i = 0 to BackTest.MTX.rows() - 1
    Nut = color.from_gradient(
             i,
             0,
             BackTest.MTX.rows(),
             bottom_color =  color.gray,
             top_color = color.gray
             )

    
    for j = 0 to BackTest.MTX.columns() - 1
        Total = BackTest.MTX.get(i, 0) + BackTest.MTX.get(i, j)
        Cell(3,(i+1)+ 1,str.tostring(Total),Nut)
        if BackTest.MAXBOX.get(0)< Total
            BackTest.MAXBOX.set(0,Total)

        if j == 0
            Cell(4,(i+1)+ 1,str.tostring(BackTest.MTX.get(i, 0)),Nut)    
        else
            Cell(5,(i+1)+ 1,str.tostring(BackTest.MTX.get(i, j)),Nut)
            Cell(6,(i+1)+ 1,str.tostring(math.round((BackTest.MTX.get(i, 0) / (BackTest.MTX.get(i, 0) + BackTest.MTX.get(i, j))) * 100,2)) +" %",Nut)
            BackTest.MAXWin.set(i,math.round((BackTest.MTX.get(i, 0) / (BackTest.MTX.get(i, 0) + BackTest.MTX.get(i, j))) * 100,2))
           
                             
for i = 0 to BackTest.PNL.rows() - 1
    Nut = color.from_gradient(
             i,
             0,
             BackTest.PNL.rows(),
             bottom_color =  color.gray,
             top_color = color.gray)

    
    for j = 0 to BackTest.PNL.columns() - 1
        BackTest.MAXPF.set(i,PFCal(BackTest.PNL.get(i, 0),BackTest.PNL.get(i, j)))
        BackTest.MAXPNL.set(i,ReturnCal(BackTest.PNL.get(i, 0),BackTest.PNL.get(i, j)))
        Cell(7,(i+1)+ 1,str.tostring(PFCal(BackTest.PNL.get(i, 0),BackTest.PNL.get(i, j))) +" %",PFCal(BackTest.PNL.get(i, 0),BackTest.PNL.get(i, j))< 1 ? color.red: Nut) 
        Cell(8,(i+1)+ 1,
             str.tostring(ReturnCal(BackTest.PNL.get(i, 0),BackTest.PNL.get(i, j))) + " %",
             G_Color(ReturnCal(BackTest.PNL.get(i, 0),BackTest.PNL.get(i, j))))

    tootip = "Max Profit : " + str.format("{0, number, currency}",BackTest.Maxprofit.get(i,0)) + "\n" +
         "Max % : " + str.tostring(math.round(BackTest.Maxprofit.get(i,0) / 100,2)) + " %" + "\n" + 
         "Bar Index " + str.tostring(BackTest.Maxprofit.get(i,1)) + "\n" + 
         "Time : " + str.format("{0,date,medium}",BackTest.Maxprofit.get(i,2))
                
    table.cell_set_tooltip(DataTable,2,i+2,tooltip = tootip)

method volAdj(int len)=>
    math.min(ta.atr(len) * 0.3, close * (0.3/100)) [20] /2

Adj = volAdj(30)

if MAXWHAT == "PNL"
    WinIndex = BackTest.MAXPNL.indexof(BackTest.MAXPNL.max())
    for i = 2 to 7
        table.cell_set_bgcolor(DataTable,i,(WinIndex+1)+ 1,BackTest.Colors.get("Select"))

if MAXWHAT == "Profit Factor"
    MAXS = BackTest.MAXPF.indexof(BackTest.MAXPF.max())
    for i = 2 to 7
        table.cell_set_bgcolor(DataTable,i,(MAXS+1)+ 1,BackTest.Colors.get("Select"))

if MAXWHAT == "Winrate"
    MAXSW = BackTest.MAXWin.indexof(BackTest.MAXWin.max())
    for i = 2 to 7
        table.cell_set_bgcolor(DataTable,i,(MAXSW+1)+ 1,BackTest.Colors.get("Select"))

plot(ShowTrades and BackTest.Signals.get(0) ? BackTest.PLOT.get(0,0) : na , color = BackTest.Colors.get("Black") ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(0) ? BackTest.PLOT.get(0,1) : na , color = BackTest.Col.get(0) ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(0) ? BackTest.PLOT.get(0,2) : na , color = BackTest.Colors.get("Red") ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(1) ? BackTest.PLOT.get(1,0) : na , color = BackTest.Colors.get("Black") ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(1) ? BackTest.PLOT.get(1,1) : na , color = BackTest.Col.get(1) ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(1) ? BackTest.PLOT.get(1,2) : na , color = BackTest.Colors.get("Red") ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(2) ? BackTest.PLOT.get(2,0) : na , color = BackTest.Colors.get("Black")  ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(2) ? BackTest.PLOT.get(2,1) : na , color = BackTest.Col.get(2) ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(2) ? BackTest.PLOT.get(2,2) : na , color = BackTest.Colors.get("Red") ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(3) ? BackTest.PLOT.get(3,0) : na , color = BackTest.Colors.get("Black") ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(3) ? BackTest.PLOT.get(3,1) : na , color = BackTest.Col.get(3) ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(3) ? BackTest.PLOT.get(3,2) : na , color = BackTest.Colors.get("Red") ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(4) ? BackTest.PLOT.get(4,0) : na , color = BackTest.Colors.get("Black") ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(4) ? BackTest.PLOT.get(4,1) : na , color = BackTest.Col.get(4) ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(4) ? BackTest.PLOT.get(4,2) : na , color = BackTest.Colors.get("Red") ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(5) ? BackTest.PLOT.get(5,0) : na , color = BackTest.Colors.get("Black") ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(5) ? BackTest.PLOT.get(5,1) : na , color = BackTest.Col.get(5) ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(5) ? BackTest.PLOT.get(5,2) : na , color = BackTest.Colors.get("Red") ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(6) ? BackTest.PLOT.get(6,0) : na , color = BackTest.Colors.get("Black") ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(6) ? BackTest.PLOT.get(6,1) : na , color = BackTest.Col.get(6) ,style =plot.style_linebr)
plot(ShowTrades and BackTest.Signals.get(6) ? BackTest.PLOT.get(6,2) : na , color = BackTest.Colors.get("Red") ,style =plot.style_linebr)

Hình 1: Chọn vào backtest date và chọn chu kỳ test mục I. Mục II chọn hiển thị thông số, vị trí bảng. Mục III, mặc định chọn internal là các thông số các mục B, ngược lại liên kết bên ngoài thì chọn mục A (liên kết chỉ báo khác với các thông số cài đặt riêng). Mục B thì chọn một hoặc nhiều chỉ báo để chọn điểm vào, nếu chọn nhiều sẽ an toàn hơn nhưng sẽ chờ lâu hơn, thường chọn 1 hoặc hai tín hiệu đồng thời có Winrate lớn nhất.

Hình 2: Cài đặt các thông số cho chỉ báo theo khẩu vị giao dịch.

Hình 3: Mục IV cài đặt các thông số cắt lỗ.

Hình 5: Mục V là các mức để tính xác suất trong quá khứ đạt ở các level cài đặt với xác suất win bao nhiêu. Nam đang để mặc định như thế cho chỉ số, còn cổ phiếu thường để 1-1.5-2-,…

Ví dụ cụ thể:
Mũi tên xanh lá chỉ điểm vào lệnh mua (đường ngang đen), đỏ chỉ điểm stoploss (đường ngang đỏ), tím chỉ các level cài đặt, màu thay đổi theo thuật toán viết trong script. Nên xem hai khung giờ và phân tích các ảnh hưởng khác để quyết định.

Hình bên dưới: Sử dụng script cùng chỉ báo RSI, chỉ báo xác suất, kênh xu hướng. Điểm đánh dấu tròn đỏ là điểm breakdown kênh xu hướng, gần breakdown đường MA tích lũy dài hạn, RSI đang bên dưới đường EMA, là điểm quan sát chứ không phải mua. Điểm tròn xanh biển là điểm gợi ý đảo chiều, cây nến sau đó là cây nến cho điểm mua (đường ngang đen), mua bao nhiêu tùy khẩu vị với xác suất lên mục tiêu khu 19k là 88%, và/hoặc đợi nhịp test mua thêm tùy theo diễn biến.

Hãy xem khu vực đánh dấu số 1 và 2, khu vực 2 đang tạo phân kỳ dương nhưng xác suất đang chỉ về thấp hơn, cho tín hiệu mua ở ngày đánh dấu nhưng mua hay không? mua tỉ trọng bao nhiêu và có quyết liệt cắt lỗ không?..



13 Likes

Em cảm ơn bác nhiều ạ. Em không biết nói gì hơn. Bác quá tuyệt vời dù em biết bác chắc chắn còn dấu tuyệt học.

4 Likes