'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
'The strategy is inside between If and Then. If
Hammer appears, Then generate a Long OK signal.
If Cells(Candle, "L").Value > Cells(Candle,
"I").Value And Cells(Candle, "K").Value < Cells(Candle, "I").Value Then
If LongOK = False And _
(Cells(Candle, "I").Value -
Cells(Candle, "K").Value) / (Cells(Candle, "L").Value - Cells(Candle,
"I").Value) > Trigger And _
(Cells(Candle, "J").Value -
Cells(Candle, "L").Value) / (Cells(Candle, "I").Value - Cells(Candle,
"K").Value) < 0.1 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
End If
If Cells(Candle, "L").Value < Cells(Candle,
"I").Value And Cells(Candle, "K").Value < Cells(Candle, "L").Value Then
If LongOK = False And _
(Cells(Candle, "L").Value -
Cells(Candle, "K").Value) / (Cells(Candle, "I").Value - Cells(Candle,
"L").Value) > Trigger And _
(Cells(Candle, "J").Value -
Cells(Candle, "I").Value) / (Cells(Candle, "L").Value - Cells(Candle,
"K").Value) < 0.1 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
End If
'The strategy is inside between If and Then. If
Shooting Star appears, Then generate a Short OK signal.
If Cells(Candle, "L").Value < Cells(Candle,
"I").Value And Cells(Candle, "J").Value > Cells(Candle, "I").Value Then
If ShortOK = False And _
(Cells(Candle, "J").Value -
Cells(Candle, "I").Value) / (Cells(Candle, "I").Value - Cells(Candle,
"L").Value) > Trigger And _
(Cells(Candle, "L").Value -
Cells(Candle, "K").Value) / (Cells(Candle, "J").Value - Cells(Candle,
"I").Value) < 0.1 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
End If
If Cells(Candle, "I").Value < Cells(Candle,
"L").Value And Cells(Candle, "J").Value > Cells(Candle, "L").Value Then
If ShortOK = False And _
(Cells(Candle, "J").Value -
Cells(Candle, "L").Value) / (Cells(Candle, "L").Value - Cells(Candle,
"I").Value) > Trigger And _
(Cells(Candle, "I").Value -
Cells(Candle, "K").Value) / (Cells(Candle, "J").Value - Cells(Candle,
"L").Value) < 0.1 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
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