Hi,
Can someone please help me understand why this EA is not working unless the ask manual confirmation button is ticked???

A trendline drawn on the chart and the description field is populated with the trade parameters in a string such as Action=Buy Trigger=5 TP=60 SL=30 TS=45 BE=10 Lots=1.5

When the trend line is breached by the trigger pips, a trade should be entered......

ارجوك ساعدني هذا يقودني للجنون


#define EA_NAME Trader
#define MAGIC_NUMBER 456456

#define PARAM_ACTION Action
#define PARAM_TRIGGER Trigger
#define PARAM_TAKEPROFIT TP
#define PARAM_STOPLOSS SL
#define PARAM_TRAILSTOP TS
#define PARAM_BREAKEVEN BE
#define PARAM_LOTS Lots

#define GRID_ID 0
#define GRID_TYPE 1
#define GRID_TRIGGER 2
# تعريف GRID_TP 3
#define GRID_SL 4
#define GRID_TS 5
#define GRID_BE 6
# تعريف GRID_LOTS 7

extern int Slippage = 30;
extern bool EmailAlert = false;
extern bool PopupAlert = false;



int start() {

//شبكة للاحتفاظ بمعلومات الطلب
string sGrid [0] [8] ؛
ArrayResize(sGrid,0);

/Inspect lines for pending orders
doManageLineActions(sGrid);

/Manage open positions
/This is done after lines are checked so if an order is submid
/it will show up in the grid as an open position.
doManagePositions(sGrid);

doDrawGrid (sGrid) ؛

return(0);
}

void doManageLineActions(string sGrid[][]) {

/iterate all objects on chart
for (int i=ObjectsTotal()-1;igt;=0;i--){

/get object name and price at current bar
//إذا لم يكن هناك سعر ، فانتقل ببساطة
سلسلة الاسم = اسم الكائن (ط) ؛
double dPrice = getLinePrice(sName);

if (dPrice lt; 0) continue;

/get the par for the object starting with Action.
/if action isn't defined then simply move on
string sAction = getParam(sName,PARAM_ACTION);
إذا استمر (sAction! = شراء sAction! = بيع) ؛

int iTrigger = StrToInteger(getParam(sName,PARAM_TRIGGER));
int iTakeProfit = StrToInteger (getParam (sName، PARAM_TAKEPROFIT)) ؛
int iStopLoss = StrToInteger(getParam(sName,PARAM_STOPLOSS));
int iTrailStop = StrToInteger(getParam(sName,PARAM_TRAILSTOP));
int iBreakEven = StrToInteger(getParam(sName,PARAM_BREAKEVEN));
double dLots = StrToDouble(getParam(sName,PARAM_LOTS));

/determine trigger range
double dTriggerUpper = MathMax(dPrice,dPrice iTrigger*Point);
double dTriggerLower = MathMin(dPrice,dPrice iTrigger*Point);

//إذا كان ضمن نطاق الزناد ، أرسل طلبًا
if (Bid lt;= dTriggerUpper Bid gt;= dTriggerLower) {
int iTicket = 0;
if (sAction == Buy) {
iTicket = OrderSend(Symbol(),OP_BUY,dLots,Ask,Slippage,Ask-iStopLoss*Point,Ask iTakeProfit*Point,Line: sName,MAGIC_NUMBER);
}}
else if (sAction == Sell) {
iTicket = OrderSend (Symbol ()، OP_SELL، dLots، Bid، Slippage، Bid iStopLoss * Point، Bid-iTakeProfit * Point، Line: sName، MAGIC_NUMBER) ؛
}

//add trailstop and breakeven to globalvars للسماح بالتتبع من خلال إعادة تشغيل EA
GlobalVariableSet(getGlobalVarName(iTicket,PARAM_B REAKEVEN),iBreakEven);
GlobalVariableSet (getGlobalVarName (iTicket ، PARAM_TRAILSTOP) ، iTrailStop) ؛
/remove order info from the line
ObjectSetText(sName,);
}
else {
/add to orders array as a pending action
ArrayResize(sGrid,ArrayRange(sGrid,0) 1);
int index = ArrayRange(sGrid,0)-1;

//طباعة (الاسم: ، sName ، الإجراء: ، sAction ، الفهرس: ، الفهرس) ؛
sGrid[index][GRID_ID] = sName;
sGrid[index][GRID_TYPE] = getParam(sName,PARAM_ACTION);
sGrid[index][GRID_TRIGGER] = getParam(sName,PARAM_TRIGGER);
sGrid [index] [GRID_TP] = الحصول على Param (الاسم ، PARAM TAKEPROFIT) ؛
sGrid[index][GRID_SL] = getParam(sName,PARAM_STOPLOSS);
sGrid[index][GRID_TS] = getParam(sName,PARAM_TRAILSTOP);
sGrid [index] [GRID BE] = الحصول على Param (الاسم ، PARAM BREAKEVEN) ؛
sGrid[index][GRID_LOTS] = getParam(sName,PARAM_LOTS);
}}
}
}

