-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlgo V1.1-Lite
862 lines (727 loc) · 48.6 KB
/
Algo V1.1-Lite
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheLameCo
//@version=5
indicator("TheLameFactory Algo V1.1-Lite",
"TLF Algo V1.1-Lite",
overlay = true,
max_lines_count = 500,
max_labels_count = 500,
max_bars_back = 1)
//
// SECTION <1> title : "Variable Declarations"
// SECTION <1> note : In this section the variables that are going to be used across Algo are declared.
// SECTION <1> subsection : <<1>>Groups and Tooltips, <<2>>Colors and styles, <<3>>Strategy Variables
// SECTION <1> [Start]{
// <1>:<<1>>Groups and Tooltips [Start]{
//Groups
FltrGp = " ███ Time Filter ███" //Filter Setting
StratGp = " ███ Strategy Selection & Source ███" //Strategy
RiskGp = " ███ Risk Management ███" //Risk Management
CommGp = " ███ Order Type & Commission ███" //order Type & Commission
SlGp = " ███ StopLoss ███" //Stoploss
TpGp = " ███ TakeProfit ███" //TakeProfit
PlotGp = " ███ Displays ███" //Displays
// Tooltips
stratSeT = "To manually configure the strategy, select MANUAL otherwise, changing the settings won't have any effect"
riskT = "Maximum allowable loss % of the deposit per 1 trade"
slT = "If choosed: stoploss will be calculated manually \nIf NOT choosed: stoploss will be calculated automatic"
devT = "Shows all possible events"
// <1>:<<1>>Groups and Tooltips [End]}
// <1>:<<2>>Colors and styles [Start]{
int fibo_lines_trans = 60
int fill_best_transp = 95
int fill_worst_transp = 98
color high_line_color = color.rgb(36, 255, 44, fibo_lines_trans)
color fib_236_color = color.rgb(130, 228, 74, fibo_lines_trans)
color fib_382_color = color.rgb(171, 224, 174, fibo_lines_trans)
color fib_618_color = color.rgb(235, 255, 51, fibo_lines_trans)
color fib_786_color = color.rgb(255, 131, 73, fibo_lines_trans)
color low_line_color = color.rgb(255, 82, 82, fibo_lines_trans)
color high_best_fill_color = color.rgb(48, 255, 55, fill_best_transp)
color high_worst_fill_color = color.rgb(37, 255, 44, fill_worst_transp)
color low_best_fill_color = color.rgb(255, 54, 54, fill_best_transp)
color low_worst_fill_color = color.rgb(255, 43, 43, fill_worst_transp)
tp_sl_entry_trans = 30
color tp_col = color.new(color.green, tp_sl_entry_trans)
color en_col = color.rgb(120, 123, 134, tp_sl_entry_trans)
color sl_col = color.new(color.red, tp_sl_entry_trans)
line_dot = line.style_dotted
line_sol = line.style_solid
color green = color.green
color red = color.red
color pos_lb_col = color.rgb(255, 255, 255, 100)
lb_left = label.style_label_left
lb_right = label.style_label_right
color gfill = color.new(color.green, 85)
color rfill = color.new(color.red, 85)
color tbl_gb = color.rgb(0, 0, 0, 87)
txt_left = text.align_left
// Display Formats
dw_Y = display.data_window
dw_N = display.all - display.data_window
// <1>:<<2>>Colors and styles [End]}
// <1>:<<3>>Strategy Variables [Start]{
var float sensitivity = 18
float risk_percent = 1
string break_even_target = "2"
float tp1_percent = 0
float tp1_percent_fix = 0
float tp2_percent = 0
float tp2_percent_fix = 0
float tp3_percent = 0
float tp3_percent_fix = 0
float tp4_percent = 0
float tp4_percent_fix = 0
bool fixed_stop = false
float sl_percent = 0
// <1>:<<3>>Strategy Variables [End]}
// SECTION <1> [End]}
// SECTION <2> title : "Types Declarations"
// SECTION <2> note : In this section the type variabls are declared
// SECTION <2> subsection : <<1>>Strategy_settings Type, <<2>>trade Type
// SECTION <2> [Start]{
// <2>:<<1>>Strategy_settings Type [Start]{
type Strategy_settings
float sensitivity = 0
float risk_percent = 1
string break_even_target = "1"
float tp1_percent = 0
float tp1_percent_fix = 0
float tp2_percent = 0
float tp2_percent_fix = 0
float tp3_percent = 0
float tp3_percent_fix = 0
float tp4_percent = 0
float tp4_percent_fix = 0
bool fixed_stop = false
float sl_percent = 0
//
// <2>:<<1>>Strategy_settings Type [End]}
// <2>:<<2>>trade Type [Start]{
type Trade
int start_bar_index = 0
string side
float market_order_comission
float limit_order_comission
float entry_price
bool entry_hit = false
float sl_price
float tp1_price
float tp1_percent_fix
float tp2_price
float tp2_percent_fix
float tp3_price
float tp3_percent_fix
float tp4_price
float tp4_percent_fix
float break_even_price
bool sl_hit = false
bool tp1_hit = false
bool tp2_hit = false
bool tp3_hit = false
bool tp4_hit = false
float position_size_left = 100
float risk_percent
bool is_closed = false
float close_price = 0
bool can_break_even = false
bool force_closed = false
float profit = 0
float risk_reward
line entry_line
line stoploss_line
line target1_line
line target2_line
line target3_line
line target4_line
// <2>:<<2>>trade Type [End]}
// SECTION <2> [End]}
// SECTION <3> title : "Functions Declarations"
// SECTION <3> note : In this section the Algo's functions are declared
// SECTION <3> subsection : There are no subsections under this section.
// SECTION <3> [Start]{
//RoundUp Fx
RoundUp(number, decimals) =>
factor = math.pow(10, decimals)
math.ceil(number * factor) / factor
//RR Fx
calc_rr(float entry_price, float sl_price, float take_price) =>
entry_price > sl_price ? (take_price - entry_price) / (entry_price - sl_price) : (entry_price - take_price) / (sl_price - entry_price)
//TrendLine Fx
create_trend_line(float sensitivity, float fib) =>
high_line = ta.highest(high, int(sensitivity))
low_line = ta.lowest(low, int(sensitivity))
channel_range = high_line - low_line
high_line - channel_range * fib
// Strategy Selector fx
selector(string strategy_name) =>
strategy_settings = Strategy_settings.new()
switch strategy_name
"MANUAL" =>
strategy_settings.sensitivity := 18
strategy_settings.risk_percent := 1
strategy_settings.break_even_target := "1"
strategy_settings.tp1_percent := 1
strategy_settings.tp1_percent_fix := 40
strategy_settings.tp2_percent := 2
strategy_settings.tp2_percent_fix := 30
strategy_settings.tp3_percent := 3
strategy_settings.tp3_percent_fix := 20
strategy_settings.tp4_percent := 4
strategy_settings.tp4_percent_fix := 10
strategy_settings.fixed_stop := false
strategy_settings.sl_percent := 0.0
"UNIVERSAL 15m" =>
strategy_settings.sensitivity := 20
strategy_settings.risk_percent := 1
strategy_settings.break_even_target := "1"
strategy_settings.tp1_percent := 1
strategy_settings.tp1_percent_fix := 40
strategy_settings.tp2_percent := 2
strategy_settings.tp2_percent_fix := 30
strategy_settings.tp3_percent := 3
strategy_settings.tp3_percent_fix := 20
strategy_settings.tp4_percent := 4
strategy_settings.tp4_percent_fix := 10
strategy_settings.fixed_stop := false
strategy_settings.sl_percent := 0.0
"SOL 5m" =>
strategy_settings.sensitivity := 20
strategy_settings.risk_percent := 1
strategy_settings.break_even_target := "1"
strategy_settings.tp1_percent := 1
strategy_settings.tp1_percent_fix := 40
strategy_settings.tp2_percent := 2
strategy_settings.tp2_percent_fix := 30
strategy_settings.tp3_percent := 3
strategy_settings.tp3_percent_fix := 20
strategy_settings.tp4_percent := 4
strategy_settings.tp4_percent_fix := 10
strategy_settings.fixed_stop := false
strategy_settings.sl_percent := 0.0
strategy_settings
// SECTION <3> [End]}
// SECTION <4> title : "Active Trade Label"
// SECTION <4> note : The Active trade label is calculated in this section through a newly defined method "calc_profit".
// SECTION <4> subsection : There are no subsections under this section.
// SECTION <4> [Start]{
method calc_profit(Trade trade, bool show_labels) =>
label trade_info_label = na
label entry_hit_label = na
label tp1_hit_label = na
label tp2_hit_label = na
label tp3_hit_label = na
label tp4_hit_label = na
label sl_hit_label = na
label be_hit_label = na
float profit = 0.0
//
if trade.side == "LONG"
if low <= trade.entry_price and not trade.entry_hit
trade.start_bar_index := bar_index
trade.entry_hit := true
entry_hit_label := label.new(trade.start_bar_index, trade.entry_price, str.tostring("ENTRY HIT"), color=color.blue, textcolor=color.white, size=size.normal, style = lb_right)
trade_info_label := label.new(bar_index, high, "Trade info:" + "\nEntry: " + str.tostring(trade.entry_price) + "\nTp1: " + str.tostring(trade.tp1_price) + "\nTp2: " + str.tostring(trade.tp2_price) + "\nTp3:" + str.tostring(trade.tp3_price) + "\nTp4: " + str.tostring(trade.tp4_price) + "\nSl: " + str.tostring(trade.sl_price), color=color.green, textcolor=color.white, size= size.small )
if high >= trade.tp1_price and not trade.tp1_hit and trade.entry_hit
trade.tp1_hit := true
trade.position_size_left -= trade.tp1_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp1_price) * trade.tp1_percent_fix / 100 * trade.risk_percent
tp1_hit_label := label.new(trade.start_bar_index, trade.tp1_price, str.tostring("TP1 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = lb_right)
if high >= trade.tp2_price and not trade.tp2_hit and trade.entry_hit
trade.tp2_hit := true
trade.can_break_even := true
trade.position_size_left -= trade.tp2_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp2_price) * trade.tp2_percent_fix / 100 * trade.risk_percent
tp2_hit_label := label.new(trade.start_bar_index, trade.tp2_price, str.tostring("TP2 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = lb_right)
if high >= trade.tp3_price and not trade.tp3_hit and trade.entry_hit
trade.tp3_hit := true
trade.position_size_left -= trade.tp3_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp3_price) * trade.tp3_percent_fix / 100 * trade.risk_percent
tp3_hit_label := label.new(trade.start_bar_index, trade.tp3_price, str.tostring("TP3 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = lb_right)
if high >= trade.tp4_price and not trade.tp4_hit and trade.entry_hit
trade.tp4_hit := true
trade.is_closed := true
trade.position_size_left -= trade.tp4_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp4_price) * trade.tp4_percent_fix / 100 * trade.risk_percent
tp4_hit_label := label.new(trade.start_bar_index, trade.tp4_price, str.tostring("TP4 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = lb_right)
if high >= trade.break_even_price and not trade.can_break_even and trade.entry_hit
trade.can_break_even := true
//
//BE ENTRY HIT
if trade.can_break_even and trade.entry_hit
if low <= trade.entry_price and not (close >= open) and bar_index != trade.start_bar_index
trade.is_closed := true
be_hit_label := label.new(bar_index, trade.entry_price, str.tostring("BE HIT"), style = lb_left)
// SL HIT
if low <= trade.sl_price and not trade.can_break_even and trade.entry_hit and bar_index != trade.start_bar_index
trade.sl_hit := true
trade.is_closed := true
profit += -trade.risk_percent * trade.position_size_left / 100
sl_hit_label := label.new(bar_index, trade.sl_price, str.tostring("SL HIT ") + str.tostring(profit, "#.##") + "%", color = red, style = lb_left)
else
if high >= trade.entry_price and not trade.entry_hit
trade.start_bar_index := bar_index
trade.entry_hit := true
entry_hit_label := label.new(trade.start_bar_index, trade.entry_price, str.tostring("ENTRY HIT"), style = lb_right)
trade_info_label := label.new(bar_index, high, "Trade info:" + "\nEntry: " + str.tostring(trade.entry_price) + "\nTp1: " + str.tostring(trade.tp1_price) + "\nTp2: " + str.tostring(trade.tp2_price) + "\nTp3:" + str.tostring(trade.tp3_price) + "\nTp4: " + str.tostring(trade.tp4_price) + "\nSl: " + str.tostring(trade.sl_price))
if low <= trade.tp1_price and not trade.tp1_hit and trade.entry_hit
trade.tp1_hit := true
trade.position_size_left -= trade.tp1_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp1_price) * trade.tp1_percent_fix / 100 * trade.risk_percent
tp1_hit_label := label.new(trade.start_bar_index, trade.tp1_price, str.tostring("TP1 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = lb_right)
if low <= trade.tp2_price and not trade.tp2_hit and trade.entry_hit
trade.tp2_hit := true
trade.position_size_left -= trade.tp2_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp2_price) * trade.tp2_percent_fix / 100 * trade.risk_percent
tp2_hit_label := label.new(trade.start_bar_index, trade.tp2_price, str.tostring("TP2 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = lb_right)
if low <= trade.tp3_price and not trade.tp3_hit and trade.entry_hit
trade.tp3_hit := true
trade.position_size_left -= trade.tp3_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp3_price) * trade.tp3_percent_fix / 100 * trade.risk_percent
tp3_hit_label := label.new(trade.start_bar_index, trade.tp3_price, str.tostring("TP3 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = lb_right)
if low <= trade.tp4_price and not trade.tp4_hit and trade.entry_hit
trade.tp4_hit := true
trade.is_closed := true
trade.position_size_left -= trade.tp4_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp4_price) * trade.tp4_percent_fix / 100 * trade.risk_percent
tp4_hit_label := label.new(trade.start_bar_index, trade.tp4_price, str.tostring("TP4 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = lb_right)
if low <= trade.break_even_price and not trade.can_break_even and trade.entry_hit
trade.can_break_even := true
//
//BE ENTRY HIT
if trade.can_break_even and trade.entry_hit
if high >= trade.entry_price and not (close <= open) and bar_index != trade.start_bar_index
trade.is_closed := true
be_hit_label := label.new(bar_index, trade.entry_price, str.tostring("BE HIT"), style = lb_left)
//
// SL HIT
if high >= trade.sl_price and not trade.can_break_even and trade.entry_hit and bar_index != trade.start_bar_index
trade.sl_hit := true
trade.is_closed := true
profit += -trade.risk_percent * trade.position_size_left / 100
sl_hit_label := label.new(bar_index, trade.sl_price, str.tostring("SL HIT ") + str.tostring(profit, "#.##") + "%", color = red, style = lb_left)
trade.profit += profit
if not show_labels
label.delete(entry_hit_label)
label.delete(trade_info_label)
label.delete(tp1_hit_label)
label.delete(tp2_hit_label)
label.delete(tp3_hit_label)
label.delete(tp4_hit_label)
label.delete(sl_hit_label)
label.delete(be_hit_label)
//
// SECTION <4> [End]}
// SECTION <5> title : "Closed Trade Label"
// SECTION <5> note : The Closed trade label is calculated in this section through a newly defined method "close_trades"
// SECTION <5> subsection : There are no subsections under this section.
// SECTION <5> [Start]{
method close_trade(Trade trade, bool show_labels) =>
float profit = 0.0
label trade_closed_label = na
trade.force_closed := true
if not trade.sl_hit
if trade.side == "SHORT"
trade.is_closed := true
trade.close_price := close
if close <= trade.entry_price
percent_from_entry_to_close_price_at_trend_change = math.abs((close / trade.entry_price) * 100)
percent_from_entry_to_sl_price = math.abs((trade.entry_price / trade.sl_price) * 100)
profit := calc_rr(trade.entry_price, trade.sl_price, close) * trade.position_size_left / 100 * trade.risk_percent
else
profit := calc_rr(trade.entry_price, trade.sl_price, close) * trade.position_size_left / 100 * trade.risk_percent
string sign = profit >= 0 ? "+" : na
trade_closed_label := label.new(bar_index, high, str.tostring("TRADE CLOSED ") + sign + str.tostring(profit, "#.##") + "%")
else
trade.is_closed := true
trade.close_price := close
if close <= trade.entry_price
percent_from_entry_to_close_price_at_trend_change = math.abs((close / trade.entry_price - 1) * 100)
percent_from_entry_to_sl_price = math.abs((trade.entry_price / trade.sl_price - 1) * 100)
profit := -trade.risk_percent * (percent_from_entry_to_close_price_at_trend_change / percent_from_entry_to_sl_price) * trade.position_size_left / 100 + trade.profit
else
profit := calc_rr(trade.entry_price, trade.sl_price, close) * trade.position_size_left / 100 * trade.risk_percent
string sign = profit >= 0 ? "+" : na
trade_closed_label := label.new(bar_index, low, str.tostring("TRADE CLOSED ") + sign + str.tostring(profit, "#.##") + "%", style = label.style_label_up)
if not show_labels
label.delete(trade_closed_label)
trade.profit += profit
//
// SECTION <5> [End]}
// SECTION <6> title : "User inputs"
// SECTION <6> note : This section has the user inputs of the Algo.
// SECTION <6> subsection : There are no subsections under this section.
// SECTION <6> [Start]{
// Time Filter
start_date_input = input.time(timestamp("24 October 2024"), "Start calculating date", group = FltrGp)
// Strategy Selector & Sensivity
ext_src_ = input.bool(false, "External Source?", group = StratGp)
ext_src = input.source(close, "Select External Source", group = StratGp)
strategy_input = input.string("MANUAL","STRATEGY", [
"MANUAL",
"UNIVERSAL 15m",
"===============",
"-------A-------",
"-------B-------",
"-------C-------",
"-------D-------",
"-------E-------",
"-------F-------",
"-------G-------",
"-------H-------",
"-------I-------",
"-------J-------",
"-------K-------",
"-------L-------",
"-------M-------",
"-------N-------",
"-------O-------",
"-------P-------",
"-------Q-------",
"-------R-------",
"-------S-------",
"SOL 5m",
"-------T-------",
"-------U-------",
"-------V-------",
"-------W-------",
"-------X-------",
"-------Y-------",
"-------Z-------"
], stratSeT, inline = "strat3", group = StratGp)
sensitivity_input = input.float(18, "Sensitivity", step = 0.1, group = StratGp)
// Comission
ordertype = input.string("Limit", "Order Type", options = ["Limit", "Market"], group = CommGp)
commission_ = input.float(0.05, "Comission %", step = 0.01, group = CommGp)
comm_cost_use = input.bool(true, "Include commission?", group = CommGp)
// Risk Management
initial_equity = input.float(100, "Initial deposit $", step = 100, minval = 10, group = RiskGp)
lev_default = input.int(100, "Max Allowed Leverage", group = RiskGp)
risk_per = input.float(1, "Risk %", step = 1, tooltip = riskT, group = RiskGp)
comm_size_use = input.bool(true, "Size with commission?", group = RiskGp)
BE_target = input.string("1", "BE target", options = ["WITHOUT","1","2","3"], group = RiskGp)
// Stop Loss
fixed_sl_ = input.bool(true, "Fixed stoploss %", tooltip = slT, group = SlGp)
sl_per_ = input.float(0.03, "SL %", step = 0.001, group = SlGp)
// Take Profit
tp1_percent_ = input.float(0.06, "TP 1", 0, 100, 0.05, inline = "2.2", group = TpGp)
tp1_percent_fix_ = input.float(10, "Fix %", step = 5, inline = "2.2", group = TpGp)
tp2_percent_ = input.float(0.2, "TP 2", 0, 100, 0.05, inline = "2.3", group = TpGp)
tp2_percent_fix_ = input.float(10, "Fix %", step = 5, inline = "2.3", group = TpGp)
tp3_percent_ = input.float(0.3, "TP 3", 0, 100, 0.05, inline = "2.4", group = TpGp)
tp3_percent_fix_ = input.float(50, "Fix %", step = 5, inline = "2.4", group = TpGp)
tp4_percent_ = input.float(0.4, "TP 4", 0, 100, 0.05, inline = "2.5", group = TpGp)
tp4_percent_fix_ = input.float(30, "Fix %", step = 5, inline = "2.5", group = TpGp)
// Position plots
tl_plot = input.bool(true, "Plot Trend Line", group = PlotGp)
show_tp_enty_sl = input.bool(true, "Plot Positions?", inline = "2.1", group = PlotGp)
fill_positions = input.bool(true, "Fill Positions?", inline = "2.1", group = PlotGp)
show_profit_panel = input.bool(true, "Show profit panel", group = PlotGp)
show_strategy_panel = input.bool(true, "Show strategy panel", group = PlotGp)
show_old_panel = input.bool(true, "Show old panel", group = PlotGp)
show_dev_labels = input.bool(true, "Fine-tune labels", tooltip = devT, group = PlotGp)
// SECTION <6> [End]}
// SECTION <7> title : "Algo Calculations"
// SECTION <7> note : This section has the calculations of the Algo
// SECTION <7> subsection : <<1>>Calculation variables, <<2>>Startegy Calculation, <<3>>Default Logic, <<4>>Long/Short Condition, <<5>>Logic 1, <<6>>Logic 2
// SECTION <7> [Start]{
// <7>:<<1>>Calculation variables [Start]{
var float total_profit = 0.0
var int trade_count = 0
var int profit_trades = 0
var int loss_trades = 0
var int loss_streak = 0
var int loss_in_a_row = 0
var int win_streak = 0
var int wins_in_a_row = 0
var int first_trade_date = na
var Trade trade = na
var bool is_long_trend_started = false
var bool is_short_trend_started = false
var bool is_trend_change = na
var bool is_long_trend = false
var bool is_short_trend = false
var bool can_long = false
var bool can_short = false
var int trend_started_bar_index = na
var line tp1_line = na
var label tp1_label = na
var line tp2_line = na
var label tp2_label = na
var line tp3_line = na
var label tp3_label = na
var line tp4_line = na
var label tp4_label = na
var line entry_line = na
var label entry_label = na
var line close_line = na
var line sl_line = na
var label sl_label = na
var label lable_at_signal = na
var int signal_closed_bar = na
var Strategy_settings strategy_s = na
var float dep = initial_equity
// <7>:<<1>>Calculation variables [End]}
// <7>:<<2>>Startegy Calculation [Start]{
strategy_s := strategy_input == "MANUAL" ? Strategy_settings.new(sensitivity_input, risk_per, BE_target, tp1_percent_, tp1_percent_fix_, tp2_percent_, tp2_percent_fix_, tp3_percent_, tp3_percent_fix_, tp4_percent_, tp4_percent_fix_, fixed_sl_, sl_per_) : selector(strategy_input)
sensitivity := strategy_s.sensitivity
risk_percent := strategy_s.risk_percent
break_even_target := strategy_s.break_even_target
tp1_percent := strategy_s.tp1_percent
tp1_percent_fix := strategy_s.tp1_percent_fix
tp2_percent := strategy_s.tp2_percent
tp2_percent_fix := strategy_s.tp2_percent_fix
tp3_percent := strategy_s.tp3_percent
tp3_percent_fix := strategy_s.tp3_percent_fix
tp4_percent := strategy_s.tp4_percent
tp4_percent_fix := strategy_s.tp4_percent_fix
fixed_stop := strategy_s.fixed_stop
sl_percent := strategy_s.sl_percent
sensitivity *= 10
tp1_percent /= 100
tp2_percent /= 100
tp3_percent /= 100
tp4_percent /= 100
tp1_percent_fix /= 100
tp2_percent_fix /= 100
tp3_percent_fix /= 100
tp4_percent_fix /= 100
sl_percent /= 100
// <7>:<<2>>Startegy Calculation [End]}
// <7>:<<3>>Default Logic [Start]{
high_line = ta.highest(high, int(sensitivity))
low_line = ta.lowest(low, int(sensitivity))
channel_range = high_line - low_line
fib_236 = high_line - channel_range * (0.236)
fib_382 = high_line - channel_range * 0.382
fib_5 = high_line - channel_range * 0.5
fib_618 = high_line - channel_range * 0.618
fib_786 = high_line - channel_range * (0.786)
imba_trend_line = fib_5
// <7>:<<3>>Default Logic [End]}
// <7>:<<4>>Long/Short Condition [Start]{
if time >= start_date_input
can_long := (ext_src_ ? ext_src == 1 : (close >= imba_trend_line and close >= fib_236)) and not is_long_trend
can_short := (ext_src_ ? ext_src == -1 : (close <= imba_trend_line and close <= fib_786)) and not is_short_trend
if can_long
is_long_trend := true
is_short_trend := false
is_long_trend_started := is_long_trend_started ? false : true
else if can_short
is_short_trend := true
is_long_trend := false
is_short_trend_started := is_short_trend_started ? false : true
else
is_trend_change := false
can_long := false
can_short := false
is_short_trend_started := false
is_long_trend_started := false
is_trend_change := is_short_trend_started or is_long_trend_started
// <7>:<<4>>Long/Short Condition [End]}
// <7>:<<5>>Logic 1 [Start]{
if not na(trade)
calc_profit(trade, show_dev_labels)
if is_trend_change and not trade.is_closed
close_trade(trade, show_dev_labels)
if not trade.is_closed
label.set_x (entry_label, bar_index - 3)
label.set_text (entry_label, str.tostring(trade.side == "LONG" ? "🔰" : "🔰") + str.tostring(trade.entry_price))
label.set_x (sl_label, bar_index - 3)
label.set_text (sl_label, "⛔" + str.tostring(trade.sl_price))
label.set_x (tp1_label, bar_index - 3)
label.set_text (tp1_label, str.tostring(trade.tp1_hit ? "✅" : "1️⃣") + str.tostring(trade.tp1_price))
label.set_x (tp2_label, bar_index - 3)
label.set_text (tp2_label, str.tostring(trade.tp2_hit ? "✅" : "2️⃣") + str.tostring(trade.tp2_price))
label.set_x (tp3_label, bar_index - 3)
label.set_text (tp3_label, str.tostring(trade.tp3_hit ? "✅" : "3️⃣") + str.tostring(trade.tp3_price))
label.set_x (tp4_label, bar_index - 3)
label.set_text (tp4_label, str.tostring(trade.tp4_hit ? "✅" : "4️⃣") + str.tostring(trade.tp4_price))
line.set_xy1 (tp1_line, trade.start_bar_index, trade.tp1_price)
line.set_xy2 (tp1_line, bar_index + 1, trade.tp1_price)
line.set_xy1 (tp2_line, trade.start_bar_index, trade.tp2_price)
line.set_xy2 (tp2_line, bar_index + 1, trade.tp2_price)
line.set_xy1 (tp3_line, trade.start_bar_index, trade.tp3_price)
line.set_xy2 (tp3_line, bar_index + 1, trade.tp3_price)
line.set_xy1 (tp4_line, trade.start_bar_index, trade.tp4_price)
line.set_xy2 (tp4_line, bar_index + 1, trade.tp4_price)
line.set_xy1 (entry_line, trade.start_bar_index, trade.entry_price)
line.set_xy2 (entry_line, bar_index + 1, trade.entry_price)
line.set_xy1 (sl_line, trade.start_bar_index, trade.sl_price)
line.set_xy2 (sl_line, bar_index + 1, trade.sl_price)
lable_at_signal.set_x(int(math.avg(bar_index, trade.start_bar_index)))
sign = trade.profit >= 0 ? "+" : na
lable_at_signal.set_text(sign + str.tostring(trade.profit, "#.##") + "%")
lable_at_signal.set_color(trade.profit >= 0 ? green : red)
// FILLING
if fill_positions
if trade.tp1_hit
linefill.new(entry_line, tp1_line, gfill)
if trade.tp2_hit
linefill.new(tp1_line, tp2_line, gfill)
if trade.tp3_hit
linefill.new(tp2_line, tp3_line, gfill)
if trade.tp4_hit
linefill.new(tp3_line, tp4_line, gfill)
if trade.sl_hit
linefill.new(sl_line, entry_line, rfill)
if trade.force_closed
close_line := line.new(trade.start_bar_index, trade.close_price, bar_index, trade.close_price, color=color.white, style = line_dot, width = 2)
if trade.profit <= 0
linefill.new(close_line,entry_line, rfill)
if trade.is_closed
dep := (trade.profit / 100 * dep) + dep
label.delete(entry_label)
label.delete(sl_label)
label.delete(tp1_label)
label.delete(tp2_label)
label.delete(tp3_label)
label.delete(tp4_label)
total_profit += trade.profit
trade_count += 1
if trade.profit >= 0
profit_trades += 1
wins_in_a_row += 1
loss_in_a_row := 0
win_streak := wins_in_a_row > win_streak ? wins_in_a_row : win_streak
else
loss_trades += 1
loss_in_a_row += 1
wins_in_a_row := 0
loss_streak := loss_in_a_row > loss_streak ? loss_in_a_row : loss_streak
trade := na
//
// <7>:<<5>>Logic 1 [End]}
// <7>:<<6>>Logic 2 [Start]{
if can_long or can_short and na(trade)
first_trade_date := trade_count == 0 ? timestamp(year, month, dayofmonth, hour, minute) : first_trade_date
trade := Trade.new()
trade.side := can_long ? "LONG" : "SHORT"
trade.entry_price := close
trade.entry_hit := true
trade.sl_price := math.round_to_mintick(can_long ? fixed_stop ? trade.entry_price * (1 - sl_percent) : fib_786 * (1 - sl_percent) : fixed_stop ? trade.entry_price * (1 + sl_percent) : fib_236 * (1 + sl_percent))
trade.tp1_price := math.round_to_mintick(can_long ? trade.entry_price * (1 + tp1_percent) : trade.entry_price * (1 - tp1_percent))
trade.tp1_percent_fix := tp1_percent_fix * 100
trade.tp2_price := math.round_to_mintick(can_long ? trade.entry_price * (1 + tp2_percent) : trade.entry_price * (1 - tp2_percent))
trade.tp2_percent_fix := tp2_percent_fix * 100
trade.tp3_price := math.round_to_mintick(can_long ? trade.entry_price * (1 + tp3_percent) : trade.entry_price * (1 - tp3_percent))
trade.tp3_percent_fix := tp3_percent_fix * 100
trade.tp4_price := math.round_to_mintick(can_long ? trade.entry_price * (1 + tp4_percent) : trade.entry_price * (1 - tp4_percent))
trade.tp4_percent_fix := tp4_percent_fix * 100
trade.break_even_price := switch break_even_target
"1" => trade.tp1_price
"2" => trade.tp2_price
"3" => trade.tp3_price
"WITHOUT" => trade.tp4_price
trade.risk_percent := risk_percent
trade.risk_reward := calc_rr(trade.entry_price, trade.sl_price, trade.tp4_price)
trade.start_bar_index := bar_index
alert_message = "\n{\n" + " \"side\": \"" + str.tostring(trade.side) + "\",\n \"entry\": \"" + str.tostring(trade.entry_price) + "\",\n \"tp1\": \"" + str.tostring(trade.tp1_price) + "\",\n \"tp2\": \"" + str.tostring(trade.tp2_price) + "\",\n \"tp3\": \"" + str.tostring(trade.tp3_price) + "\",\n \"tp4\": \"" + str.tostring(trade.tp4_price) + "\",\n \"winrate\": \"" + str.tostring(RoundUp(profit_trades / trade_count * 100, 2)) + "%" + "\",\n \"strategy\": \"" + strategy_input + "\",\n \"beTargetTrigger\": \"" + break_even_target + "\",\n \"stop\": \"" + str.tostring(trade.sl_price) + "\"\n}\n"
alert(alert_message, alert.freq_once_per_bar_close)
//Plot Long/Short Positions
if show_tp_enty_sl
entry_line := line.new(trade.start_bar_index, trade.entry_price, bar_index, trade.entry_price, color=en_col, style = line_sol, width = 2)
entry_label := label.new(bar_index, trade.entry_price, str.tostring(trade.entry_price), style = lb_left, color = pos_lb_col, textcolor = color.gray)
sl_line := line.new(trade.start_bar_index, trade.sl_price, bar_index, trade.sl_price, color=sl_col, style = line_dot, width = 2)
sl_label := label.new(bar_index, trade.sl_price, str.tostring(trade.sl_price), style = lb_left, color = pos_lb_col, textcolor = red)
tp1_line := line.new(trade.start_bar_index, trade.tp1_price, bar_index, trade.tp1_price, color=tp_col, style = line_dot, width = 2)
tp1_label := label.new(bar_index, trade.tp1_price, str.tostring(trade.tp1_price), style = lb_left, color = pos_lb_col, textcolor = green)
tp2_line := line.new(trade.start_bar_index, trade.tp2_price, bar_index, trade.tp2_price, color=tp_col, style = line_dot, width = 2)
tp2_label := label.new(bar_index, trade.tp2_price, str.tostring(trade.tp2_price), style = lb_left, color = pos_lb_col, textcolor = green)
tp3_line := line.new(trade.start_bar_index, trade.tp3_price, bar_index, trade.tp3_price, color=tp_col, style = line_dot, width = 2)
tp3_label := label.new(bar_index, trade.tp3_price, str.tostring(trade.tp3_price), style = lb_left, color = pos_lb_col, textcolor = green)
tp4_line := line.new(trade.start_bar_index, trade.tp4_price, bar_index, trade.tp4_price, color=tp_col, style = line_dot, width = 2)
tp4_label := label.new(bar_index, trade.tp4_price, str.tostring(trade.tp4_price), style = lb_left, color = pos_lb_col, textcolor = green)
lable_at_signal := label.new(bar_index, is_long_trend ? trade.tp4_price * 1.004 : trade.tp4_price * 0.996, "", style = label.style_label_center, textcolor = color.white)
//
// <7>:<<6>>Logic 2 [End]}
// SECTION <7> [End]}
// SECTION <8> title : "Plots"
// SECTION <8> note : This section has the plots.
// SECTION <8> subsection : <<1>>Shapes and Trendline, <<2>>Algo Report Label, <<3>>Profit Label, <<4>>Strategy Panel, <<5>>CTRLs
// SECTION <8> [Start]{
//<8>:<<1>>Shapes and Trendline [Start]{
plotshape(is_long_trend and is_long_trend_started ? imba_trend_line : na, "Long", shape.triangleup, location.belowbar, green, size=size.small)
plotshape(is_short_trend and is_short_trend_started ? imba_trend_line : na, "Short", shape.triangledown, location.abovebar, red, size=size.small)
plot(tl_plot ? imba_trend_line : na , "TrendLine", is_long_trend[1] ? green : red, 3)
//<8>:<<1>>Shapes and Trendline [End]}
//<8>:<<2>>Algo Report Label [Start]{
lim = "-------------------------------------------------------"
high_idk = "╔════════════════════════════╗"
low_idk = "╚════════════════════════════╝"
panel_str1 = high_idk + "\n" + "[TLF] ALGO" + "\n" + low_idk
panel_str13 = "First signal: " + str.format("{0,date,hh:mm} {0,date,long}", first_trade_date) + "\n" + lim
panel_str14 = "Signal closed: " + str.tostring(trade_count) + " " + "Winrate: " + str.tostring(RoundUp(profit_trades / trade_count * 100, 2)) + "%"
panel_str15 = "Profit signals: " + str.tostring(profit_trades) + " " + "Loss signals: " + str.tostring(trade_count - profit_trades)
panel_str16 = "Win streak: " + str.tostring(win_streak) + " " + "Loss streak: " + str.tostring(loss_streak) + "\n" + lim
panel_str17 = "💰 Profit: " + str.tostring(total_profit, "#.##") + "% 💰"
panel_last = "╚════════════════════════════╝"
panel_str_arr = array.from(panel_str1, panel_str13, panel_str14, panel_str15, panel_str16, panel_str17, panel_last)
if show_old_panel
label l = label.new(bar_index + 20, close, text=array.join(panel_str_arr, "\n"), color=tbl_gb, style=lb_left, textcolor=color.rgb(76, 187, 72),textalign=text.align_center)
label.delete(l[1])
//
//<8>:<<2>>Algo Report Label [End]}
//<8>:<<3>>Profit Label [Start]{
var table profit_table = na
if show_profit_panel
profit_table := table.new(position.top_right, 3, 10, border_color = green, border_width = 0)
table.cell(profit_table, 0, 0, "═════════════════════════════" + "\n" + "[TLF] ALGO" + "\n" + "═════════════════════════════", bgcolor = tbl_gb, text_color = green, width = 6, height = 5, text_size = size.normal)
table.cell(profit_table, 1, 0, "", bgcolor = tbl_gb, text_color = green, width = 6, height = 3, text_size = size.normal)
table.merge_cells(profit_table, 0,0,1,0)
table.cell(profit_table, 0, 1, "First trade:", bgcolor = tbl_gb, text_color = green, width = 8, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(profit_table, 1, 1, str.format("{0,date,hh:mm} {0,date,long}", first_trade_date), bgcolor = tbl_gb, text_color = green, width = 8, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 2, "Total trades:", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(profit_table, 1, 2, str.tostring(trade_count), bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 3, "Profit trades:", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(profit_table, 1, 3, str.tostring(profit_trades), bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 4, "Loss trades:", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(profit_table, 1, 4, str.tostring(loss_trades), bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 5, "Winrate:", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(profit_table, 1, 5, str.tostring(RoundUp(profit_trades / trade_count * 100, 2)) + "%", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 6, "Win streak:", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(profit_table, 1, 6, str.tostring(win_streak), bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 7, "Loss streak:", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(profit_table, 1, 7, str.tostring(loss_streak), bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 8, "Deposit: ", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(profit_table, 1, 8, str.tostring(dep, "##.##"), bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 9, "═════════════════════════════" + "\n" + "💰 Profit: " + str.tostring(total_profit, "#.##") + "% 💰" + "\n" + "═════════════════════════════", bgcolor = tbl_gb, text_color = green, width = 5, height = 10, text_size = size.normal, text_halign = text.align_center, text_valign = text.align_top)
table.cell(profit_table, 1, 9,"", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.merge_cells(profit_table, 0, 9, 1, 9)
//
//<8>:<<3>>Profit Label [End]}
//<8>:<<4>>Strategy Panel [Start]{
var table strategy_table = na
if show_strategy_panel
strategy_table := table.new(position.bottom_right, 5, 6, border_color = green)
table.cell(strategy_table, 1, 0, "══════════════════════════════════════════" + "\n" + syminfo.ticker + " " + timeframe.period + " | WR: " + str.tostring(profit_trades / (profit_trades + (trade_count - profit_trades)) * 100, "##,##") + "%" + " | TT: " + str.tostring(trade_count) + " | P: " + str.tostring(total_profit, "#.##") + "%" + "\n" + "══════════════════════════════════════════", bgcolor = tbl_gb, text_color = green, width = 6, height = 7, text_size = size.normal, text_valign = text.align_bottom)
table.cell(strategy_table, 2, 0, "", bgcolor = tbl_gb, text_color = green, width = 6, height = 3, text_size = size.normal)
table.cell(strategy_table, 3, 0, "", bgcolor = tbl_gb, text_color = green, width = 6, height = 3, text_size = size.normal)
table.cell(strategy_table, 4, 0, "", bgcolor = tbl_gb, text_color = green, width = 6, height = 3, text_size = size.normal)
table.merge_cells(strategy_table, 1,0,4,0)
table.cell(strategy_table, 1, 1, "Strategy:", bgcolor = tbl_gb, text_color = green, width = 6, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(strategy_table, 2, 1, strategy_input, bgcolor = tbl_gb, text_color = green, width = 6, height = 3, text_size = size.normal)
table.cell(strategy_table, 1, 2, "Sensitivity:", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(strategy_table, 2, 2, str.tostring(sensitivity / 10), bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 1, 3, "Risk:", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(strategy_table, 2, 3, str.tostring(risk_percent) + "%", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 1, 4, "BE target:", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(strategy_table, 2, 4, str.tostring(break_even_target), bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 1, 5, "Fixed stop:", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal, text_halign = txt_left)
table.cell(strategy_table, 2, 5, str.tostring(fixed_stop), bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 3, 1, "TP1:", bgcolor = tbl_gb, text_color = green, width = 4, height = 3, text_size = size.normal)
table.cell(strategy_table, 4, 1, str.tostring(tp1_percent * 100) + "%" + " (" + str.tostring(tp1_percent_fix * 100) + "%)", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 3, 2, "TP2:", bgcolor = tbl_gb, text_color = green, width = 4, height = 3, text_size = size.normal)
table.cell(strategy_table, 4, 2, str.tostring(tp2_percent * 100) + "%" + " (" + str.tostring(tp2_percent_fix * 100) + "%)", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 3, 3, "TP3:", bgcolor = tbl_gb, text_color = green, width = 4, height = 3, text_size = size.normal)
table.cell(strategy_table, 4, 3, str.tostring(tp3_percent * 100) + "%" + " (" + str.tostring(tp3_percent_fix * 100) + "%)", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 3, 4, "TP4:", bgcolor = tbl_gb, text_color = green, width = 4, height = 3, text_size = size.normal)
table.cell(strategy_table, 4, 4, str.tostring(tp4_percent * 100) + "%" + " (" + str.tostring(tp4_percent_fix * 100) + "%)", bgcolor = tbl_gb, text_color = green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 3, 5, "Stop:", bgcolor = tbl_gb, text_color = green, width = 4, height = 3, text_size = size.normal)
table.cell(strategy_table, 4, 5, str.tostring(sl_percent * 100) + "%", bgcolor = tbl_gb, text_color = green, width = 8, height = 3, text_size = size.normal)
//
//<8>:<<4>>Strategy Panel [End]}
//<8>:<<5>>CTRLs [Start]{
plot(dep, "Equity", color.white, display = dw_Y)
//<8>:<<5>>CTRLs [End]}
// SECTION <8> [End]}