@@ -65,7 +65,35 @@ module.exports = class {
65
65
. map ( v => `${ intl . format ( v . rangeStart ) } -${ intl . format ( v . rangeEnd ) } ` )
66
66
. join ( ', ' ) ;
67
67
68
- return SignalResult . createEmptySignal ( currentValues ) ;
68
+ const emptySignal = SignalResult . createEmptySignal ( currentValues ) ;
69
+
70
+ // entry or exit
71
+ if ( ! indicatorPeriod . getLastSignal ( ) ) {
72
+ const dice = parseFloat ( options . dice || 6 ) ;
73
+ const diceSize = parseFloat ( options . dice_size || 12 ) ;
74
+
75
+ const number = Math . floor ( Math . random ( ) * diceSize ) + 1 ;
76
+ emptySignal . addDebug ( 'message' , `${ number } ` ) ;
77
+ if ( number === dice ) {
78
+ const longOrShort = Math . random ( ) > 0.5 ? 'long' : 'short' ;
79
+ emptySignal . setSignal ( longOrShort ) ;
80
+ }
81
+ }
82
+
83
+ // close on profit or lose
84
+ if ( indicatorPeriod . getLastSignal ( ) ) {
85
+ if ( indicatorPeriod . getProfit ( ) > 2 ) {
86
+ // take profit
87
+ emptySignal . addDebug ( 'message' , 'TP' ) ;
88
+ emptySignal . setSignal ( 'close' ) ;
89
+ } else if ( indicatorPeriod . getProfit ( ) < - 2 ) {
90
+ // stop loss
91
+ emptySignal . addDebug ( 'message' , 'SL' ) ;
92
+ emptySignal . setSignal ( 'close' ) ;
93
+ }
94
+ }
95
+
96
+ return emptySignal ;
69
97
}
70
98
71
99
getBacktestColumns ( ) {
@@ -110,6 +138,10 @@ module.exports = class {
110
138
label : 'Top Volume Ranges' ,
111
139
value : 'ranges'
112
140
} ,
141
+ {
142
+ label : 'dice' ,
143
+ value : 'message'
144
+ } ,
113
145
{
114
146
label : 'zigzag' ,
115
147
value : row => ( row . zigzag && row . zigzag . turningPoint === true ? 'warning' : undefined ) ,
@@ -121,6 +153,8 @@ module.exports = class {
121
153
getOptions ( ) {
122
154
return {
123
155
period : '15m' ,
156
+ dice : 6 ,
157
+ dice_size : 12 ,
124
158
foreign_pair_exchange : 'binance' ,
125
159
foreign_pair_symbol : 'BTCUSDT' ,
126
160
foreign_pair_period : '15m'
0 commit comments