I'm trying to program my stops so that if profit is greater than 30 (pips), we will have a stop equal to the 55 Period MA, if profit is greater than 60, we'll use a 21 MA, if profit is greater then 90 we'll use an 8 MA. The problem is when profit goes above 60 (so it reverts to the 21 MA) and then falls back below 60, the moving average falls back to the 55 period MA (which we don't want). The stop should hold at the 21 MA.
Once the price leaves the 55ma tier, it should not go back there. Can anyone help?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I'm trying to program my stops so that if profit is greater than 30 (pips), we will have a stop equal to the 55 Period MA, if profit is greater than 60, we'll use a 21 MA, if profit is greater then 90 we'll use an 8 MA. The problem is when profit goes above 60 (so it reverts to the 21 MA) and then falls back below 60, the moving average falls back to the 55 period MA (which we don't want). The stop should hold at the 21 MA.
Once the price leaves the 55ma tier, it should not go back there. Can anyone help?
ma1 = iMA(NULL, 0, 8, 0, MODE_EMA, PRICE_CLOSE,0);
ma2 = iMA(NULL, 0, 21, 0, MODE_EMA, PRICE_CLOSE,0);
ma3 = iMA(NULL, 0, 55, 0, MODE_EMA, PRICE_CLOSE,0);
OOP30= OrderOpenPrice() + 30*Point;
OOP60= OrderOpenPrice() + 60*Point;
OOP90= OrderOpenPrice() + 90*Point;
OOP120= OrderOpenPrice() + 120*Point;
if(OrderType() == OP_BUY)
{
if( Ask > (OOP30) && Ask < (OOP60) && Ask > ma3)
{
OrderModify(OrderTicket(),OrderOpenPrice(),ma3, OrderTakeProfit(),0,Blue);
}
if( Ask > (OOP60) && Ask < (OOP90) && Ask > ma2)
{
OrderModify(OrderTicket(),OrderOpenPrice(),ma2, OrderTakeProfit(),0,Blue);
}
if( Ask > (OOP90) && Ask < (OOP120) && Ask > ma1)
{
OrderModify(OrderTicket(),OrderOpenPrice(),ma1, OrderTakeProfit(),0,Blue);
}