forked from gbzenobi/CSharp-NT8-OrderFlowKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bookmap.cs
1597 lines (1452 loc) · 78 KB
/
Bookmap.cs
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
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#region Using declarations
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Gui;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Gui.SuperDom;
using NinjaTrader.Gui.Tools;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
using NinjaTrader.NinjaScript.AddOns.SightEngine;
using NinjaTrader.NinjaScript.AddOns.WyckoffRenderUtils;
public static class _BookMapEnums
{
public enum LadderRange
{
Levels10,
Levels30,
Levels50,
Levels70
}
public enum MarketOrdersCalculation
{
Delta,
Total,
}
public enum MarketBarsCalculation
{
EachTick,
Cummulative,
}
public enum MarketCummulativeCalculation
{
BidAndAsk,
DeltaAndTotal
}
}
namespace NinjaTrader.NinjaScript.Indicators.WyckoffZen
{
public class Bookmap : Indicator
{
#region MAIN_CLASS
public int getLadderRange(_BookMapEnums.LadderRange ladderRange)
{
switch(ladderRange)
{
//case _BookMapEnums.LadderRange.Default10Levels:
//return 10;
case _BookMapEnums.LadderRange.Levels30:
return 30;
case _BookMapEnums.LadderRange.Levels50:
return 50;
case _BookMapEnums.LadderRange.Levels70:
return 70;
}
return 10;
}
public class WyckoffBookMap : WyckoffRenderControl
{
#region DEFS
private VolumeAnalysis.BookMap bookMap;
private VolumeAnalysis.WyckoffBars wyckoffBars;
private VolumeAnalysis.WyckoffBars.Bar currentBar;
private VolumeAnalysis.PriceLadder cummulativeMarketOrderLadder;
private VolumeAnalysis.OrderBookLadder cummulativeOrderBookLadder;
private VolumeAnalysis.MarketOrder maxMarketOL;
private VolumeAnalysis.MarketOrder minMarketOL;
private SharpDX.RectangleF ordersBookRect;
private SharpDX.RectangleF marketOrdersRect;
private SharpDX.RectangleF cummulativeBookRect;
private SharpDX.RectangleF backgroundRect;
private SharpDX.Vector2 background_StVerticalVec;
private SharpDX.Vector2 background_EndVerticalVec;
private SharpDX.Direct2D1.Ellipse marketOrdersCircle;
private SharpDX.RectangleF genRect;
private SharpDX.Color colorBidPendingOrdersColor;
private SharpDX.Color colorAskPendingOrdersColor;
private SharpDX.Color colorBidMarketOrdersColor;
private SharpDX.Color colorAskMarketOrdersColor;
private SharpDX.Color colorBidPendingOrdersTextColor;
private SharpDX.Color colorBidMarketOrdersTextColor;
private SharpDX.Color colorAskPendingOrdersTextColor;
private SharpDX.Color colorAskMarketOrdersTextColor;
private SharpDX.Color colorTotalMarketOrdersColor;
private SharpDX.Color colorTotalMarketOrdersFontColor;
private SharpDX.Color colorBigPendingOrdersColor;
private SharpDX.Color colorBidMarketCummulativeColor;
private SharpDX.Color colorAskMarketCummulativeColor;
private SharpDX.Color colorTotalMarketCummulativeColor;
private SharpDX.Color colorBidMarketCummulativeTextColor;
private SharpDX.Color colorAskMarketCummulativeTextColor;
private SharpDX.Color colorTotalMarketCummulativeTextColor;
private SharpDX.Color colorBidOrderBookColor;
private SharpDX.Color colorAskOrderBookColor;
private SharpDX.Color colorBidOrderBookTextColor;
private SharpDX.Color colorAskOrderBookTextColor;
private SharpDX.Color colorBackgroundColor;
private SharpDX.Color colorVerticalLinesColor;
private SharpDX.DirectWrite.TextFormat bookmapTextFormat, cummulativeTextFormat, orderbookTextFormat;
private Action<float, float, Brush, float, float, float> renderGeometry;
private Action<int, double, long> renderMarketOrder;
private Action<double, VolumeAnalysis.MarketOrder, long> renderCummulative;
private float filterPendingOrdersPer, filterTextPendingOrdersPer;
private long filterAggresiveMarketOrders;
private long filterBigPendingOrders;
private float bidPendingOrdersTextOpacity;
private float askPendingOrdersTextOpacity;
private float bidMarketOrdersTextOpacity;
private float askMarketOrdersTextOpacity;
private float totalMarketOrdersTextOpacity;
//private float askMarketOrdersOpacity;
//private float bidMarketOrdersOpacity;
private float bigPendingOrdersOpacity;
private float bidOrderBookOpacity;
private float askOrderBookOpacity;
private float bidOrderBookTextOpacity;
private float askOrderBookTextOpacity;
private float backgroundOpacity;
// private float verticalLinesOpacity;
private float bidMarketCummulativeTextOpacity;
private float askMarketCummulativeTextOpacity;
private float totalMarketCummulativeTextOpacity;
private float bookmapMinFontWidth;
private float bookmapMinFontHeight;
private float cummulativeBookMinFontWidth;
private float cummulativeBookMinFontHeight;
private float orderBookMinFontWidth;
private float orderBookMinFontHeight;
private float barX;
private float barY;
private double TickSize;
private int marginRight;
private bool showMarketOrdersText;
private bool isRealtime;
bool saveSession;
bool loadSession;
string sessionFilePath;
#endregion
public WyckoffBookMap()
{
this.genRect = new SharpDX.RectangleF();
this.ordersBookRect = new SharpDX.RectangleF();
this.marketOrdersRect= new SharpDX.RectangleF();
this.cummulativeBookRect = new SharpDX.RectangleF();
this.marketOrdersCircle = new SharpDX.Direct2D1.Ellipse();
this.background_StVerticalVec = new SharpDX.Vector2();
this.background_EndVerticalVec = new SharpDX.Vector2();
this.backgroundRect = new SharpDX.RectangleF();
this.maxMarketOL = new VolumeAnalysis.MarketOrder();
this.minMarketOL = new VolumeAnalysis.MarketOrder();
this.isRealtime = false;
}
#region BOOK_MAP_SETS
public void setBookMap(VolumeAnalysis.BookMap bookMap)
{
this.bookMap = bookMap;
}
public void setWyckoffBars(VolumeAnalysis.WyckoffBars wyckoffBars)
{
this.wyckoffBars = wyckoffBars;
this.TickSize = wyckoffBars.TickSize;
}
public void setCummulativeMarketOrdersLadder(VolumeAnalysis.PriceLadder cummulativeMarketOrderLadder)
{
this.cummulativeMarketOrderLadder= cummulativeMarketOrderLadder;
}
public void setOrderBookLadder(VolumeAnalysis.OrderBookLadder cummulativeOrderBookLadder)
{
this.cummulativeOrderBookLadder = cummulativeOrderBookLadder;
}
public void setDatabaseSession(bool saveSession, bool loadSession, string sessionFilePath)
{
this.saveSession= saveSession;
this.loadSession= loadSession;
this.sessionFilePath = sessionFilePath;
}
public void setBookmapFontStyle(SimpleFont font)
{
setFontStyle(font, out this.bookmapTextFormat);
}
public void setCummulativeBookFontStyle(SimpleFont font)
{
setFontStyle(font, out this.cummulativeTextFormat);
}
public void setOrderBookFontStyle(SimpleFont font)
{
setFontStyle(font, out this.orderbookTextFormat);
}
public void setBackgroundColor(Brush brushBackgroundColor, float opacity)
{
this.colorBackgroundColor = WyckoffRenderControl.BrushToColor(brushBackgroundColor);
this.backgroundOpacity = opacity / 100.0f;
}
public void setVerticalLinesColor(Brush brushVerticalLinesColor)//, float opacity)
{
this.colorVerticalLinesColor = WyckoffRenderControl.BrushToColor(brushVerticalLinesColor);
//this.verticalLinesOpacity = opacity;
}
public void setBidAskPendingOrdersColor(Brush brushBidPendingOrdersColor, Brush brushAskPendingOrdersColor)
{
this.colorBidPendingOrdersColor = WyckoffRenderControl.BrushToColor(brushBidPendingOrdersColor);
this.colorAskPendingOrdersColor = WyckoffRenderControl.BrushToColor(brushAskPendingOrdersColor);
}
public void setBidAskPendingOrdersFontColor(
Brush brushBidPendingOrdersTextColor, float bidOpacity,
Brush brushAskPendingOrdersTextColor, float askOpacity)
{
this.colorBidPendingOrdersTextColor = WyckoffRenderControl.BrushToColor(brushBidPendingOrdersTextColor);
this.bidPendingOrdersTextOpacity = bidOpacity / 100f;
this.colorAskPendingOrdersTextColor = WyckoffRenderControl.BrushToColor(brushAskPendingOrdersTextColor);
this.askPendingOrdersTextOpacity = askOpacity / 100f;
}
public void setBidAskMarketOrdersColor(Brush brushBidMarketOrdersColor, Brush brushAskMarketOrdersColor)
{
this.colorBidMarketOrdersColor = WyckoffRenderControl.BrushToColor(brushBidMarketOrdersColor);
this.colorAskMarketOrdersColor = WyckoffRenderControl.BrushToColor(brushAskMarketOrdersColor);
}
public void setBidAskMarketOrdersFontColor(
Brush brushBidMarketOrdersTextColor, float bidOpacity,
Brush brushAskMarketOrdersTextColor, float askOpacity)
{
this.colorBidMarketOrdersTextColor = WyckoffRenderControl.BrushToColor(brushBidMarketOrdersTextColor);
this.bidMarketOrdersTextOpacity = bidOpacity / 100f;
this.colorAskMarketOrdersTextColor = WyckoffRenderControl.BrushToColor(brushAskMarketOrdersTextColor);
this.askMarketOrdersTextOpacity = askOpacity / 100f;
}
public void setTotalMarketOrdersColor(Brush brushTotalMarketOrdersColor)
{
this.colorTotalMarketOrdersColor= WyckoffRenderControl.BrushToColor(brushTotalMarketOrdersColor);
}
public void setTotalMarketOrdersFontColor(Brush brushTotalMarketOrdersFontColor, float opacity)
{
this.colorTotalMarketOrdersFontColor = WyckoffRenderControl.BrushToColor(brushTotalMarketOrdersFontColor);
this.totalMarketOrdersTextOpacity = opacity / 100.0f;
}
public void setBigPendingOrdersColor(Brush brushBigPendingOrdersColor, float opacity)
{
this.colorBigPendingOrdersColor = WyckoffRenderControl.BrushToColor(brushBigPendingOrdersColor);
this.bigPendingOrdersOpacity = opacity / 100f;
}
public void setFilterPendingOrders(float filterPendingOrdersPer, float filterTextPendingOrdersPer)
{
this.filterPendingOrdersPer= filterPendingOrdersPer / 100f;
this.filterTextPendingOrdersPer= filterTextPendingOrdersPer / 100f;
}
public void setFilterBigPendingOrders(long filterBigPendingOrders)
{
this.filterBigPendingOrders = filterBigPendingOrders;
}
public void setFilterAggresiveMarketOrders(long filterAggresiveMarketOrders)
{
this.filterAggresiveMarketOrders= filterAggresiveMarketOrders;
}
public void setMarginRight(int marginRight)
{
this.marginRight = marginRight;
}
public void setBookmapMinSizeFont(float minFontWidth, float minFontHeight)
{
this.bookmapMinFontWidth = minFontWidth;
this.bookmapMinFontHeight = minFontHeight;
}
public void setOrderBookMinSizeFont(float minFontWidth, float minFontHeight)
{
this.orderBookMinFontWidth = minFontWidth;
this.orderBookMinFontHeight= minFontHeight;
}
public void setCummulativeBookMinSizeFont(float minFontWidth, float minFontHeight)
{
this.cummulativeBookMinFontWidth = minFontWidth;
this.cummulativeBookMinFontHeight= minFontHeight;
}
public void setShowMarketOrdersText(bool showText)
{
this.showMarketOrdersText = showText;
}
public void setRealtime(bool isRealtime)
{
this.isRealtime = isRealtime;
}
public bool IsRealtime
{
get{ return this.isRealtime; }
}
public void setMarketOrdersCalculation(
_BookMapEnums.MarketOrdersCalculation marketOrdersCalculation,
_BookMapEnums.MarketBarsCalculation marketBarsCalculation
)
{
switch(marketOrdersCalculation)
{
case _BookMapEnums.MarketOrdersCalculation.Delta:
{
switch( marketBarsCalculation ){
case _BookMapEnums.MarketBarsCalculation.EachTick:
{
this.renderMarketOrder = this.__renderDeltaMarketOrders;
break;
}
case _BookMapEnums.MarketBarsCalculation.Cummulative:
{
this.renderMarketOrder = this.__renderDeltaMarketOrder;
break;
}
}
break;
}
case _BookMapEnums.MarketOrdersCalculation.Total:
{
switch( marketBarsCalculation ){
case _BookMapEnums.MarketBarsCalculation.EachTick:
{
this.renderMarketOrder = __renderTotalMarketOrders;
break;
}
case _BookMapEnums.MarketBarsCalculation.Cummulative:
{
this.renderMarketOrder = __renderTotalMarketOrder;
break;
}
}
break;
}
}
}
#endregion
#region BOOK_CUMMULATIVE_STYLE_SETS
public void setBidAskMarketCummulativeColor(Brush brushBidMarketCummulativeColor, Brush brushAskMarketCummulativeColor)
{
this.colorBidMarketCummulativeColor = WyckoffRenderControl.BrushToColor(brushBidMarketCummulativeColor);
this.colorAskMarketCummulativeColor = WyckoffRenderControl.BrushToColor(brushAskMarketCummulativeColor);
}
public void setTotalMarketCummulativeColor(Brush brushTotalMarketCummulativeColor)
{
this.colorTotalMarketCummulativeColor = WyckoffRenderControl.BrushToColor(brushTotalMarketCummulativeColor);
}
public void setBidAskMarketCummulativeFontColor(
Brush brushBidMarketCummulativeTextColor, float bidOpacity,
Brush brushAskMarketCummulativeTextColor, float askOpacity,
Brush brushTotalMarketCummulativeTextColor, float totalOpacity)
{
this.colorBidMarketCummulativeTextColor = WyckoffRenderControl.BrushToColor(brushBidMarketCummulativeTextColor);
this.bidMarketCummulativeTextOpacity = bidOpacity / 100f;
this.colorAskMarketCummulativeTextColor = WyckoffRenderControl.BrushToColor(brushAskMarketCummulativeTextColor);
this.askMarketCummulativeTextOpacity = askOpacity / 100f;
this.colorTotalMarketCummulativeTextColor = WyckoffRenderControl.BrushToColor(brushTotalMarketCummulativeTextColor);
this.totalMarketCummulativeTextOpacity = totalOpacity / 100f;
}
#endregion
#region ORDER_BOOK_STYLE_SETS
public void setBidAskOrderBookColor(
Brush brushBidOrderBookColor, float bidOpacity,
Brush brushAskOrderBookColor, float askOpacity)
{
this.colorBidOrderBookColor = WyckoffRenderControl.BrushToColor(brushBidOrderBookColor);
this.bidOrderBookOpacity = bidOpacity / 100f;
this.colorAskOrderBookColor = WyckoffRenderControl.BrushToColor(brushAskOrderBookColor);
this.askOrderBookOpacity = askOpacity / 100f;
}
public void setBidAskOrderBookFontColor(
Brush brushBidOrderBookTextColor, float bidOpacity,
Brush brushAskOrderBookTextColor, float askOpacity)
{
this.colorBidOrderBookTextColor = WyckoffRenderControl.BrushToColor(brushBidOrderBookTextColor);
this.bidOrderBookTextOpacity = bidOpacity / 100f;
this.colorAskOrderBookTextColor = WyckoffRenderControl.BrushToColor(brushAskOrderBookTextColor);
this.askOrderBookTextOpacity = askOpacity / 100f;
}
#endregion
#region RENDER_MARKET_ORDERS
private void renderMarketBar(float X, float Y, SharpDX.Color color, long volume, float opacity)
{
if( volume >= this.filterAggresiveMarketOrders ){
marketOrdersCircle.Point.X = X;
marketOrdersCircle.Point.Y = Y;
marketOrdersCircle.RadiusX = this.W;
marketOrdersCircle.RadiusY = this.H;
// !- multiplicando*10 el filtro de volumen configurado por el usuario garantizamos
// que el porcentaje de opacidad parta de 100%(0,1f) en adelante para que el color sea maximo
// deberia alcanzar con esta formula el 1000%
float aggresivePer = (float)(Math2.Percent(this.filterAggresiveMarketOrders * 10, volume) / 100.0f);
//Target.DrawEllipse(marketOrdersCircle, brush.ToDxBrush(Target, aggresivePer), 2.0f);
//Target.FillEllipse(marketOrdersCircle, brush.ToDxBrush(Target, aggresivePer));
myDrawEllipse(ref marketOrdersCircle, color, aggresivePer, 2.0f);
myFillEllipse(ref marketOrdersCircle, color, aggresivePer);
//return;
// !- no dejamos que sobrepase el maximo para el rect
//volume = this.filterAggresiveMarketOrders;
return;
}
float per= (float)Math2.Percent(this.filterAggresiveMarketOrders, volume) / 100f;//volume / this.filterAggresiveMarketOrders;
// !- setup y renderizado de las ordenes agresivas
marketOrdersRect.X = X - (this.W / 2f) * per;
marketOrdersRect.Y = Y - (this.H / 2f);
marketOrdersRect.Width = this.W * per;
marketOrdersRect.Height = this.H;
myFillRectangle(ref marketOrdersRect, color, opacity);
myDrawRectangle(ref marketOrdersRect, color, 0.7f, 2.0f);
}
// private void __renderCummulativeText(string volumeText, Brush brushColor, float brushOpacity)
// {
// if( this.W >= this.cummulativeBookMinFontWidth && this.H >= this.cummulativeBookMinFontHeight ){
// Target.DrawText(volumeText,
// this.cummulativeTextFormat, this.genRect,
// brushColor.ToDxBrush(Target, brushOpacity));
// }
// }
private void renderDeltaVolume(double price, long D, long maxOrderVolume)
{
long vol = Math.Abs(D);
float priceOpacity = (float)Math2.Percent(maxOrderVolume, vol) / 100.0f;
float barY = CHART_SCALE.GetYByValue(price);
float h = this.H / 2f;
this.genRect.Y = barY - h;
if( D >= 0 ){
this.renderMarketBar(this.barX, barY, colorAskMarketOrdersColor, vol, priceOpacity);
if( this.showMarketOrdersText ){
if( vol != 0 )
this.myDrawText(vol.ToString(), ref this.genRect, colorAskMarketOrdersTextColor, bookmapMinFontWidth, bookmapMinFontHeight, bookmapTextFormat, askMarketOrdersTextOpacity);
}
}
else{
this.renderMarketBar(this.barX, barY, colorBidMarketOrdersColor, vol, priceOpacity);
if( this.showMarketOrdersText ){
if( vol != 0 )
this.myDrawText(vol.ToString(), ref this.genRect, colorBidMarketOrdersTextColor, bookmapMinFontWidth, bookmapMinFontHeight, bookmapTextFormat, bidMarketOrdersTextOpacity);
}
}
}
private void renderTotalVolume(double price, long T, long maxOrderVolume)
{
float priceOpacity = (float)Math2.Percent(maxOrderVolume, T) / 100.0f;
float barY = CHART_SCALE.GetYByValue(price);
this.renderMarketBar(this.barX, barY, colorTotalMarketOrdersColor, T, priceOpacity);
if( this.showMarketOrdersText ){
this.genRect.Y = barY - this.H / 2f;
this.myDrawText(T.ToString(), ref this.genRect, colorTotalMarketOrdersFontColor, bookmapMinFontWidth, bookmapMinFontHeight, bookmapTextFormat, totalMarketOrdersTextOpacity);
}
}
private void __renderDeltaMarketOrders(int barIndex, double marketPrice, long maxOrderVolume)
{
//long D = this.wyckoffBars[barIndex].Delta; //this.wyckoffBars[barIndex].AtPrice(marketPrice).Delta;
VolumeAnalysis.WyckoffBars.Bar wbar = this.wyckoffBars[barIndex];
foreach(var bar in wbar){
renderDeltaVolume(bar.Key, bar.Value.Delta, maxOrderVolume);
}
}
private void __renderDeltaMarketOrder(int barIndex, double marketPrice, long maxOrderVolume)
{
renderDeltaVolume(marketPrice, this.wyckoffBars[barIndex].Delta, maxOrderVolume);
}
private void __renderTotalMarketOrder(int barIndex, double marketPrice, long maxOrderVolume)
{
renderTotalVolume(marketPrice,this.wyckoffBars[barIndex].Total, maxOrderVolume);
}
private void __renderTotalMarketOrders(int barIndex, double marketPrice, long maxOrderVolume)
{
VolumeAnalysis.WyckoffBars.Bar wbar = this.wyckoffBars[barIndex];
foreach(var bar in wbar){
renderTotalVolume(bar.Key, bar.Value.Total, maxOrderVolume);
}
}
#endregion
#region RENDER_CUMMULATIVE
private void __renderCummulativeBidAndAsk(double price, VolumeAnalysis.MarketOrder marketOrderFlow, long maxMarketTotal)
{
long currBid = marketOrderFlow.Bid;
long currAsk = marketOrderFlow.Ask;
float maxVolumeTotalPercent = (float)Math2.Percent(maxMarketTotal, marketOrderFlow.Total) / 100f;
float maxVolumeBidPercent = (float)Math2.Percent(maxMarketTotal, currBid) / 100f;
float maxVolumeAskPercent = (float)Math2.Percent(maxMarketTotal, currAsk) / 100f;
float half_margin_right = this.marginRight / 2f;
// !- valores generales
this.cummulativeBookRect.X = this.PanelW - half_margin_right + (this.W / 2f);
this.cummulativeBookRect.Y = CHART_SCALE.GetYByValue(price) - (this.H / 2f);
this.cummulativeBookRect.Height = this.H;
this.genRect.Y = cummulativeBookRect.Y;
this.genRect.Height = this.H;
// !- render total
// this.cummulativeBookRect.Width = half_margin_right * maxVolumeTotalPercent;
// Target.FillRectangle(cummulativeBookRect, brushTotalMarketCummulativeColor.ToDxBrush(Target, maxVolumeTotalPercent));
// !- ordenes de capa de dibujo, evitamos que se tapen
// if( maxVolumeBidPercent >= maxVolumeAskPercent ){
// !- render Bid
this.cummulativeBookRect.Width = half_margin_right * maxVolumeBidPercent;
/*Target.FillRectangle(cummulativeBookRect,
colorBidMarketCummulativeColor.ToDxBrush(Target, maxVolumeBidPercent)
);*/
myFillRectangle(ref cummulativeBookRect, colorBidMarketCummulativeColor, maxVolumeBidPercent);
// !- render Ask
this.cummulativeBookRect.Width = half_margin_right * maxVolumeAskPercent;
myFillRectangle(ref cummulativeBookRect, colorAskMarketCummulativeColor, maxVolumeBidPercent);
if( this.W >= (half_margin_right - 45f) )
return;
/// !- render Bid text
this.genRect.X = this.PanelW - this.marginRight + (this.W / 2f) + 3f;
this.genRect.Width = this.marginRight + (this.W / 2f);
this.myDrawText(currBid.ToString(), ref this.genRect, colorBidMarketCummulativeTextColor,
this.cummulativeBookMinFontWidth, this.cummulativeBookMinFontHeight,
this.cummulativeTextFormat, bidMarketCummulativeTextOpacity
);
/// !- render Ask text
this.genRect.X = this.PanelW - this.marginRight + 50f;
this.genRect.Width = this.marginRight + 50f;
this.myDrawText(currAsk.ToString(), ref this.genRect, colorAskMarketCummulativeTextColor,
this.cummulativeBookMinFontWidth, this.cummulativeBookMinFontHeight,
this.cummulativeTextFormat, this.askMarketCummulativeTextOpacity
);
}
private void __renderCummulativeDeltaAndTotal(double price, VolumeAnalysis.MarketOrder marketOrderFlow, long maxMarketTotal)
{
long currDelta = marketOrderFlow.Delta;
long currTotal = marketOrderFlow.Total;
//maxVolumePercent = (float)Math2.Percent(Math.Abs(maxMarketOF.Delta), Math.Abs(delta)) / 100f;
float maxVolumeDeltaPercent = (float)Math2.Percent(maxMarketTotal, Math.Abs(currDelta)) / 100f;
float maxVolumeTotalPercent = (float)Math2.Percent(maxMarketTotal, currTotal) / 100f;
float half_margin_right = this.marginRight / 2f;
bool isMaxMargin = this.W < (half_margin_right - 45f);
// !- valores generales
this.cummulativeBookRect.X = this.PanelW - half_margin_right + (this.W / 2f);
this.cummulativeBookRect.Y = CHART_SCALE.GetYByValue(price) - (this.H / 2f);
this.cummulativeBookRect.Height = this.H;
this.genRect.Y = cummulativeBookRect.Y;
this.genRect.Height = this.H;
// !- render total
this.cummulativeBookRect.Width = half_margin_right * maxVolumeTotalPercent;
myFillRectangle(ref cummulativeBookRect, colorTotalMarketCummulativeColor, 0.5f);
// !- render delta
this.cummulativeBookRect.Width = half_margin_right * maxVolumeDeltaPercent;
this.genRect.X = this.PanelW - this.marginRight + (this.W / 2f) + 5f;
this.genRect.Width = this.marginRight + (this.W / 2f);
if( currDelta >= 0 ){
myFillRectangle(ref cummulativeBookRect, colorAskMarketCummulativeColor, 1.0f);
if( isMaxMargin ){
this.myDrawText(currDelta.ToString(), ref this.genRect, colorAskMarketCummulativeTextColor,
this.cummulativeBookMinFontWidth, this.cummulativeBookMinFontHeight,
this.cummulativeTextFormat, this.askMarketCummulativeTextOpacity
);
}
}
else{
myFillRectangle(ref cummulativeBookRect, colorBidMarketCummulativeColor, 1.0f);
if( isMaxMargin ){
this.myDrawText(currDelta.ToString(), ref this.genRect, colorBidMarketCummulativeTextColor,
this.cummulativeBookMinFontWidth, this.cummulativeBookMinFontHeight,
this.cummulativeTextFormat, bidMarketCummulativeTextOpacity
);
}
}
if( isMaxMargin ){
// !- render Total text
this.genRect.X = this.PanelW - this.marginRight + 50f;
this.genRect.Width = this.marginRight + 50f;
this.myDrawText(currTotal.ToString(), ref this.genRect, this.colorTotalMarketCummulativeTextColor,
this.cummulativeBookMinFontWidth, this.cummulativeBookMinFontHeight,
this.cummulativeTextFormat, this.totalMarketCummulativeTextOpacity
);
}
}
public void setMarketCummulativeCalculation(_BookMapEnums.MarketCummulativeCalculation marketCummulativeCalculation)
{
switch( marketCummulativeCalculation )
{
case _BookMapEnums.MarketCummulativeCalculation.BidAndAsk:
{
this.renderCummulative = this.__renderCummulativeBidAndAsk;
break;
}
case _BookMapEnums.MarketCummulativeCalculation.DeltaAndTotal:
{
this.renderCummulative = this.__renderCummulativeDeltaAndTotal;
break;
}
}
}
#endregion
private void renderPendingOrders(double price, long volume, VolumeAnalysis.OrderType orderType, float orderOpacity)
{
if( orderType == VolumeAnalysis.OrderType.Ask ){
if( this.filterBigPendingOrders != 0 && volume >= this.filterBigPendingOrders ){
//Target.FillRectangle(genRect, brushBigPendingOrdersColor.ToDxBrush(Target, (float)(Math2.Percent(this.filterBigPendingOrders*10, volume) / 100.0f)));
myFillRectangle(ref genRect, colorBigPendingOrdersColor, (float)((volume / this.filterBigPendingOrders)*bigPendingOrdersOpacity));
}
else{
myFillRectangle(ref genRect, colorAskPendingOrdersColor, orderOpacity);
}
// !- debemos saber el % para poder filtrar correctamente
if( orderOpacity > this.filterTextPendingOrdersPer ){
myDrawText(volume.ToString(), ref this.genRect, colorAskPendingOrdersTextColor, bookmapMinFontWidth, bookmapMinFontHeight, bookmapTextFormat, askPendingOrdersTextOpacity);
}
}
else if( orderType == VolumeAnalysis.OrderType.Bid ){
if( this.filterBigPendingOrders != 0 && volume >= this.filterBigPendingOrders ){
myFillRectangle(ref genRect, colorBigPendingOrdersColor, (float)((volume / this.filterBigPendingOrders)*bigPendingOrdersOpacity));
}
else{
myFillRectangle(ref genRect, colorBidPendingOrdersColor, orderOpacity);
}
// !- debemos saber el % para poder filtrar correctamente
if( orderOpacity > this.filterTextPendingOrdersPer ){
myDrawText(volume.ToString(), ref this.genRect, colorBidPendingOrdersTextColor, bookmapMinFontWidth, bookmapMinFontHeight, bookmapTextFormat, bidPendingOrdersTextOpacity);
}
}
}
public void renderOrdersLadder(int barIndex)
{
VolumeAnalysis.OrderBookLadder orderBookLadder = this.bookMap.getOrderBookLadder(barIndex);
if( orderBookLadder == null )
return;
long maxPendingOrderVolume = orderBookLadder.MaxOrderVolume;
this.barX = CHART_CONTROL.GetXByBarIndex(CHART_BARS, barIndex);
this.genRect.X = this.barX - (this.W / 2f);
this.genRect.Width = this.W;
this.genRect.Height = this.H;
VolumeAnalysis.OrderInfo orderInfo;
double price;
int bars = this.wyckoffBars.Count;
foreach(var order in orderBookLadder)
{
price = order.Key;
// !- no mostramos el nivel de la escalera de precios por donde el precio de mercado paso.
if( price == orderBookLadder.MarketPrice ){
// ! evitar error: The given key X was not present in the dictionary
if( bars > barIndex)//if( this.wyckoffBars.BarExists(barIndex) )
this.renderMarketOrder(barIndex, price, maxPendingOrderVolume);
continue;
}
long volume = order.Value.Volume;
float orderOpacity = (float)Math2.Percent(maxPendingOrderVolume, volume) / 100.0f;
if( orderOpacity >= this.filterPendingOrdersPer ){
this.genRect.Y = CHART_SCALE.GetYByValue(price) - this.H / 2f;
this.renderPendingOrders(order.Key, volume, order.Value.Type, orderOpacity);
}
}
}
/// !- Mostramos el libro de ordenes
public void renderOrderBookLadder()
{
if( cummulativeOrderBookLadder == null ){
return;
}
double price;
long maxOrder;
float maxOrderPercent;
VolumeAnalysis.OrderInfo orderInfo;
float half_margin_right = this.marginRight / 2f;
this.genRect.X = this.PanelW - this.marginRight + (this.W / 2f);
this.genRect.Width = half_margin_right;
this.genRect.Height = this.H;
this.ordersBookRect.X = this.PanelW - this.marginRight + (this.W / 2f);
this.ordersBookRect.Height = this.H;
maxOrder = cummulativeOrderBookLadder.MaxOrderVolume;
foreach(var order in cummulativeOrderBookLadder)
{
price = order.Key;
orderInfo = order.Value;
maxOrderPercent = (float)Math2.Percent(maxOrder, orderInfo.Volume) / 100f;
ordersBookRect.Y = CHART_SCALE.GetYByValue(price) - (this.H / 2f);
ordersBookRect.Width = half_margin_right * maxOrderPercent;
this.genRect.Y = CHART_SCALE.GetYByValue(price) - (this.H / 2f);
if(orderInfo.Type == VolumeAnalysis.OrderType.Ask ){
myFillRectangle(ref ordersBookRect, colorAskOrderBookColor, bidOrderBookOpacity);
myDrawRectangle(ref ordersBookRect, SharpDX.Color.Green, bidOrderBookOpacity, 1);
myDrawText(orderInfo.Volume.ToString(), ref this.genRect, colorAskOrderBookTextColor, this.orderBookMinFontWidth, this.orderBookMinFontHeight, orderbookTextFormat, askOrderBookTextOpacity);
}
else{
myFillRectangle(ref ordersBookRect, colorBidOrderBookColor, askOrderBookOpacity);
myDrawRectangle(ref ordersBookRect, SharpDX.Color.Red, askOrderBookOpacity, 1);
myDrawText(orderInfo.Volume.ToString(), ref this.genRect, colorBidOrderBookTextColor, this.orderBookMinFontWidth, this.orderBookMinFontHeight, orderbookTextFormat, bidOrderBookTextOpacity);
}
}
}
/// !- Mostramos el volume profile de la sesion
public void renderCummulativeMarketOrderLadder()
{
if( cummulativeMarketOrderLadder == null ){
return;
}
/// !- calculamos en tiempo real el maximo y minimo de la escalera
this.cummulativeMarketOrderLadder.CalculateMinAndMax(ref minMarketOL, ref maxMarketOL);
long maxMarketTotal= maxMarketOL.Total;
foreach(var marketOrder in cummulativeMarketOrderLadder){
this.renderCummulative(marketOrder.Key, marketOrder.Value, maxMarketTotal);
}
}
public void renderBackground()
{
float halfW = this.W / 2f;
float midline_x = this.PanelW - this.marginRight + halfW;
float backgroundH = System.Convert.ToSingle(CHART_SCALE.Height);
backgroundRect.X = midline_x;
backgroundRect.Y = 0;
backgroundRect.Width = this.marginRight;
backgroundRect.Height = System.Convert.ToSingle(this.PanelH);
myFillRectangle(ref backgroundRect, colorBackgroundColor, backgroundOpacity);
midline_x = this.PanelW - (this.marginRight/2f) + halfW;
background_StVerticalVec.X = midline_x;
background_EndVerticalVec.X = midline_x;
background_StVerticalVec.Y = backgroundH;
background_EndVerticalVec.Y = 0;
myDrawLine(ref background_StVerticalVec, ref background_EndVerticalVec, colorVerticalLinesColor);
midline_x = this.PanelW - this.marginRight + halfW;
background_StVerticalVec.X = midline_x;
background_EndVerticalVec.X = midline_x;
background_StVerticalVec.Y = backgroundH;
background_EndVerticalVec.Y = 0;
myDrawLine(ref background_StVerticalVec, ref background_EndVerticalVec, colorVerticalLinesColor);
}
}
#endregion
#region GLOBAL_VARIABLES
private WyckoffBookMap wyckoffBM;
private VolumeAnalysis.WyckoffBars wyckoffBars;
private VolumeAnalysis.BookMap bookMap;
private VolumeAnalysis.PriceLadder marketOrderLadder;
private VolumeAnalysis.OrderBookLadder orderBookLadder;
#endregion
#region INDICATOR_SETUP
private void setBookMapDatabase()
{
_SaveSession = false;
_SessionSaveFilePath = string.Empty;
_SessionLoadFilePath = string.Empty;
_FilterSessionPendingOrdersPer = 0;//100f;
}
private void setBookMapStyle()
{
_BookmapTextFont = new SimpleFont();
_BookmapTextFont.Family = new FontFamily("Arial");
_BookmapTextFont.Size = 10f;
_BookmapTextFont.Bold = false;
_BookmapTextFont.Italic= false;
_BookmapMinFontWidth = 15f;
_BookmapMinFontHeight = 15f;
_BidPendingOrdersColor = Brushes.LightBlue;//Brushes.Brown;
_AskPendingOrdersColor = Brushes.LightBlue;//Brushes.DarkSeaGreen;
_BidPendingOrdersTextColor = Brushes.MidnightBlue;
_AskPendingOrdersTextColor = Brushes.MidnightBlue;
_BidPendingOrdersTextOpacity = 100f;
_AskPendingOrdersTextOpacity = 100f;
_BidMarketOrdersColor = Brushes.Maroon;
_AskMarketOrdersColor = Brushes.SeaGreen;
_BidMarketOrdersTextColor = Brushes.IndianRed;
_AskMarketOrdersTextColor = Brushes.MediumAquamarine;
_BigPendingOrdersColor = Brushes.OrangeRed;
_BidMarketOrdersTextOpacity = 100f;
_AskMarketOrdersTextOpacity = 100f;
_BigPendingOrdersOpacity = 70f;
_TotalMarketOrdersColor = Brushes.DarkGoldenrod;
_TotalMarketOrdersTextColor = Brushes.WhiteSmoke;
_TotalMarketOrdersTextOpacity = 70f;
_BookMarginRight = 200;
_ShowMarketOrdersText = true;
}
private void setBookMapCalculationsAndFilters()
{
// !- por defecto 50 niveles
_LadderRange = _BookMapEnums.LadderRange.Levels50;
_MarketBarsCalculation = _BookMapEnums.MarketBarsCalculation.EachTick;
_MarketOrdersCalculation = _BookMapEnums.MarketOrdersCalculation.Delta;
// !- mostrar ordenes desde % en adelante
_FilterPendingOrdersPer = 0;
_FilterTextPendingOrdersPer = 95;
// !- filtro para grandes ordenes a mercado
_AggresiveMarketOrdersFilter = 50;
// !- 0 para ignorar el filtro de volumen
_FilterBigPendingOrders = 600;
}
private void setCummulativeBookCalculations()
{
_MarketCummulativeCalculation = _BookMapEnums.MarketCummulativeCalculation.BidAndAsk;
}
private void setCummulativeBookStyle()
{
_CummulativeBookTextFont = new SimpleFont();
_CummulativeBookTextFont.Family = new FontFamily("Arial");
_CummulativeBookTextFont.Size = 10f;
_CummulativeBookTextFont.Bold = false;
_CummulativeBookTextFont.Italic= false;
_CummulativeBookMinFontWidth = 14;
_CummulativeBookMinFontHeight= 14;
_BidMarketCummulativeColor = Brushes.Maroon;
_AskMarketCummulativeColor = Brushes.SeaGreen;
_BidMarketCummulativeTextColor = Brushes.LightPink;
_AskMarketCummulativeTextColor = Brushes.LightYellow;
_TotalMarketCummulativeColor = Brushes.SteelBlue;
_TotalMarketCummulativeTextColor = Brushes.Goldenrod;
_TotalMarketCummulativeTextOpacity = 100f;
_BidMarketCummulativeTextOpacity = 100f;
_AskMarketCummulativeTextOpacity = 100f;
}
private void setOrderBookStyle()
{
_OrderBookTextFont = new SimpleFont();
_OrderBookTextFont.Family = new FontFamily("Arial");
_OrderBookTextFont.Size = 10f;
_OrderBookTextFont.Bold = true;
_OrderBookTextFont.Italic= false;
_OrderBookTextMinFontWidth = 14;
_OrderBookTextMinFontHeight= 14;
_BidOrderBookColor = Brushes.Maroon;
_AskOrderBookColor = Brushes.SeaGreen;
_BidOrderBookTextColor = Brushes.WhiteSmoke;
_AskOrderBookTextColor = Brushes.WhiteSmoke;
_BidOrderBookTextOpacity = 100f;
_AskOrderBookTextOpacity = 100f;
_BidOrderBookOpacity = 100f;
_AskOrderBookOpacity = 100f;
}
private void setOrderBookBackground()
{
_BackgroundColor = Brushes.DarkSlateGray;
_BackgroundColorOpacity = 20f;
_VerticalLinesColor = Brushes.DarkSlateGray;
}
#endregion
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"";
Name = "Book Map";
Calculate = Calculate.OnEachTick;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = false;
setBookMapDatabase();
setBookMapStyle();
setBookMapCalculationsAndFilters();
setCummulativeBookCalculations();
setCummulativeBookStyle();
setOrderBookStyle();
setOrderBookBackground();
marketOrderLadder = new VolumeAnalysis.PriceLadder();
wyckoffBM = new WyckoffBookMap();
}
else if (State == State.Configure)
{
/// !- el orden no importa
///
wyckoffBM.setBookmapFontStyle(_BookmapTextFont);
wyckoffBM.setBookmapMinSizeFont(_BookmapMinFontWidth, _BookmapMinFontHeight);
wyckoffBM.setOrderBookFontStyle(_OrderBookTextFont);
wyckoffBM.setOrderBookMinSizeFont(_OrderBookTextMinFontWidth, _OrderBookTextMinFontHeight);
wyckoffBM.setCummulativeBookFontStyle(_CummulativeBookTextFont);
wyckoffBM.setCummulativeBookMinSizeFont(_CummulativeBookMinFontWidth, _CummulativeBookMinFontHeight);
wyckoffBM.setBidAskPendingOrdersColor(_BidPendingOrdersColor, _AskPendingOrdersColor);
wyckoffBM.setBidAskPendingOrdersFontColor(
_BidPendingOrdersTextColor, _BidPendingOrdersTextOpacity,
_AskPendingOrdersTextColor, _AskPendingOrdersTextOpacity
);
wyckoffBM.setBidAskMarketOrdersColor(_BidMarketOrdersColor, _AskMarketOrdersColor);
wyckoffBM.setBigPendingOrdersColor(_BigPendingOrdersColor, _BigPendingOrdersOpacity);
wyckoffBM.setBidAskMarketOrdersFontColor(
_BidMarketOrdersTextColor, _BidMarketOrdersTextOpacity,
_AskMarketOrdersTextColor, _AskMarketOrdersTextOpacity
);
wyckoffBM.setShowMarketOrdersText(_ShowMarketOrdersText);
wyckoffBM.setFilterPendingOrders(_FilterPendingOrdersPer, _FilterTextPendingOrdersPer);
wyckoffBM.setFilterBigPendingOrders(_FilterBigPendingOrders);
wyckoffBM.setFilterAggresiveMarketOrders(_AggresiveMarketOrdersFilter);
wyckoffBM.setMarketOrdersCalculation(_MarketOrdersCalculation, _MarketBarsCalculation);
wyckoffBM.setTotalMarketOrdersColor(_TotalMarketOrdersColor);
wyckoffBM.setTotalMarketOrdersFontColor(_TotalMarketOrdersTextColor, _TotalMarketOrdersTextOpacity);
wyckoffBM.setBidAskMarketCummulativeColor(_BidMarketCummulativeColor, _AskMarketCummulativeColor);
wyckoffBM.setBidAskMarketCummulativeFontColor(
_BidMarketCummulativeTextColor, _BidMarketCummulativeTextOpacity,
_AskMarketCummulativeTextColor, _AskMarketCummulativeTextOpacity,
_TotalMarketCummulativeTextColor, _TotalMarketCummulativeTextOpacity
);
wyckoffBM.setTotalMarketCummulativeColor(_TotalMarketCummulativeColor);
wyckoffBM.setMarketCummulativeCalculation(_MarketCummulativeCalculation);
wyckoffBM.setMarginRight(_BookMarginRight);
wyckoffBM.setBidAskOrderBookColor(
_BidOrderBookColor, _BidOrderBookOpacity,
_AskOrderBookColor, _AskOrderBookOpacity
);
wyckoffBM.setBidAskOrderBookFontColor(
_BidOrderBookTextColor, _BidOrderBookTextOpacity,
_AskOrderBookTextColor, _AskOrderBookTextOpacity
);
wyckoffBM.setBackgroundColor(_BackgroundColor, _BackgroundColorOpacity);
wyckoffBM.setVerticalLinesColor(_VerticalLinesColor);
Calculate = Calculate.OnEachTick;
}
else if (State == State.DataLoaded)
{
int ladderRange = this.getLadderRange(_LadderRange);
bookMap = new VolumeAnalysis.BookMap(Bars);
// !- nivel maximo de la escalera de precios
bookMap.setLadderRange(ladderRange);
bookMap.setFilterSessionPercent(_FilterSessionPendingOrdersPer);
if( this._SaveSession ){
if( _SessionSaveFilePath.IsNullOrEmpty() ){
// !- Desde la ultima barra cargada...
DateTime tmp = this.Bars.LastBarTime;
string sessionTime = tmp.Year.ToString() + '_' + tmp.Month.ToString() + '_' + tmp.Day.ToString();
// !- siempre cargamos el nombre del archivo con la ruta asociada a la propiedad de NT8