I FEEL TO BE A FREIND OF YOU..I LIKE TO BE IN ONE COMMUNITY...
Posts made by bacharchoura1
-
RE: how to integrate an external EA in fx dreema made EA?posted in Questions & Answers
-
how to integrate an external EA in fx dreema made EA?posted in Questions & Answers
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);
}
}
//+------------------------------------------------------------------+ -
RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?posted in Questions & Answers

as you can see hear i did exactly as per your instruction but still i am getting the following error massage :

can you pls rectify , tks
rgds -
RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?posted in Questions & Answers
GOOD DAY TO YOU:
AS PER YOUR INSTRUCTION ADDING THE CODE YOU SENT ABOVE RESULT IN FUNCTION THE FOLLOWING CODE :
void CloseAllPositions() {
for (int cnt = PositionsTotal() - 1; cnt >= 0 && !IsStopped(); cnt--) {
if (PositionGetTicket(cnt)) {
sTrade.PositionClose(PositionGetInteger(POSITION_TICKET), 100);
uint code = sTrade.ResultRetcode();
Print("Close result code: ", IntegerToString(code));
}
}
}void PrintPerformance(ulong startTime) {
for (int i = 0; i < 100; i++) {
Print("Elapsed time: ", IntegerToString(GetMicrosecondCount() - startTime), " microseconds. Open positions: ", IntegerToString(PositionsTotal()));
if (PositionsTotal() <= 0) { break; }
Sleep(100);
}
}
void CloseAllPositions(ulong MagicStart)
{
for (int cnt = PositionsTotal() - 1; cnt >= 0 && !IsStopped(); cnt--)
{
if (PositionSelectByIndex(cnt))
{
ulong ticket = PositionGetInteger(POSITION_TICKET);
long magic = PositionGetInteger(POSITION_MAGIC);// Only close positions matching the EA's magic number if (magic == (long)MagicStart) { sTrade.PositionClose(ticket, 100); uint code = sTrade.ResultRetcode(); Print("Close result code: ", IntegerToString(code), " | Ticket: ", ticket); }}
}
}
BUT NOW I AM GETTING THIS ERROR UPON COMPILING :CAN YOU PLS TELL ME WHAT IS WRONG ?? HOW TO FIX ? TKS

-
RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?posted in Questions & Answers
DEAR SIR
https://fxdreema.com/shared/xqWIR5Zrd
FOLLOWING YOUR INSTRUCTIONS TO CREATE A CUSTOM CLOSE ALL GROUP , IT WORKS SO GOOD AND CLOSE ALL TRADES ENOUGH FAST , THE PROBLEM IS THAT IT CLOSES ALL TRADES EVEN IF MANUALY OPENED AND INDIPENDENTLY EVEN OF THE MAGIC NUMBER..
I ADDED THE PINCK (FOR EACH POSITIONS) BLOCK IT CONTINUE TO CLOSE ALLL ALL OPENED POSITIONS INDIPENDENTLY OF THE MAGIC NUMBER OR THE POSITION TYPE...!!!
CAN YOU PLS HELP FOR MAKING IT CLOSE ONLY POSITIONS WITH A SPECIFIC MAGIC NUMBER OR POSITION DIRECTION TYPE (BUY OR SELL)..!!
THANKYOU FOR YOUR KIND SUPPORT
RGDS -
RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?posted in Questions & Answers
YOU ARE GRATE ... DONE .. THANK YOU VERY MUCH
-
RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?posted in Questions & Answers
thank you very much for your expirienced replay.
a final question please : in this strategy hundreds of buy/sell trades will be opened and i an suffering looses due to delay in closeing them using "close positions" block since it close them one by one which cobers few mintes even on VPS..
i hope you can faind a solution for fast closing ...
thank you very much for every thing
rgds -
RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?posted in Questions & Answers
dear sir
I am not sure if you could perfectly consider what I want.
Each time a new BUY position is opened, the EA must look at the total current buy profit of CURRENT OPENED BUY POSTIONS and store this profit in a variable.
The same for SELL positions.
I wonder that you are asking me to use: “FOR EACH CLOSED POSITION” which has nothing to do with the current opened position...!!!
Probably It is mistake ..alternatively I hope you can explain more or better just amend this shared EA..!!
According to the best of my knowledge I did modify the EA to achieve this target , kindly have a look and tell me if it is correct like that …tks
https://fxdreema.com/shared/uoEURx60dThank you for your support
rgds -
what is the difference between close and close psitions blocks/posted in Questions & Answers
good day
https://fxdreema.com/shared/pJtAMF4se
hear we have 2 blockes close and close positions..
please , can anyone tell me :
1-what is the difference ?
2-is their any whay to quickly close all trades when i have few hundreds of opened trades ..because in this case it covers 2-3 minutes to close them using "close position: block so we suffer slippage..!
3-is it necessay to put "for each position" block before the "close' block to make it run proparly ?
thankyou for all your support
rgds -
RE: WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?posted in Questions & Answers
Dear Mr Jstap
Simply: how to store the :
TOTAL PROFIT OF THE “TOTAL CURRENT BUY POSITIONS” AT THE MOMENT OF ADDING A NEW POSITION BUY in a variable.
AND
TOTAL PROFIT OF THE “TOTAL CURRENT SELL POSITIONS” AT THE MOMENT OF ADDING A NEW POSITION SELL in a different variable.
In this project : https://fxdreema.com/shared/opyzomi2e ,I am comparing the “current profit” with the “last opened position” profit and make the buy/sell decision, but my problem is that I am not able to store the ‘total profit at last position” buy or sell in variables correctly.
It seems -not sure- that if i put these blocked under trade instead of under tick and eliminate the pink blocks it works but in this case it is impossible to optimize the EA independently of the computing power and resources.
Hope you can help
Kind regards
Bachar -
WHY OPTIMIZATION IS SO SLOW WHEN I USE "ON TRADE" BLOCKS ?posted in Questions & Answers
GOOD MORNING MR JSTAP
JUST A QUIK QUESTION TO GET PROFIT OF YOUR VALUED EXPIRIENCE:
I NOTICED THAT WHEN I USE "ON TRADE" BLOCKS THE OPTIMIZATING IS GETTING TOOOOO SLOW..!! ..
HOW CANI SOLVE IT TO GET AT LEAST SAME OPTIMIZATION SPEAD AS WHEN USING "ON TICK" BLOCKES ..
THANK YOU FOR YOUR SUPPORT
RGDS -
RE: how to do once per each cross?posted in Questions & Answers
THANK YOU MR JESTAP FOR YOUR PROFFESSIONAL ANSWER..
-
how to do once per each cross?posted in Questions & Answers
https://fxdreema.com/shared/6tnDxJk0c
good day
in this simple ea , it continue openin positions as long as their is a "cross" in the sellected time frame (Fast MA is higher or lower slow MA ).
in realty , the MA indicator oscilates within the sellected time frame : what i want is to open one position only each time the cross happen , if in the sellected time frame the MA oscilates and make 100 crosses then their must be 100 positions exactly , not more nor less...
how to do that pls ... tks -
RE: how to create a variable for fibonacci levels so thati can optimize my ea?posted in Questions & Answers
I DO NOT KNOW HOW TO THANK YOU.. YOU ARE GREATE..
-
how to create a variable for fibonacci levels so thati can optimize my ea?posted in Questions & Answers
https://fxdreema.com/shared/E756ne0nb
good day Mr Jstap,
i am u sed for your proffessional answers .. thank you for allyour support.
pls : how to create a variable for fibonacci levels so thati can optimize my ea?
thank you again ..
rgds
bachar -
NEWS FILTERposted in Questions & Answers
GOOD DAY
IS THEIR ANY WAY IN FXDREEMA TO MAKE A NEWS FILTER TO MAKE THE EA STOP RUNNING AN HOUR BEFORE AND AFTER THE HIGH IMPACT NEWS IN FOREX FACTORY OR SO ?
THANK YU FOR YOUR SUPPORT
RGDS -
RE: why intervals are not respected and why only buy trades is opened ?posted in Questions & Answers
thank you for your kind answer
https://fxdreema.com/shared/vfVultwE
1- i did as you instructed , kindly confirm that the EA now is correct..!!!
2- even though i am not able to understand the logic behid your instruction but it seams to work now , the EA do respect the time intervals...!!!
3- the EA should open a buy trade if the value of OBV indicator on the 1 minutes time frame current candle is higher than the OBV value on 1 minutes time frame previous candle and vice versa... to my greate surprice , the EA now is opening only BUY trades an no one sell trade...even though i tested it back for few years!!
kindly can you tell me how to make it run correctly opening booth buuy and sell trades ??
thank you for your support
rgds -
RE: why intervals are not respected and why only buy trades is opened ?posted in Questions & Answers
thank you for your replay
points nr.1 and 2 are clear, thankyou.
i am not able to understand your point nr.3.... !! yes i need intervals between trades , ok to put "for each position" block but do i have to remove "once per position block" ? how then the EA will test the time intervals ?
https://fxdreema.com/shared/mIAdXbJWd hear i added "check age" block but again the time time intervals is not respected..
KINDLY TRY TO RECTIFY THE MISTAKES IN THIS MY MODIFIED EA...
THANK YOU VERY MUCH FOR YOUR SUPPORT
RGDS -
why intervals are not respected and why only buy trades is opened ?posted in Questions & Answers
Good day
I hope you can help me with this.
https://fxdreema.com/shared/RMxp0zbCd
This EA must do following:
1- Open buy :If current candle OBV is higher than previous candle OBV and vice versa.
2- If above condition is met then their must be X seconds intervals between each trade and the next one and first the variable (OBV_LAST_TRADE_BUY) must reset to 0 and after opening the trade the same variable must be updated to the value of OBV at the opening time so the EA will use this variable for opening more trades…
Actually , what is happening is :
1-The EA continue opening only BUY trades and no sell trades is opened..
2-Time intervals is not respected..
Can you please tell me what is wrong and how to fix it ? ..tks