how to integrate an external EA in fx dreema made EA?
-
good moring ,
i want to create an EA that detects the nearest support and resistance level to the currently opened position using daily pivot channel indicator so thati can set the TP SL.
i could not do it in fx dreema .. can you help with this ?? tks.
alternativly i could make it using AI buy still i need to integrate the AI code with my EA made in fx dreema , eventually by adding a custom block or condition... can you please tell me how to do that ? : following is the AI code : #property copyright "Meta AI"
#property version "1.2"
#property strict#include <Trade\Trade.mqh>
CTrade trade;
//--- Input parameters
input double TP_Percent = 20; // Take Profit percentage of the distance between support and resistance (%)//+------------------------------------------------------------------+
void OnTick()
{
string currentSymbol = Symbol(); // Current chart symbol//--- Calculate daily pivot levels
double high1 = iHigh(NULL, PERIOD_D1, 1);
double low1 = iLow(NULL, PERIOD_D1, 1);
double close1 = iClose(NULL, PERIOD_D1, 1);if(high1 == 0 || low1 == 0 || close1 == 0) return;
double P = (high1 + low1 + close1) / 3.0;
double R1 = (2 * P) - low1;
double S1 = (2 * P) - high1;
double R2 = P + (high1 - low1);
double S2 = P - (high1 - low1);
double M1 = (P + S1) / 2.0;
double M2 = (S1 + S2) / 2.0;
double M3 = (P + R1) / 2.0;
double M4 = (R1 + R2) / 2.0;double levels[] = {R2, R1, M4, M3, P, M1, S1, M2, S2};
double currentPrice = SymbolInfoDouble(currentSymbol, SYMBOL_BID);
double support = EMPTY_VALUE;
double resistance = EMPTY_VALUE;//--- Find nearest support and resistance levels
for(int i = 0; i < ArraySize(levels); i++)
{
if(levels[i] > currentPrice && (resistance == EMPTY_VALUE || levels[i] < resistance))
resistance = levels[i];
if(levels[i] < currentPrice && (support == EMPTY_VALUE || levels[i] > support))
support = levels[i];
}if(support == EMPTY_VALUE || resistance == EMPTY_VALUE) return;
//--- Draw support and resistance lines
ObjectDelete(0, "Support");
ObjectDelete(0, "Resistance");ObjectCreate(0, "Support", OBJ_HLINE, 0, TimeCurrent(), support);
ObjectSetInteger(0, "Support", OBJPROP_COLOR, clrGreen);
ObjectSetInteger(0, "Support", OBJPROP_WIDTH, 2);
ObjectSetString(0, "Support", OBJPROP_TEXT, "Support: " + DoubleToString(support, _Digits));ObjectCreate(0, "Resistance", OBJ_HLINE, 0, TimeCurrent(), resistance);
ObjectSetInteger(0, "Resistance", OBJPROP_COLOR, clrRed);
ObjectSetInteger(0, "Resistance", OBJPROP_WIDTH, 2);
ObjectSetString(0, "Resistance", OBJPROP_TEXT, "Resistance: " + DoubleToString(resistance, _Digits));//--- Modify Take Profit for open positions on the current symbol
for(int i = PositionsTotal() - 1; i >= 0; i--)
{
ulong ticket = PositionGetTicket(i);
if(PositionSelectByTicket(ticket))
{
// Check if the position is on the same symbol
if(PositionGetString(POSITION_SYMBOL) == currentSymbol)
{
double gap = resistance - support;
double tpLevel;
double openPrice = PositionGetDouble(POSITION_PRICE_OPEN);
double currentTP = PositionGetDouble(POSITION_TP);if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) { tpLevel = NormalizeDouble(resistance - (gap * TP_Percent / 100.0), _Digits); if(tpLevel > openPrice && (currentTP == 0 || MathAbs(currentTP - tpLevel) > _Point)) TradeModifyTake(ticket, tpLevel); } else if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL) { tpLevel = NormalizeDouble(support + (gap * TP_Percent / 100.0), _Digits); if(tpLevel < openPrice && (currentTP == 0 || MathAbs(currentTP - tpLevel) > _Point)) TradeModifyTake(ticket, tpLevel); } } }}
}//+------------------------------------------------------------------+
//| Modify Take Profit for a position |
//+------------------------------------------------------------------+
void TradeModifyTake(ulong ticket, double tp)
{
MqlTradeRequest request;
MqlTradeResult result;
ZeroMemory(request);
ZeroMemory(result);request.action = TRADE_ACTION_SLTP;
request.position = ticket;
request.symbol = PositionGetString(POSITION_SYMBOL);
request.tp = tp;
request.sl = PositionGetDouble(POSITION_SL);bool success = OrderSend(request, result);
if(!success)
{
Print("OrderSend failed. Error: ", GetLastError(), " Ticket: ", ticket);
}
else
{
Print("Take Profit updated successfully for ticket: ", ticket, " New TP: ", tp);
}
}
//+------------------------------------------------------------------+ -
Better start from scratch in fxDreema.
If you want to make use of AI, better use it to develop an indicator first then be used in fxDreema.
Or you can completely use AI to develop the EA, but it seems to me not as flexible as fxDreema
-
@sktsec @bacharchoura1 I disagree with that FX has a lot of very useful blocks, AI can be smart but sometimes too smart. Mixing custom code blocks, indicators, FX blocks can all work together well. This picture shows the amount of AI generated, checked and perfected blocks I am currently using.

-
@jstap
Thanks for sharing. The pipeline integration is inspiring. -
I FEEL TO BE A FREIND OF YOU..I LIKE TO BE IN ONE COMMUNITY...