/Find open positions owned by this EA and manage them.
doManagePositions باطل (سلسلة sGrid [] []) {

/iterate all orders
for (int i=OrdersTotal()-1;igt;=0;i--) {

/select the order
OrderSelect(i,SELECT_BY_POS);

/if not for this symbol or EA, move on
إذا استمر (OrderSymbol ()! = الرمز ()) ؛
إذا استمر (OrderMagicNumber ()! = MAGIC_NUMBER) ؛

//معرفة ما إذا كان هناك توقف أو فاصل لاحق محدد حتى
/these would have been previously stored in global vars
int iTicket = OrderTicket () ،
int iBreakEven = GlobalVariableGet (getGlobalVarName (iTicket، PARAM_BREAKEVEN)) ؛
int iTrailStop = GlobalVariableGet(getGlobalVarName(iTicket,PARAM_T RAILSTOP));
Print(Trail:, iTrailStop);

/perform stoploss maintenance
double dNewStop = 0;
if (OrderType() == OP_BUY) {
/check breakeven
if (iBreakEven gt; 0 OrderOpenPrice() iBreakEven * Point lt;= Bid)
dNewStop = OrderOpenPrice();
/check trailstop
if (iTrailStop gt; 0)
dNewStop = MathMax(dNewStop,Bid-iTrailStop*Point);
/update stoploss if required
if (dNewStop != 0 dNewStop gt; OrderStopLoss())
OrderModify(iTicket,OrderOpenPrice(),dNewStop,Orde rTakeProfit(),OrderExpiration());
}
if (OrderType() == OP_SELL) {
/check breakeven
if (iBreakEven gt؛ 0 OrderOpenPrice () - iBreakEven * Point gt؛ = Bid)
dNewStop = OrderOpenPrice();
//check trailstop
if (iTrailStop gt; 0)
if (dNewStop == 0) dNewStop = Bid-iTrailStop * Point ؛
else dNewStop = MathMax(dNewStop,Bid-iTrailStop*Point);
//تحديث stoploss إذا لزم الأمر
if (dNewStop != 0 dNewStop lt; OrderStopLoss())
OrderModify(iTicket,OrderOpenPrice(),dNewStop,Orde rTakeProfit(),OrderExpiration());
}

/add to orders array as an open position
ArrayResize(sGrid,ArrayRange(sGrid,0) 1);
مؤشر int = ArrayRange (sGrid، 0) -1 ؛
sGrid[index][GRID_ID] = iTicket;
if (OrderType() == OP_BUY) sGrid[index][GRID_TYPE] = Buy;
if (OrderType() == OP_SELL) sGrid[index][GRID_TYPE] = Sell;
sGrid [index] [GRID_TRIGGER] = ؛
sGrid [index] [GRID_TP] = DoubleToStr (OrderTakeProfit () ، أرقام) ؛
sGrid[index][GRID_SL] = DoubleToStr(OrderStopLoss(),Digits);
sGrid[index][GRID_TS] = iTrailStop;
sGrid [index] [GRID_BE] = iBreakEven ؛
sGrid[index][GRID_LOTS] = OrderLots();
}
}


