Cascade trading combined with Reverse MA
- Experten
- Chia Leilypour
- Version: 1.0
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
#include <Most_Common_Classes.mqh>
// Parameter für die gleitenden Durchschnitte definieren
input int fastMAPeriod = 10; // Schnelle MA-Periode (z.B. 10 für Scalping)
input int slowMAPeriod = 20; // Langsamer MA-Zeitraum (z.B. 20 für Scalping)
input ENUM_MA_METHOD maMethod = MODE_SMA;
double lotSize;
int maShift_aktuell = 0;
int maShift_Previous = 1;
bool genug_Geld;
bool genug_Volumen;
string Nachricht;
bool IsBuy;
bool TradeIsOk;
double StopLoss;
double TakeProfit;
input double RiskPercent=0.01;
Eingabe double R2R=2;
input double StopLossPoints=100;
input double MinimumStopLossPoints=25;
ST_StopLoss_TakeProfit arr;
int OnInit()
{
// Initialisierung
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Experten-Deinitialisierungsfunktion |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
// Code bereinigen
}
//+------------------------------------------------------------------+
//| Experten-Tick-Funktion |
//+------------------------------------------------------------------+
void OnTick()
{
// Keine Verschiebung für gleitende Durchschnitte
// Einfacher gleitender Durchschnitt (SMA) verwenden
ENUM_APPLIED_PRICE appliedPrice = PRICE_CLOSE; // Auf Schlusskurse anwenden
// Abrufen der Werte des aktuellen und des vorherigen gleitenden Durchschnitts
// if (AccountInfoDouble(ACCOUNT_PROFIT)>100){close_All_Orders();}
double fastMA_Current = MACalculator(_Symbol,PERIOD_CURRENT,fastMAPeriod,maShift_current,maMethod,appliedPrice); // Aktueller Fast MA
double slowMA_Current = MACalculator(_Symbol,PERIOD_CURRENT,slowMAPeriod,maShift_current,maMethod,appliedPrice); // Aktueller Slow MA
double fastMA_Previous = MACalculator(_Symbol,PERIOD_CURRENT,fastMAPeriod,maShift_Previous,maMethod,appliedPrice); // Vorheriger Fast MA
double slowMA_Previous = MACalculator(_Symbol,PERIOD_CURRENT,slowMAPeriod,maShift_Previous,maMethod,appliedPrice); // Vorheriger Slow MA
double Refference_MA = MACalculator(_Symbol,PERIOD_CURRENT,100,maShift_Previous,maMethod,appliedPrice);
// Aktuelle Kontoinformationen abrufen
// Losgröße für Trades festlegen
double ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); // Aktueller Briefkurs
double bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); // Aktueller Geldkurs
if(IsNewCanddle(PERIOD_H1))
{
TradeIsOk=true;
//if(PositionsTotal() != 0)canddleCount=canddleCount+1;
}
if(fastMA_Previous < slowMA_Previous && fastMA_Current > slowMA_Current && SymbolOpenOrders(Symbol())==0 && bid< Refference_MA)
{
//lotSize=OptimumLotSize(_Symbol,ask,StopLoss,RiskPercent);
lotSize=0.01;
Genug_Geld =CheckMoneyForTrade(Symbol(),lotSize,ORDER_TYPE_SELL);
genug_Volumen=CheckVolumeValue(lotSize,message);
StopLoss=Bid+StopLossPoints*Point();
TakeProfit=Bid-R2R*StopLossPoints*Point();
if(enough_money && enough_valume) Trading.Sell(lotSize, NULL, bid, StopLoss,0, "Logic Order");
IsBuy=false;
}
if(fastMA_Previous > slowMA_Previous && fastMA_Current < slowMA_Current && SymbolOpenOrders(Symbol())==0 && ask > Refference_MA)
{
//lotSize=OptimumLotSize(_Symbol,ask,StopLoss,RiskPercent);
lotSize=0.01;
Genug_Geld =CheckMoneyForTrade(Symbol(),lotSize,ORDER_TYPE_BUY);
genug_Volumen=CheckVolumeValue(lotSize,message);
StopLoss=Bid-StopLossPoints*Point();
TakeProfit=Bid+R2R*StopLossPoints*Point();
if(enough_money && enough_valume)Trading.Buy(lotSize, NULL, ask, StopLoss,0, "Logic Order");
IsBuy=true;
}
if(TradeIsOk && SymbolOpenOrders(Symbol())>=1)
{
//arr=Cascade_trading(_Symbol,lotSize,IsBuy,ask,bid,TakeProfit,StopLoss,StopLossPoints,MinimumStopLossPoints,R2R,true, SymbolOpenOrders(Symbol()));
//TakeProfit=arr.NewTakeProfit;
//StopLoss=arr.NewStopLoss;
}
}

