'Generating signals for opening positions
Private Sub Signals()
Dim ByPebP, SlPebP, ByMgbP, SlMgbP, DlPe,
Trigger As Double
'Calculating Trigger for an action standard
Trigger = [B8].Value * [B34].Value / 100
'The strategy is inside between If and Then. If
Close price is higher than Open price for three days in a row, Then
generate a Long OK signal.
If LongOK = False And _
(Cells(Candle, "L").Value -
Cells(Candle, "I").Value) / Cells(Candle, "I").Value > Trigger And _
(Cells(Candle + 1, "L").Value -
Cells(Candle + 1, "I").Value) / Cells(Candle + 1, "I").Value > Trigger
And _
(Cells(Candle + 2, "L").Value -
Cells(Candle + 2, "I").Value) / Cells(Candle + 2, "I").Value > Trigger
Then
'Strategy for Long
LongOK = True
BCBM = Candle
BBP = Round(Cells(Candle, "L").Value,
2)
Cells(Candle, "N").Value = "Long OK "
& Int([B20].Value * CP / 100 / BBP) & " @ " & BBP
Exit Sub
End If
'The strategy is inside between If and Then. If
Close price is lower than Open price for three days in a row, Then
generate a Short OK signal.
If ShortOK = False And _
(Cells(Candle, "L").Value -
Cells(Candle, "I").Value) / Cells(Candle, "I").Value < -1 * Trigger And
_
(Cells(Candle + 1, "L").Value -
Cells(Candle + 1, "I").Value) / Cells(Candle + 1, "I").Value < -1 *
Trigger And _
(Cells(Candle + 2, "L").Value -
Cells(Candle + 2, "I").Value) / Cells(Candle + 2, "I").Value < -1 *
Trigger Then
'Strategy for Short
ShortOK = True
SCBM = Candle
SBP = Round(Cells(Candle, "L").Value,
2)
Cells(Candle, "N").Value = "Short OK "
& Int(([B20].Value + 1.5 * [B19].Value * SlPebP) / 1.5 * CP / 100 / SBP)
& " @ " & SBP
Exit Sub
End If
If BCBM - Candle > [B7].Value Then LongOK =
False
If SCBM - Candle > [B7].Value Then ShortOK =
False
'Open Long
If BCBM - Candle <= [B7].Value Then
'
If LongOK = True And ShortOK = False
And Cells(Candle, "I").Value > BBP Then
If LongOK = True And ShortOK = False
Then
DlPe = Round((Cells(Candle, "J").Value
+ Cells(Candle, "K").Value) / 2, 2)
If [B19].Value = 0 Then
TdSum = Int([B20].Value * CP / 100 /
DlPe)
Cells(Candle, "O").Value = -1 * TdSum
* DlPe
[B19].Value = [B19].Value + TdSum
PBM = DlPe
BM = [B20].Value + Cells(Candle,
"O").Value + [B19].Value * PBM
[B20].Value = [B20].Value +
Cells(Candle, "O").Value
Cells(Candle, "AE").Value =
[B20].Value + [B19].Value * Cells(Candle, "L").Value
Cells(Candle, "N").Value = "Buy/Open "
& TdSum & " @ " & DlPe
End If
End If
End If
'Open Short
If SCBM - Candle <= [B7].Value Then
'
If ShortOK = True And LongOK = False
And Cells(Candle, "I").Value < SBP Then
If ShortOK = True And LongOK = False
Then
DlPe = Round((Cells(Candle, "J").Value
+ Cells(Candle, "K").Value) / 2, 2)
If [B19].Value = 0 Then
TdSum = Int([B20].Value / 1.5 * CP /
100 / DlPe)
Cells(Candle, "O").Value = TdSum *
DlPe
[B19].Value = [B19].Value - TdSum
PBM = DlPe
BM = [B20].Value + Cells(Candle,
"O").Value + [B19].Value * PBM
[B20].Value = [B20].Value +
Cells(Candle, "O").Value
Cells(Candle, "AE").Value =
[B20].Value + [B19].Value * Cells(Candle, "L").Value
Cells(Candle, "N").Value = "Sell/Open
" & TdSum & " @ " & DlPe
End If
End If
End If
End Sub