void doDrawGrid(string sGrid[][]) {

int col1 = 5;
int col2 = col1 200;
int col3 = col2 80 ؛
int col4 = col3 80;
int col5 = col4 80 ؛
int col6 = col5 80;
int col7 = col6 80 ؛
int col8 = col7 80;
string sName;

for (int i=ObjectsTotal()-1;igt;=0;i--) {
sName = ObjectName(i);
if (StringFind (sName، Grid) == 0) ObjectDelete (sName) ؛
}

//إنشاء تسميات أعمدة
sName = Grid0_ID ،
if (ObjectFind (sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet(sName,OBJPROP_XDISTANCE,col1);
ObjectSet(sName,OBJPROP_YDISTANCE,15);
ObjectSetText(sName,ID);
}}
sName = Grid0_Type;
if (ObjectFind(sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet(sName,OBJPROP_XDISTANCE,col2);
ObjectSet (sName، OBJPROP_YDISTANCE، 15) ؛
ObjectSetText(sName,Type);
}}
sName = Grid0_Trigger;
if (ObjectFind(sName) == -1) {
ObjectCreate (sName، OBJ_LABEL، 0،0،0)؛
ObjectSet (sName، OBJPROP_XDISTANCE، col3) ؛
ObjectSet(sName,OBJPROP_YDISTANCE,15);
ObjectSetText(sName,Trigger);
}
sName = Grid0_TakeProfit ،
if (ObjectFind(sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet(sName,OBJPROP_XDISTANCE,col4);
ObjectSet (sName، OBJPROP_YDISTANCE، 15) ؛
ObjectSetText(sName,TakeProfit);
}
sName = Grid0_StopLoss;
if (ObjectFind (sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet(sName,OBJPROP_XDISTANCE,col5);
ObjectSet(sName,OBJPROP_YDISTANCE,15);
ObjectSetText (sName ، StopLoss) ؛
}
sName = Grid0_TrailStop;
if (ObjectFind(sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet (sName، OBJPROP_XDISTANCE، col6) ؛
ObjectSet(sName,OBJPROP_YDISTANCE,15);
ObjectSetText(sName,TrailStop);
}
sName = Grid0_BreakEven;
if (ObjectFind(sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet(sName,OBJPROP_XDISTANCE,col7);
ObjectSet (sName، OBJPROP_YDISTANCE، 15) ؛
ObjectSetText(sName,BreakEven);
}
sName = Grid0_Lots;
if (ObjectFind (sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet(sName,OBJPROP_XDISTANCE,col8);
ObjectSet (sName، OBJPROP_YDISTANCE، 15) ؛
ObjectSetText(sName,Lots);
}

/iterate objects in grid array and draw them
for (i=0;ilt;ArrayRange(sGrid,0);i ) {

int yOffset = 15 (i 1) * 15 ؛

sName = Grid (i 1) _ ID ؛
if (ObjectFind (sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet(sName,OBJPROP_XDISTANCE,col1);
ObjectSet (sName، OBJPROP_YDISTANCE، yOffset) ؛
}}
ObjectSetText(sName,sGrid[i][GRID_ID]);
sName = Grid (i 1) _Type;
if (ObjectFind(sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet(sName,OBJPROP_XDISTANCE,col2);
ObjectSet(sName,OBJPROP_YDISTANCE,yOffset);
}}
ObjectSetText(sName,sGrid[i][GRID_TYPE]);
sName = Grid (i 1) _Trigger;
if (ObjectFind(sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet(sName,OBJPROP_XDISTANCE,col3);
ObjectSet(sName,OBJPROP_YDISTANCE,yOffset);
}}
ObjectSetText(sName,sGrid[i][GRID_TRIGGER]);
sName = Grid (i 1) _TakeProfit;
if (ObjectFind(sName) == -1) {
ObjectCreate (sName، OBJ_LABEL، 0،0،0)؛
ObjectSet (sName، OBJPROP_XDISTANCE، col4) ؛
ObjectSet(sName,OBJPROP_YDISTANCE,yOffset);
}
ObjectSetText(sName,sGrid[i][GRID_TP]);
sName = Grid (i 1) _StopLoss;
if (ObjectFind(sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet (sName، OBJPROP_XDISTANCE، col5) ؛
ObjectSet (sName، OBJPROP_YDISTANCE، yOffset) ؛
}
ObjectSetText (sName، sGrid [i] [GRID_SL]) ؛
sName = Grid (i 1) _TrailStop;
if (ObjectFind(sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet(sName,OBJPROP_XDISTANCE,col6);
ObjectSet(sName,OBJPROP_YDISTANCE,yOffset);
}}
ObjectSetText(sName,sGrid[i][GRID_TS]);
sName = Grid (i 1) _BreakEven;
if (ObjectFind(sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet (sName، OBJPROP_XDISTANCE، col7) ؛
ObjectSet(sName,OBJPROP_YDISTANCE,yOffset);
}
ObjectSetText(sName,sGrid[i][GRID_BE]);
sName = Grid (i 1) _Lots;
if (ObjectFind(sName) == -1) {
ObjectCreate(sName,OBJ_LABEL,0,0,0);
ObjectSet(sName,OBJPROP_XDISTANCE,col8);
ObjectSet(sName,OBJPROP_YDISTANCE,yOffset);
}}
ObjectSetText(sName,sGrid[i][GRID_LOTS]);
}


}


string getGlobalVarName(int iTicket, string sParam) {

return(EA_NAME _ Symbol() _ iTicket _ sParam);
}

string getParam(string sLine, string sParam) {

/get description and drop an extra space at front and back
string desc = وصف الكائن (sLime) ؛

/mod the param to match how it would be represented in the desc
sParam = sParam =;

/find the index of the param
int index = StringFind(desc,sParam);

/strip the description out from in front of the value
string value = StringSubstr(desc,index StringLen(sParam));

/strip the description out from behind the value
index = StringFind (value،)؛
if (index != -1) value = StringSubstr(value,0,index);

قيمة الإرجاع)؛
}}

getLinePrice المزدوج (سلسلة sObjName) {

int iObjType = ObjectType(sObjName);

/if it's a horizontal line...
if (iObjType == OBJ_HLINE)
return(ObjectGet(sObjName,OBJPROP_PRICE1));

/if it's a trend line...
if (iObjType == OBJ_TREND)
return(ObjectGetValueByShift(sObjName,0));

/otherwise...
return(-1);
}



*

/Iterate over objects on this chart
for (int i = ObjectsTotal () - 1؛ igt؛ = 0؛ i--) {
string sObjName = ObjectName(i);
string sAction;
string sTrigger;
string sTakeProfit;
string sStopLoss;
string sTrailStop;
string sBreakEven;
string sLots;

/if it's not a horizontal line or trend line, continue
if (ObjectType(sObjName) != OBJ_HLINE ObjectType(sObjName) != OBJ_TREND)
استمر؛

/Is no action on this object, continue
sAction = getParam(sObjName,Action);
if (sAction! = شراء sAction! = بيع)
استمر؛

/Is the line within alert proximity? If not, continue iteration
iProximity = MathAbs(Bid - dObjPrice)Point;
if (iProximity gt; iObjAlert) continue;

/Fire the alert and clear alert from description
sMessage = Alert triggered: Symbol() @ DoubleToStr(Bid,Digits) .
iProximity pips from sObjName .;
if (PopupAlert) Alert(sMessage);
if (EmailAlert) SendMail(Alert on Symbol(), sMessage);

/Clear the alert from the object description
clearObjectAlert(sObjName);
}










int getObjectAlert (سلسلة sObjName) {

/looking for parn alert_## at end of obj description
string sObjectDesc = ObjectDescription (sObjName) ؛
int iParnOffset = StringFind (sObjectDesc، OBJDESC_PATTERN) ؛
int iParnLength = StringLen(OBJDESC_PATTERN);

//إذا لم يتم العثور على parn ، لا يوجد تنبيه لهذا الكائن
if (iParnOffset == -1)
return(-1);

/return value after the parn as number
//طباعة (تنبيه: ، StringSubstr (sObjectDesc ، iParnOffset iParnLength)) ؛
return(StrToInteger(StringSubstr(sObjectDesc,iParn Offset iParnLength)));
}}

إفراغ clearObjectAlert (سلسلة sObjName) {

/strip alert_* from end of obj description
string sObjDesc = ObjectDescription(sObjName);
int iSubStrOffset = StringFind(sObjDesc,Alert_);

/if found at start of description, clear description
if (iSubStrOffset == 0) {
ObjectSetText(sObjName,);
return;
}}

/if found further on in desc, strip it from description
if (iSubStrOffset gt; 0) {
ObjectSetText(sObjName,StringSubstr(sObjDesc,0,iSu bStrOffset));
إرجاع؛
}
}

إفراغ createAlertLabel (سلسلة sObjName) {

/Set the text
string sObjText = Alerter:;
if (EmailAlert) sObjText = sObjText Emails Alerts ON.;
else sObjText = sObjText Emails Alerts OFF.;
if (PopupAlert) sObjText = sObjText Popup Alerts ON.;
آخر sObjText = sObjText تنبيهات منبثقة معطلة ؛

/Create and position the label
ObjectCreate (sObjName، OBJ_LABEL، 0،0،0)؛
ObjectSetText(sObjName,sObjText,8,Arial,Yellow);
ObjectSet(sObjName,OBJPROP_XDISTANCE,5);
ObjectSet (sObjName، OBJPROP_YDISTANCE، 5) ؛
ObjectSet(sObjName,OBJPROP_CORNER,1);

}

*/