Hi all
Is there still somebody there who follows this thread ? If I speak alone in the desert, thank you for inquiring
anyway, I follow my research with FT to improve Marilyn results. After the last module "close on slope", I'm so happy (and proud ) to release the "Close on PinBar" ( or may be the "Move SL on PinBar" and surely the 'Don't trade after these pinbar" )
The main work is the detection of PinBar... after that, we can do all we want with !
FT example to close trade after PinBar :
Code: Select all // Test sur Pinbar -> Move SL sur AM25 ou Close ?
// PinBar
if (PA_PinBar_Meche_Ratio[j] > 0) then
begin
if (OrderType = tp_buy) then
begin
if (IsBearishPinBar(PaireDevise[j],j) = true) then
begin
FermeTradeDevise(PaireDevise[j],tp_buy,0,999999);
Lprint(PaireDevise[j]+' -> Close BUY sur Bearish PinBar' );
end;
end;
if (OrderType = tp_sell) then
begin
if IsBullishPinBar(PaireDevise[j],j) then
begin
FermeTradeDevise(PaireDevise[j],tp_sell,0,999999);
Lprint(PaireDevise[j]+' -> Close SELL sur Bullish PinBar' );
end;
end;
end;
and the main detection module :
Code: Select all Function IsBullishPinBar(MaDevise : string; MonIndex : integer) : boolean;
var
High0,Low0,Open0,Close0,High1,Low1,Open1,Close1,High2,Low2,Open2,Close2: double;
bar_length, wick_length, body_length, close_ratio, Ratio_Meche_Taille : double;
ValeurRetour: boolean;
Procedure Calcul_OHLC(MaPeriode : integer);
begin
// Nouvelle bougie
High0 := iHigh(MaDevise,MaPeriode,0);
Low0 := iLow(MaDevise,MaPeriode,0);
Open0 := iOpen(MaDevise,MaPeriode,0);
Close0 := iClose(MaDevise,MaPeriode,0);
// Bougie de la PinBar
High1 := iHigh(MaDevise,MaPeriode,1);
Low1 := iLow(MaDevise,MaPeriode,1);
Open1 := iOpen(MaDevise,MaPeriode,1);
Close1 := iClose(MaDevise,MaPeriode,1);
// Bougie précédent la PinBar
High2 := iHigh(MaDevise,MaPeriode,2);
Low2 := iLow(MaDevise,MaPeriode,2);
Open2 := iOpen(MaDevise,MaPeriode,2);
Close2 := iClose(MaDevise,MaPeriode,2);
bar_length := High1 - Low1;
body_length := Abs(Open1 - Close1);
wick_length := Min(Open1, Close1) - Low1;
if bar_length>0 then Ratio_Meche_Taille := wick_length / bar_length else Ratio_Meche_Taille := 0;
end;
function CalculPinBar(MaPeriode : integer) : boolean ;
var
ValeurRetour: boolean;
MonMultiplcateur : integer;
MaTailleMini : integer;
begin
ValeurRetour := false;
if MaPeriode = Period_H1 then
begin
MonMultiplcateur := PA_PinBar_Coeff_H1[Monindex];
MaTailleMini := PA_PinBar_TailleMini_H1[Monindex];
end;
if MaPeriode = Period_H4 then
begin
MonMultiplcateur := PA_PinBar_Coeff_H4[Monindex];
MaTailleMini := PA_PinBar_TailleMini_H4[Monindex];
end;
if MaPeriode = Period_D1 then
begin
MonMultiplcateur := PA_PinBar_Coeff_D1[Monindex];
MaTailleMini := PA_PinBar_TailleMini_D1[Monindex];
end;
if MaPeriode = Period_W1 then
begin
MonMultiplcateur := PA_PinBar_Coeff_W1[Monindex];
MaTailleMini := PA_PinBar_TailleMini_W1[Monindex];
end;
// Taille minimale
if (abs(High1 - Low1) >= MaTailleMini * Point) then
begin
// High PinBar < High2 d'un delta pips mini
if ((Low2 - Low1) > PA_PinBar_DeltaPipsMiniHigh_Low_1_2[MonIndex] * MonMultiplcateur * Point) then
begin
// Mèche > PA_PinBar_Meche_Ratio * Taille globale
if ( Ratio_Meche_Taille >= (PA_PinBar_Meche_Ratio[MonIndex] / 100.0) ) then // looks like a bullish pinbar
begin
close_ratio := (high1 - close1 ) / bar_length;
if (close_ratio < (PA_PinBar_Close_Ratio[MonIndex] / 100.0)) then
begin
// Corps de la PinBar inclus dans la bougie précédente (Open and close within previous bar)
if (Open1 > Low2) and (Open1 < High2) and (Close1 > Low2) and (Close1 < High2) then
begin
ValeurRetour := true;
end;
end;
end;
end;
end;
result:= ValeurRetour;
end;
begin
ValeurRetour := false;
// PinBar H1
Calcul_OHLC(Period_H1);
// PinBar basique - ajouter controle taille corps sur bougie N-1 / Low < tous les autes low précedents etc
// analyse 1 seule fois en début de bougie
if CalculPinBar(Period_H1)= true then
begin
if PA_PinBar_Coeff_H1[Monindex] >0 then
begin
ValeurRetour := true;
if (Open0 = Close0) and (High0 = Low0) then TraceLigne(MaDevise,Period_H1,0,psSolid,'BULLISH_H1',0);
end;
end;
// PinBar H4
Calcul_OHLC(Period_H4);
if CalculPinBar(Period_H4)= true then
begin
if PA_PinBar_Coeff_H4[Monindex] >0 then
begin
ValeurRetour := true;
if (Open0 = Close0) and (High0 = Low0) then TraceLigne(MaDevise,Period_H4,0,psSolid,'BULLISH_H4',0);
end;
end;
// PinBar D1
Calcul_OHLC(Period_D1);
// PinBar basique - ajouter controle taille corps sur bougie N-1 / Low < tous les autes low précedents etc
// analyse 1 seule fois en début de bougie
if CalculPinBar(Period_D1)= true then
begin
if PA_PinBar_Coeff_D1[Monindex] >0 then
begin
ValeurRetour := true;
if (Open0 = Close0) and (High0 = Low0) then TraceLigne(MaDevise,Period_D1,0,psSolid,'BULLISH_D1',0);
end;
end;
// PinBar W1
Calcul_OHLC(Period_W1);
// PinBar basique - ajouter controle taille corps sur bougie N-1 / Low < tous les autes low précedents etc
// analyse 1 seule fois en début de bougie
if CalculPinBar(Period_W1)= true then
begin
if PA_PinBar_Coeff_W1[Monindex] >0 then
begin
ValeurRetour := true;
if (Open0 = Close0) and (High0 = Low0) then TraceLigne(MaDevise,Period_W1,0,psSolid,'BULLISH_W1',0);
end;
end;
result:= ValeurRetour;
end;
//----------------------------------------------------------------------
Code: Select all Function IsBearishPinBar(MaDevise : string; MonIndex : integer) : boolean;
var
High0,Low0,Open0,Close0,High1,Low1,Open1,Close1,High2,Low2,Open2,Close2: double;
bar_length, wick_length, body_length, close_ratio, Ratio_Meche_Taille : double;
ValeurRetour: boolean;
Procedure Calcul_OHLC(MaPeriode : integer);
begin
// Nouvelle bougie
High0 := iHigh(MaDevise,MaPeriode,0);
Low0 := iLow(MaDevise,MaPeriode,0);
Open0 := iOpen(MaDevise,MaPeriode,0);
Close0 := iClose(MaDevise,MaPeriode,0);
// Bougie de la PinBar
High1 := iHigh(MaDevise,MaPeriode,1);
Low1 := iLow(MaDevise,MaPeriode,1);
Open1 := iOpen(MaDevise,MaPeriode,1);
Close1 := iClose(MaDevise,MaPeriode,1);
// Bougie précédent la PinBar
High2 := iHigh(MaDevise,MaPeriode,2);
Low2 := iLow(MaDevise,MaPeriode,2);
Open2 := iOpen(MaDevise,MaPeriode,2);
Close2 := iClose(MaDevise,MaPeriode,2);
bar_length := High1 - Low1;
body_length := Abs(Open1 - Close1);
wick_length := High1 - Max(Open1, Close1);
if bar_length>0 then Ratio_Meche_Taille := wick_length / bar_length else Ratio_Meche_Taille := 0;
end;
function CalculPinBar(MaPeriode : integer) : boolean ;
var
ValeurRetour: boolean;
MonMultiplcateur : integer;
MaTailleMini : integer;
begin
ValeurRetour := false;
if MaPeriode = Period_H1 then
begin
MonMultiplcateur := PA_PinBar_Coeff_H1[Monindex];
MaTailleMini := PA_PinBar_TailleMini_H1[Monindex];
end;
if MaPeriode = Period_H4 then
begin
MonMultiplcateur := PA_PinBar_Coeff_H4[Monindex];
MaTailleMini := PA_PinBar_TailleMini_H4[Monindex];
end;
if MaPeriode = Period_D1 then
begin
MonMultiplcateur := PA_PinBar_Coeff_D1[Monindex];
MaTailleMini := PA_PinBar_TailleMini_D1[Monindex];
end;
if MaPeriode = Period_W1 then
begin
MonMultiplcateur := PA_PinBar_Coeff_W1[Monindex];
MaTailleMini := PA_PinBar_TailleMini_W1[Monindex];
end;
// Taille minimale
if (abs(High1 - Low1) >= MaTailleMini * Point) then
begin
// High PinBar > High2 d'un delta pips mini
if ((High1 - High2) > PA_PinBar_DeltaPipsMiniHigh_Low_1_2[MonIndex] * MonMultiplcateur * Point) then
begin
// Mèche > PA_PinBar_Meche_Ratio * Taille globale
if ( Ratio_Meche_Taille >= (PA_PinBar_Meche_Ratio[MonIndex] / 100.0) ) then // looks like a bullish pinbar
begin
close_ratio := (close1 - low1 ) / bar_length;
if (close_ratio < (PA_PinBar_Close_Ratio[MonIndex] / 100.0)) then
begin
// Corps de la PinBar inclus dans la bougie précédente (Open and close within previous bar)
if (Open1 > Low2) and (Open1 < High2) and (Close1 > Low2) and (Close1 < High2) then
begin
ValeurRetour := true;
end;
end;
end;
end;
end;
result:= ValeurRetour;
end;
begin
ValeurRetour := false;
// PinBar H1
Calcul_OHLC(Period_H1);
// PinBar basique - ajouter controle taille corps sur bougie N-1 / Low < tous les autes low précedents etc
// analyse 1 seule fois en début de bougie
if CalculPinBar(Period_H1)= true then
begin
if PA_PinBar_Coeff_H1[Monindex] >0 then
begin
ValeurRetour := true;
if (Open0 = Close0) and (High0 = Low0) then TraceLigne(MaDevise,Period_H1,0,psSolid,'BULLISH_H1',0);
end;
end;
// PinBar H4
Calcul_OHLC(Period_H4);
// PinBar basique - ajouter controle taille corps sur bougie N-1 / Low < tous les autes low précedents etc
// analyse 1 seule fois en début de bougie
if CalculPinBar(Period_H4)= true then
begin
if PA_PinBar_Coeff_H4[Monindex] >0 then
begin
ValeurRetour := true;
if (Open0 = Close0) and (High0 = Low0) then TraceLigne(MaDevise,Period_H4,0,psSolid,'BULLISH_H4',0);
end;
end;
// PinBar D1
Calcul_OHLC(Period_D1);
// PinBar basique - ajouter controle taille corps sur bougie N-1 / Low < tous les autes low précedents etc
// analyse 1 seule fois en début de bougie
if CalculPinBar(Period_D1)= true then
begin
if PA_PinBar_Coeff_D1[Monindex] >0 then
begin
ValeurRetour := true;
if (Open0 = Close0) and (High0 = Low0) then TraceLigne(MaDevise,Period_D1,0,psSolid,'BULLISH_D1',0);
end;
end;
// PinBar W1
Calcul_OHLC(Period_W1);
// PinBar basique - ajouter controle taille corps sur bougie N-1 / Low < tous les autes low précedents etc
// analyse 1 seule fois en début de bougie
if CalculPinBar(Period_W1)= true then
begin
if PA_PinBar_Coeff_W1[Monindex] >0 then
begin
ValeurRetour := true;
if (Open0 = Close0) and (High0 = Low0) then TraceLigne(MaDevise,Period_W1,0,psSolid,'BULLISH_W1',0);
end;
end;
result:= ValeurRetour;
end;
//----------------------------------------------------------------------
For now, I'm just using D1 PinBar detection and doing some calculation to detect the best param for :
wick_length, close_ratio and DeltaPipsMiniHigh_Low. But first result show a very good balance increase with €/$ to about +26% !
If someone interested...let me know !
cheers
Philippe |