تحرير تعليقك
MQL4 Stoploss
forex_trader_294488
عضو منذ Dec 28, 2015
8 المشاركات
Feb 10, 2016 at 12:59
عضو منذ Dec 28, 2015
8 المشاركات
Hello everyone. I've coded this piece here:
for(int i=0;iOrderStopLoss()+atr && Close[1]>OrderOpenPrice()+atr) //is the price already greater than the opening price+ATR, and than the stoploss+ATR?
{
bool order = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderStopLoss()+atr-0.0005,5),0,0,clrAquamarine);
if(!order){Alert(GetLastError());}
}
else
{
return;
}
}
}
But the stoploss keeps moving on every tick. I know it is due to the "-0.0005", but I would like to have that added "margin". How could I manage it to stop from moving on every tick, without having to remove this -0.0005 margin?
thank you very much in advance.
for(int i=0;iOrderStopLoss()+atr && Close[1]>OrderOpenPrice()+atr) //is the price already greater than the opening price+ATR, and than the stoploss+ATR?
{
bool order = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderStopLoss()+atr-0.0005,5),0,0,clrAquamarine);
if(!order){Alert(GetLastError());}
}
else
{
return;
}
}
}
But the stoploss keeps moving on every tick. I know it is due to the "-0.0005", but I would like to have that added "margin". How could I manage it to stop from moving on every tick, without having to remove this -0.0005 margin?
thank you very much in advance.
عضو منذ Nov 21, 2011
1601 المشاركات
Feb 10, 2016 at 13:46
عضو منذ Nov 21, 2011
1601 المشاركات
If you wanna place SL when you open orders, then you simply need to adjust SL at this moment using OpenOrder function.
If you wanna place SL at a particular event then you have to add the following condition... Does my SL is null, if so, apply your code else nothing.
So it should do it only once.
If you wanna place SL at a particular event then you have to add the following condition... Does my SL is null, if so, apply your code else nothing.
So it should do it only once.
forex_trader_25447
عضو منذ Dec 21, 2010
127 المشاركات
Feb 10, 2016 at 15:46
عضو منذ Dec 21, 2010
127 المشاركات
I think, hi wanted to realize Trailing Stop at distance (ATR-0.0005)
عضو منذ Mar 02, 2010
95 المشاركات
Feb 13, 2016 at 09:56
عضو منذ Mar 02, 2010
95 المشاركات
you should separate your conditions from ordermodify command!
ixbone@
عضو منذ Apr 20, 2010
808 المشاركات
Feb 14, 2016 at 07:47
عضو منذ Apr 20, 2010
808 المشاركات
You need add the StopLoss Condition.
double stoplossBuy;
if(stoplossBuy < Bid- Close[1]- atr ) stoplossBuy = Bid- - Close[1]- atr ;
// This ensure your stopLossBuy will only move up
double stoplossBuy;
if(stoplossBuy < Bid- Close[1]- atr ) stoplossBuy = Bid- - Close[1]- atr ;
// This ensure your stopLossBuy will only move up
Information is Gold when come to organised.
*لن يتم التسامح مع الاستخدام التجاري والبريد العشوائي، وقد يؤدي ذلك إلى إنهاء الحساب.
نصيحة: نشر رابط صورة أو فيديو من YouTube سيضمّنها تلقائيًا في مشاركتك!
نصيحة: اكتب العلامة @ للإكمال التلقائي لاسم المستخدم المشارك في هذه المناقشة.