ستكون هذه مشاركة طويلة مع الكثير من أسطر الشفرة ...

لديّ رمزًا حاليًا يعمل على النحو المطلوب ويأخذ مواقع متعددة ويغلق عند مستويات SL و TP المخفية.

أريد أن أضيف إلى وظائف الكود الموجودة التي تسمح لـ EA بالإغلاق والعكس إذا تم إنشاء إشارات قبل أن يتم ضرب SL أو TP.

إليك الشفرة الحالية التي تعمل جيدًا:

الرمز المدرج/---------------------------------------------- ----/المعلمات التجارية/---------------------------------------- ---------- RefreshRates ()؛ {if (CUSTOM TRADING SIGNAL FOR BUY) {if ((Hour () == 0) (Minute () == 0)) Sleep (60000)؛ {fBuy1 ()؛ fBuy2 ()؛ fBuy3 ()؛ fBuy4 ()؛ fBuy5 ()؛ fBuy6 ()؛ }} إذا (إشارة التداول CUSTOM FOR SELL) {if ((Hour () == 0) (Minute () == 0)) Sleep (60000)؛ {fSell1 ()؛ fSell2 ()؛ fSell3 ()؛ fSell4 ()؛ fSell5 ()؛ fSell6 ()؛ }}}}/-------------------------------------------- ------/يشترى/--------------------------------------- ----------- void fBuy1 () {int result = OrderSend (ST1، OP_BUY، Lots، Ask، Slippage، 0،0، Open LONG Magic1، Magic1،0، Blue)؛ OrderSelect (result، SELECT_BY_TICKET، MODE_TRADES)؛ طباعة (BUY ORDER OPENED !، #، result، at، DoubleToStr (OrderOpenPrice ()، Digits)،، SL:، DoubleToStr (OrderStopLoss ()، Digits)،، TP:، DoubleToStr (OrderTakeProfit ()، Digits)،، OpenTrades :، OrdersTotal ()،، Close # 91؛ 1 # 93 ؛:، Close # 91؛ 1 # 93؛)؛ إذا كان (SignalMail) SendMail (EA OPEN TRADE ALERT !، BUY ORDER OPENED! ST1 ، # result at DoubleToStr (OrderOpenPrice ()، Digits) ، SL: DoubleToStr (OrderStopLoss ()، Digits) ، TP : DoubleToStr (OrderTakeProfit () ، أرقام)) ؛ if (result ==-1) {int e = GetLastError ()؛ طباعة (ه)؛ }} void fBuy2 () {int result = OrderSend (ST1، OP_BUY، Lots، Ask، Slippage، 0،0، Open LONG Magic2، Magic2،0، Blue)؛ OrderSelect (result، SELECT_BY_TICKET، MODE_TRADES)؛ طباعة (BUY ORDER OPENED !، #، result، at، DoubleToStr (OrderOpenPrice ()، Digits)،، SL:، DoubleToStr (OrderStopLoss ()، Digits)،، TP:، DoubleToStr (OrderTakeProfit ()، Digits)،، OpenTrades :، OrdersTotal ()،، Close # 91؛ 1 # 93 ؛:، Close # 91؛ 1 # 93؛)؛ إذا كان (SignalMail) SendMail (EA OPEN TRADE ALERT !، BUY ORDER OPENED! ST1 ، # result at DoubleToStr (OrderOpenPrice ()، Digits) ، SL: DoubleToStr (OrderStopLoss ()، Digits) ، TP : DoubleToStr (OrderTakeProfit () ، أرقام)) ؛ if (result ==-1) {int e = GetLastError ()؛ طباعة (ه)؛ }} ETC ... يستمر تكرار الكود من خلال VoidfBuy6/------------------------------------- -------------/يبيع/-------------------------------- ------------------ void fSell1 () {int result = OrderSend (ST1، OP_SELL، Lots، Bid، Slippage، 0،0، Open SHORT Magic1، Magic1،0، أحمر)؛ OrderSelect (result، SELECT_BY_TICKET، MODE_TRADES)؛ طباعة (SELL ORDER OPENED !، #، result، at، DoubleToStr (OrderOpenPrice ()، Digits)،، SL:، DoubleToStr (OrderStopLoss ()، Digits)،، TP:، DoubleToStr (OrderTakeProfit ()، Digits)،، OpenTrades :، OrdersTotal ()،، Close # 91؛ 1 # 93 ؛:، Close # 91؛ 1 # 93؛)؛ إذا كان (SignalMail) SendMail (EA OPEN TRADE ALERT !، بيع طلب فتح! ST1 ، النتيجة DoubleToStr (OrderOpenPrice () ، Digits) ، SL: DoubleToStr (OrderStopLoss () ، Digits) ، TP : DoubleToStr (OrderTakeProfit () ، أرقام)) ؛ if (result ==-1) {int e = GetLastError ()؛ طباعة (ه)؛ }} void fSell2 () {int result = OrderSend (ST1، OP_SELL، Lots، Bid، Slippage، 0،0، Open SHORT Magic2، Magic2،0، Red)؛ OrderSelect (النتيجة ، SELECT_BY_TICKET ،MODE_TRADES)؛ طباعة (SELL ORDER OPENED !، #، result، at، DoubleToStr (OrderOpenPrice ()، Digits)،، SL:، DoubleToStr (OrderStopLoss ()، Digits)،، TP:، DoubleToStr (OrderTakeProfit ()، Digits)،، OpenTrades :، OrdersTotal ()،، Close # 91؛ 1 # 93 ؛:، Close # 91؛ 1 # 93؛)؛ إذا كان (SignalMail) SendMail (EA OPEN TRADE ALERT !، بيع طلب فتح! ST1 ، النتيجة DoubleToStr (OrderOpenPrice () ، Digits) ، SL: DoubleToStr (OrderStopLoss () ، Digits) ، TP : DoubleToStr (OrderTakeProfit () ، أرقام)) ؛ if (result ==-1) {int e = GetLastError ()؛ طباعة (ه)؛ }} void fSell3 () {int result = OrderSend (ST1، OP_SELL، Lots، Bid، Slippage، 0،0، Open SHORT Magic3، Magic3،0، Red)؛ OrderSelect (result، SELECT_BY_TICKET، MODE_TRADES)؛ طباعة (SELL ORDER OPENED !، #، result، at، DoubleToStr (OrderOpenPrice ()، Digits)،، SL:، DoubleToStr (OrderStopLoss ()، Digits)،، TP:، DoubleToStr (OrderTakeProfit ()، Digits)،، OpenTrades :، OrdersTotal ()،، Close # 91؛ 1 # 93 ؛:، Close # 91؛ 1 # 93؛)؛ إذا كان (SignalMail) SendMail (EA OPEN TRADE ALERT !، بيع طلب فتح! ST1 ، النتيجة DoubleToStr (OrderOpenPrice () ، Digits) ، SL: DoubleToStr (OrderStopLoss () ، Digits) ، TP : DoubleToStr (OrderTakeProfit () ، أرقام)) ؛ if (result ==-1) {int e = GetLastError ()؛ طباعة (ه)؛ }} ETC ... يستمر تكرار الكود من خلال VoidfSell6/------------------------------------- -------------/HIDDEN SL TP FUNCTION/----------------------------- --------------------- void hidden_stop_loss () {int totalorders = OrdersTotal ()؛ for (int i = totalorders-1؛ igt؛ = 0؛ i--) {OrderSelect (i، SELECT_BY_POS)؛ bool result = false؛ {if (OrderMagicNumber () == Magic1) {if (OrderType () == OP_BUY iClose (Symbol ()، 1،0) lt؛ NormalizeDouble (OrderOpenPrice () - ((OrderOpenPrice ()100) * StopLossLong1) ، 3 )) result = OrderClose (OrderTicket ()، OrderLots ()، Bid، 50، Red)؛ if (OrderType () == OP_SELL iClose (Symbol ()، 1،0) gt؛ NormalizeDouble (OrderOpenPrice () ((OrderOpenPrice ()100) * StopLossShort1) 3)) result = OrderClose (OrderTicket ()، OrderLots () ، اسأل ، 50 ، أحمر) ؛ } if (OrderMagicNumber () == Magic2) {if (OrderType () == OP_BUY iClose (Symbol ()، 1،0) lt؛ NormalizeDouble (OrderOpenPrice () - ((OrderOpenPrice ()100) * StopLossLong2) ، 3 )) result = OrderClose (OrderTicket ()، OrderLots ()، Bid، 50، Red)؛ if (OrderType () == OP_SELL iClose (Symbol ()، 1،0) gt؛ NormalizeDouble (OrderOpenPrice () ((OrderOpenPrice ()100) * StopLossShort2)، 3)) result = OrderClose (OrderTicket ()، OrderLots () ، اسأل ، 50 ، أحمر) ؛ } if (OrderMagicNumber () == Magic3) {if (OrderType () == OP_BUY iClose (Symbol ()، 1،0) lt؛ NormalizeDouble (OrderOpenPrice () - ((OrderOpenPrice ()100) * StopLossLong3) ، 3 )) result = OrderClose (OrderTicket ()، OrderLots ()، Bid، 50، Red)؛ if (OrderType () == OP_SELL iClose (Symbol ()، 1،0) gt؛ NormalizeDouble (OrderOpenPrice () ((OrderOpenPrice ()100) * StopLossShort3)، 3)) result = OrderClose (OrderTicket ()، OrderLots () ، اسأل ، 50 ، أحمر) ؛ } ETC ... تكرار الكوديستمر من خلال Magic6}}. } void hidden_take_profit () {int totalorders = OrdersTotal ()؛ for (int i = totalorders-1؛ igt؛ = 0؛ i--) {OrderSelect (i، SELECT_BY_POS)؛ bool result = false؛ {if (OrderMagicNumber () == Magic1) {if (OrderType () == OP_BUY iClose (Symbol ()، 1،0) gt؛ NormalizeDouble (OrderOpenPrice () ((OrderOpenPrice ()100) * TakeProfitLong1)، 3 )) result = OrderClose (OrderTicket ()، OrderLots ()، Bid، 50، Red)؛ if (OrderType () == OP_SELL iClose (Symbol ()، 1،0) lt؛ NormalizeDouble (OrderOpenPrice () - ((OrderOpenPrice ()100) * TakeProfitShort1) 3)) result = OrderClose (OrderTicket ()، OrderLots () ، اسأل ، 50 ، أحمر) ؛ } if (OrderMagicNumber () == Magic2) {if (OrderType () == OP_BUY iClose (Symbol ()، 1،0) gt؛ NormalizeDouble (OrderOpenPrice () ((OrderOpenPrice ()100) * TakeProfitLong2) ، 3 )) result = OrderClose (OrderTicket ()، OrderLots ()، Bid، 50، Red)؛ if (OrderType () == OP_SELL iClose (Symbol ()، 1،0) lt؛ NormalizeDouble (OrderOpenPrice () - ((OrderOpenPrice ()100) * TakeProfitShort2)، 3)) result = OrderClose (OrderTicket ()، OrderLots () ، اسأل ، 50 ، أحمر) ؛ } if (OrderMagicNumber () == Magic3) {if (OrderType () == OP_BUY iClose (Symbol ()، 1،0) gt؛ NormalizeDouble (OrderOpenPrice () ((OrderOpenPrice ()100) * TakeProfitLong3)، 3 )) result = OrderClose (OrderTicket ()، OrderLots ()، Bid، 50، Red)؛ if (OrderType () == OP_SELL iClose (Symbol ()، 1،0) lt؛ NormalizeDouble (OrderOpenPrice () - ((OrderOpenPrice ()100) * TakeProfitShort3)، 3)) result = OrderClose (OrderTicket ()، OrderLots () ، اسأل ، 50 ، أحمر) ؛ } ETC ... يستمر تكرار رمز عبر Magic6}} return؛ }
ما ورد أعلاه يعمل بشكل كبير ولكني أردت أن أقوم بإغلاق إغلاق إذا كانت الإشارة العكسية والوظيفة العكسية ...
على الرغم من أن EA تدخل بأعداد متعددة سحرية وتخرج SLs و TPs مخفية بأرقام سحرية متعددة ، فأنا أريدها أن تخرج من جميع المراكز المفتوحة إذا تم إنشاء إشارة معاكسة معاكسة قبل أن يتم ضرب SL أو TP ، وأريد أن ينعكس ويفتح سلسلة جديدة من المواقف المعاكسة.

هذا هو ما حاولت حتى الآن لكنه لا يعمل كما هو متوقع ... أي أفكار أخرى؟ أود استخدام الإطار الحالي ... ماذا أفعل الخطأ هنا؟

Inserted Code {if (CUSTOM TRADING SIGNAL FOR BUY) {if ((Hour () == 0) (Minute () == 0)) Sleep (60000)؛ {CloseSell ()؛ lt؛ lt؛ ----- تمت إضافة هذا التفكير أنه سيعمل منطقيًا ... منطق إضافي أسفل النوم (10000)؛ lt؛ lt؛ ----- إضافة لإعطاء مخزن مؤقت لإغلاق المواقف الحالية قبل تنفيذ مواقف جديدة لا تعتقد أنه يؤثر على المخرج fBuy1 ()؛ fBuy2 ()؛ fBuy3 ()؛ fBuy4 ()؛ fBuy5 ()؛ fBuy6 ()؛ } الخ .../------------------------------------------- -------/الوظيفة الحالية القريبة قبل fOpenPostions/---------------------------------- ---------------- void CloseSell () {int totalorders = OrdersTotal ()؛ for (int i = totalorders-1؛ igt؛ = 0؛ i--) {OrderSelect (i، SELECT_BY_POS)؛ bool result = false؛ {if (OrderType () == OP_SELL) {result = OrderClose (OrderTicket ()، OrderLots ()، Ask، 50، Red)؛ }}}} void CloseBuy () {int totalorders = OrdersTotal ()؛ for (int i = totalorders-1؛ igt؛ = 0؛ i--) {OrderSelect (i، SELECT_BY_POS)؛ bool result = false؛ {if (OrderType () == OP_BUY) {result = OrderClose (OrderTicket ()، OrderLots ()، Bid، 50، Red)؛ } } }/ إرجاع؛ }
لا تعمل الشفرة المضافة كما اعتقدت. أي حلول أخرى؟