Last code adaptation to fit more pairs : New one is AUUSD. This one go quicly to Stoch D1 OBOS. So I have added a module to add trade if
- Stoch D1 OBOS zone
- but STOCH H4 confirm trade ( for Buy Stoch H4 UP and < param level for SELL Stoch Down and > param level )
Modification of module : Close on Friday : Take the best trade for partial close (not the first one)
Code: Select all
//Close on Friday en prenant le trade le plus gagnant
if MACD_UseCloseFriday[j] = true then
begin
if (DayOfTheWeek(TimeCurrent)= 5) and (HourOf(TimeCurrent)>= 21) and (MACD_FlagCloseFriday[j]=0) and
( ((OrderOpenPrice = ReturnLowOpenPrice(PaireDevise[j],OrderTicket)) and (OrderType = tp_buy)) or
((OrderOpenPrice = ReturnHighOpenPrice(PaireDevise[j],OrderTicket)) and (OrderType = tp_sell)) ) then
begin
MACD_FlagCloseFriday[j] := 1;
if (OrderProfit>0) then
begin
if OrderLots <= 0.10 then
begin
Lprint(PaireDevise[j]+' -> Close Finale sur Vendredi 21H ' ) ;
CloseOrder(OrderTicket)
end
else
begin
Lprint(PaireDevise[j]+' -> Close Partielle sur Vendredi 21H ' ) ;
CloseOrderPArtial(OrderTicket,0.10)
end;
exit;
end;
end;Modification of Module Close on 3 MACD : add a level mini delta pips between MACD Main 1 and 3
Code: Select all
// Ferme trade si Perte sur Devise et 3 MACD baisse pour Achat et inverst pour Vente
if (OrderType = tp_sell) and (PaireMACD_D1Main[j,1] > PaireMACD_D1Main[j,2]) and (PaireMACD_D1Main[j,2] > PaireMACD_D1Main[j,3]) and
(PaireMACD_D1Main[j,1] - PaireMACD_D1Main[j,3] >= MACD_DeltaPipsInterMacdToClose[j]*Point) then
begin
if (GetProfitDevise(PaireDevise[j],OrderTicket) < 0) and (MonBid > ReturnHighOpenPrice(PaireDevise[j],OrderTicket)) then
begin
Lprint(PaireDevise[j]+' -> Solde Sell sur Perte et 3 MACD haussiers -> Delta MACD 1-3 = '+MaValeurToStr(PaireMACD_D1Main[j,1] - PaireMACD_D1Main[j,3]/Point,Digits) );
FermeTradeDevise(PaireDevise[j],tp_sell,0,999999);
exit;
end;
if (UseTakeProfitOn3MACD[j]=true) then
begin
MonNbHourHistoSELL := GetHourBetweenLastHISTOtrade(PaireDevise[j],tp_SELL,OrderTicket);
if (GetProfitDevise(PaireDevise[j],OrderTicket) > 0) and (MonNbHourHistoSELL > 24) then
begin
Lprint(PaireDevise[j]+' -> Prise Profit Partiel Sell sur 3 MACD haussiers ' );
if OrderLots <= 0.10 then
begin
Lprint(PaireDevise[j]+' -> Prise Profit Partiel Sell sur 3 MACD haussiers ' ) ;
CloseOrder(OrderTicket)
end
else
begin
Lprint(PaireDevise[j]+' -> Prise Profit Partiel Sell sur 3 MACD haussiers ' ) ;
CloseOrderPArtial(OrderTicket,0.10)
end;
exit;
end;
end;
end;
if (OrderType = tp_buy) and (PaireMACD_D1Main[j,1] < PaireMACD_D1Main[j,2]) and (PaireMACD_D1Main[j,2] < PaireMACD_D1Main[j,3])and
(PaireMACD_D1Main[j,3] - PaireMACD_D1Main[j,1] >= MACD_DeltaPipsInterMacdToClose[j]*Point) then
begin
if (GetProfitDevise(PaireDevise[j],OrderTicket) < 0) and (MonBid < ReturnLowOpenPrice(PaireDevise[j],OrderTicket)) then
begin
Lprint(PaireDevise[j]+' -> Solde BUY sur Perte et 3 MACD baissiers-> Delta MACD 3-1 = '+MaValeurToStr(PaireMACD_D1Main[j,3] - PaireMACD_D1Main[j,1]/Point,Digits) );
FermeTradeDevise(PaireDevise[j],tp_buy,0,999999);
exit;
end;
if (UseTakeProfitOn3MACD[j]=true) then
begin
MonNbHourHistoBUY := GetHourBetweenLastHISTOtrade(PaireDevise[j],tp_BUY,OrderTicket);
if (GetProfitDevise(PaireDevise[j],OrderTicket) > 0) and (MonNbHourHistoSELL > 24) then
begin
Lprint(PaireDevise[j]+' -> Prise Profit Partiel Buy sur 3 MACD haussiers ' );
if OrderLots <= 0.10 then
begin
Lprint(PaireDevise[j]+' -> Prise Profit Partiel Buy sur 3 MACD haussiers ' ) ;
CloseOrder(OrderTicket)
end
else
begin
Lprint(PaireDevise[j]+' -> Prise Profit Partiel Buy sur 3 MACD haussiers ' ) ;
CloseOrderPArtial(OrderTicket,0.10)
end;
exit;
end;
end;
end;
Take Trade Buy/Sell
1 - added for pairs like AUDUSD : filter with STOCH H4
2 - added filter for BUY on Stoch SLOW 1 < Stoch Slow 2 and for SELL on Stoch SLOW 1 > Stoch Slow 2
3 - added Minimum Level for MACD Main to take trade -> avoid range zone
BUY
Code: Select all
//Buy
if ( NbTradeBuy < MACD_NbTradeMax[kk]) and (NbTradeSell = 0) and
( PaireMACD_D1Main[kk,1] > PaireMACD_D1Main[kk,2]) and ( PaireMACD_D1Main[kk,2] > PaireMACD_D1Main[kk,3]) and
( (( _STOD1SLOW[kk,1] <= MACD_StochLevelToTrade[kk]) and ( _STOD1FAST[kk,1] > _STOD1SLOW[kk,1]) and ( _STOD1FAST[kk,1] > _STOD1FAST[kk,2]) and
(( _STOD1SLOW[kk,1] > _STOD1SLOW[kk,2]) or (UseStochD1slowToFilterTrade[kk]=false)) ) or
( (UseStochH4ToTakeTrade[kk]=true) and (_STOD1SLOW[kk,1] > MACD_StochLevelToTrade[kk]) and
(_STOH4FAST[kk,1] < MACD_StochH4LevelMax[kk]) and ( _STOH4FAST[kk,1] > _STOH4FAST[kk,2]) and ( _STOH4FAST[kk,1] > _STOH4Slow[kk,1]) ) ) and
( PaireMA5[kk,1] > PaireMA5[kk,2]) and ( PaireMA5[kk,2] > PaireMA5[kk,3]) and ( PaireMA25[kk,2] - PaireMA25[kk,1] < MACD_DeltaPipsMA25[kk]*Point ) and
((MonNbHour > MACD_HOURDELAY[kk] ) or (MonNbHour=9999)) and ((MonNbHourHistoBUY > MACD_HOURDELAY2[kk] ) or (MonNbHourHistoBUY=9999)) and
( (PaireMACD_D1Main[kk,1] >= MACD_LevelMinTotrade[kk]) or (PaireMACD_D1Main[kk,3] <= -MACD_LevelMinTotrade[kk]) ) then
beginCode: Select all
// Sell
if ( NbTradeSell < MACD_NbTradeMax[kk]) and (NbTradeBuy = 0) and
( PaireMACD_D1Main[kk,1] < PaireMACD_D1Main[kk,2]) and ( PaireMACD_D1Main[kk,2] < PaireMACD_D1Main[kk,3]) and
( (( _STOD1SLOW[kk,1] >= 100-MACD_StochLevelToTrade[kk]) and ( _STOD1FAST[kk,1] < _STOD1SLOW[kk,1]) and ( _STOD1FAST[kk,1] < _STOD1FAST[kk,2]) and
(( _STOD1SLOW[kk,1] < _STOD1SLOW[kk,2]) or (UseStochD1slowToFilterTrade[kk]=false)) ) or
( (UseStochH4ToTakeTrade[kk]=true) and (_STOD1SLOW[kk,1] < 100-MACD_StochLevelToTrade[kk]) and
(_STOH4FAST[kk,1] > 100-MACD_StochH4LevelMax[kk]) and ( _STOH4FAST[kk,1] < _STOH4FAST[kk,2]) and ( _STOH4FAST[kk,1] < _STOH4Slow[kk,1]) ) ) and
( PaireMA5[kk,1] < PaireMA5[kk,2]) and ( PaireMA5[kk,2] < PaireMA5[kk,3]) and ( PaireMA25[kk,1] - PaireMA25[kk,2] < MACD_DeltaPipsMA25[kk]*Point ) and
((MonNbHour > MACD_HOURDELAY[kk] ) or (MonNbHour=9999)) and ((MonNbHourHistoBUY > MACD_HOURDELAY2[kk] ) or (MonNbHourHistoBUY=9999)) and
( (PaireMACD_D1Main[kk,3] >= MACD_LevelMinTotrade[kk]) or (PaireMACD_D1Main[kk,1] <= -MACD_LevelMinTotrade[kk]) ) then
begin
