IntraScalper
- Indikatoren
- Mangesh Popat Ubale
- Version: 1.2
- Aktualisiert: 13 Januar 2026
EA DOKUMENTATION
#Eigenschaft Copyright "ISP Trading System"
#eigenschaft link ""
#property version "1.00"
#property strict
#include <Trade/Trade.mqh>
#include <Handel/SymbolInfo.mqh>
#include <Handel/PositionInfo.mqh>
input double InpLotSize = 0.1;
input int InpStopLoss = 200;
input int InpTakeProfit = 400;
input ulong InpMagicNumber = 2024;
input bool InpCloseOnOpposite = true;
input string InpSignalPrefix = "ISP_";
input int InpMaxSlippage = 3;
//--- Globale Variablen
CTrade m_trade; // Objekt der Handelsklasse MQL5
CSymbolInfo m_symbol; // Symbolinformationen
CPositionInfo m_position; // Positionsangaben
datetime lastSignalTime = 0;
int lastSignalType = -1;
bool isTradeAllowed = true;
//+------------------------------------------------------------------+
//| Experten-Initialisierungsfunktion |
//+------------------------------------------------------------------+
int OnInit(){
m_symbol.Name(_Symbol);
if(!m_symbol.RefreshRates())
{
Print("Symbol konnte nicht initialisiert werden");
return INIT_FAILED;
}
m_trade.SetExpertMagicNumber(InpMagicNumber);
m_trade.SetDeviationInPoints(InpMaxSlippage);
m_trade.SetTypeFilling(ORDER_FILLING_FOK);
if(GlobalVariableCheck(InpSignalPrefix + "SIGNAL_ACTIVE"))
{
Print("ISP-Indikator erkannt");
}
sonst
{
Print("Warnung: Kein Indikator erkannt oder keine aktiven Signale");
}
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Experten-Deinitialisierungsfunktion |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Print("ISP EA Shutdown");
}
//+------------------------------------------------------------------+
Expert Tick Funktion //| Expert Tick Funktion
//+------------------------------------------------------------------+
void OnTick()
{
CheckForNewSignals();
}
//+------------------------------------------------------------------+
//| Indikator ke neue Signale prüfen karo |
//+------------------------------------------------------------------+
void CheckForNewSignals()
{
if(!GlobalVariableCheck(InpSignalPrefix + "SIGNAL_ACTIVE"))
zurück;
double signalActive = GlobalVariableGet(InpSignalPrefix + "SIGNAL_ACTIVE");
if(signalActive != 1.0)
return;
int signalType = (int)GlobalVariableGet(InpSignalPrefix + "SIGNAL_TYPE");
double signalPrice = GlobalVariableGet(InpSignalPrefix + "SIGNAL_PRICE");
datetime signalTime = (datetime)GlobalVariableGet(InpSignalPrefix + "SIGNAL_TIME");
if(signalTime <= lastSignalTime)
zurück;
lastSignalTime = signalTime;
lastSignalType = signalType;
Print("Neues Signal erkannt: ", (signalType == 0 ? "BUY" : "SELL"),
" at Price: ", signalPrice,
" Time: ", TimeToString(signalTime));
ExecuteTrade(signalType, signalPrice);
// Signal ko deaktivieren kardo (tak dobara na chale)
GlobalVariableSet(InpSignalPrefix + "SIGNAL_ACTIVE", 0.0);
}
//+------------------------------------------------------------------+
//| Signal ke basis par trade execute karo |
//+------------------------------------------------------------------+
void ExecuteTrade(int signalType, double signalPrice)
{
m_symbol.RefreshRates();
bool positionExists = false;
for(int i = PositionsTotal() - 1; i >= 0; i--)
{
if(PositionGetSymbol(i) == _Symbol && PositionGetInteger(POSITION_MAGIC) == InpMagicNumber)
{
PositionExists = true;
break;
}
}
if(positionExists && InpCloseOnOpposite)
{
CloseAllPositions();
Print("Bestehende Position aufgrund eines neuen Signals geschlossen");
}
else if(positionExists)
{
Print("Position existiert bereits, neue Position wird nicht eröffnet.");
zurück;
}
double slPreis = 0.0, tpPreis = 0.0;
double point = m_symbol.Point();
if(InpStopLoss > 0)
{
slPrice = signalPrice + (signalType == 0 ? -1 : 1) * (InpStopLoss * point);
}
if(InpTakeProfit > 0)
{
tpPreis = signalPreis + (signalType == 0 ? 1 : -1) * (InpTakeProfit * Punkt);
}
if(signalType == 0) // BUY-Signal
{
double ask = m_symbol.Ask();
if(!m_trade.Buy(InpLotSize, _Symbol, ask, slPrice, tpPrice, "ISP EA BUY Signal"))
{
Print("Buy trade failed: ", m_trade.ResultRetcodeDescription());
}
sonst
{
Print("Buy trade executed at ", ask, " Lot: ", InpLotSize);
}
}
else if(signalType == 1) // SELL-Signal
{
double bid = m_symbol.Bid();
if(!m_trade.Sell(InpLotSize, _Symbol, bid, slPrice, tpPrice, "ISP EA SELL Signal"))
{
Print("Sell trade failed: ", m_trade.ResultRetcodeDescription());
}
sonst
{
Print("Sell trade executed at ", bid, " Lot: ", InpLotSize);
}
}
}
//+------------------------------------------------------------------+
//| CloseAllPositions |
//+------------------------------------------------------------------+
void CloseAllPositions()
{
for(int i = PositionsTotal() - 1; i >= 0; i--)
{
string symbol = PositionGetSymbol(i);
ulong magic = PositionGetInteger(POSITION_MAGIC);
if(symbol == _Symbol && magic == InpMagicNumber)
{
ulong ticket = PositionGetInteger(POSITION_TICKET);
double volume = PositionGetDouble(POSITION_VOLUME);
if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
{
// Position kaufen ko schließen
m_trade.Sell(Volumen, _Symbol);
}
else if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
{
// Position verkaufen ko schließen
m_trade.Buy(Volumen, _Symbol);
}
if(m_trade.ResultRetcode() == TRADE_RETCODE_DONE)
{
Print("Geschlossene Position: Ticket ", ticket);
}
}
}
}
