Hamiddd:
Forum on trading, automated trading systems and testing trading strategies
General rules and best pratices of the Forum.
Alain Verleyen, 2017.07.19 11:03
When you post code please use the SRC button !
Hello,
Please use the SRC button when you post code.
Thank you.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
in this EA my problem is that it moves the TP but doesn`t set the SL and in the journal the value for stoploss is ZERO please help me with this.
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
Calculations ();
ModifyOrders ();
}
//+------------------------------------------------------------------+
void Calculations ()
{
TMA_Middle = iCustom(Symbol(),0,"! mth_FastTMALine",TimeFrame,61,Price,3,110,TrendThreshold,ShowCenterLine,alertsOn,alertsMessage,alertsSound,alertsEmail,MoveEndpointEveryTick,MaxBarsBack,0,1);
TMA_Upper = iCustom(Symbol(),0,"! mth_FastTMALine",TimeFrame,61,Price,3,110,TrendThreshold,ShowCenterLine,alertsOn,alertsMessage,alertsSound,alertsEmail,MoveEndpointEveryTick,MaxBarsBack,1,1);
TMA_Lower = iCustom(Symbol(),0,"! mth_FastTMALine",TimeFrame,61,Price,3,110,TrendThreshold,ShowCenterLine,alertsOn,alertsMessage,alertsSound,alertsEmail,MoveEndpointEveryTick,MaxBarsBack,2,1);
TMA_TG = iCustom(Symbol(),0,"! mth_FastTMALine",TimeFrame,61,Price,3,110,TrendThreshold,ShowCenterLine,alertsOn,alertsMessage,alertsSound,alertsEmail,MoveEndpointEveryTick,MaxBarsBack,3,1);
TMA_TR = iCustom(Symbol(),0,"! mth_FastTMALine",TimeFrame,61,Price,3,110,TrendThreshold,ShowCenterLine,alertsOn,alertsMessage,alertsSound,alertsEmail,MoveEndpointEveryTick,MaxBarsBack,4,1);
TMA_TS = iCustom(Symbol(),0,"! mth_FastTMALine",TimeFrame,61,Price,3,110,TrendThreshold,ShowCenterLine,alertsOn,alertsMessage,alertsSound,alertsEmail,MoveEndpointEveryTick,MaxBarsBack,5,1);
TMA_BU = iCustom(Symbol(),0,"! mth_FastTMALine",TimeFrame,61,Price,1,110,TrendThreshold,ShowCenterLine,alertsOn,alertsMessage,alertsSound,alertsEmail,MoveEndpointEveryTick,MaxBarsBack,1,1);
TMA_BL = iCustom(Symbol(),0,"! mth_FastTMALine",TimeFrame,61,Price,1,110,TrendThreshold,ShowCenterLine,alertsOn,alertsMessage,alertsSound,alertsEmail,MoveEndpointEveryTick,MaxBarsBack,2,1);
StopLoss = iSAR(Symbol(),0,0.02,0.2,1);
}
//+-------------------------------------------------------------------+
void ModifyOrders ()
{
for(int a=OrdersTotal()-1; a >= 0; a--)
{
if (OrderSelect(a,SELECT_BY_POS,MODE_TRADES))
if (OrderSymbol()==Symbol())
if (OrderType()==OP_BUY)
if (TMA_TG != 2147483647.0)
if (!OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,TMA_Upper,0,CLR_NONE))
Print("OrderModify error ",GetLastError());
}
for(int b=OrdersTotal()-1; b >= 0; b--)
{
if (OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
if (OrderSymbol()==Symbol())
if (OrderType()==OP_BUY)
if (TMA_TR != 2147483647.0)
if (!OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,TMA_BL,0,CLR_NONE))
Print("OrderModify error ",GetLastError());
}
for(int c=OrdersTotal()-1; c >= 0; c--)
{
if (OrderSelect(c,SELECT_BY_POS,MODE_TRADES))
if (OrderSymbol()==Symbol())
if (OrderType()==OP_BUY)
if (TMA_TS != 2147483647.0)
if (!OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,TMA_BU,0,CLR_NONE))
Print("OrderModify error ",GetLastError());
}
for(int d=OrdersTotal()-1; d >= 0; d--)
{
if (OrderSelect(d,SELECT_BY_POS,MODE_TRADES))
if (OrderSymbol()==Symbol())
if (OrderType()==OP_SELL)
if (TMA_TG != 2147483647.0)
if (!OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,TMA_BU,0,CLR_NONE))
Print("OrderModify error ",GetLastError());
}
for(int e=OrdersTotal()-1; e >= 0; e--)
{
if (OrderSelect(e,SELECT_BY_POS,MODE_TRADES))
if (OrderSymbol()==Symbol())
if (OrderType()==OP_SELL)
if (TMA_TR != 2147483647.0)
if (!OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,TMA_Lower,0,CLR_NONE))
Print("OrderModify error ",GetLastError());
}
for(int f=OrdersTotal()-1; f >= 0; f--)
{
if (OrderSelect(f,SELECT_BY_POS,MODE_TRADES))
if (OrderSymbol()==Symbol())
if (OrderType()==OP_SELL)
if (TMA_TS != 2147483647.0)
if (!OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,TMA_BL,0,CLR_NONE))
Print("OrderModify error ",GetLastError());
}
}