![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hi i have some code that buys at either the close plus X pips or the high or low plus a certain amount of pips.
What i want it to do is if current price goes above the previous bars high place a limit order at a certain amount of pips below the high or maybe at a moving average for example.
This is currently what i have.
If ((BarEntryType == "C") || (BarEntryType == "c"))
{
bool tradeLong = alertLong && ( Ask >= Close[1] + entryPoint );
bool tradeShort = alertShort && (Bid <= Close[1] - entryPoint );
}
else if ((BarEntryType == "HL") || (BarEntryType == "hl"))
{
tradeLong = alertLong && ( EMA2 + entryPoint );
tradeShort = alertShort && ( EMA2 - entryPoint);
}
CheckOrders(false);
if ((tradeLong || tradeShort) && totOpen == 0 && Time[0] == alertTime) // )
{
if (PlaceMktOrder(tradeLong))
{
alertTime = 0;
totOpen = 1;
if (StopLossPips == 0)
{
if (tradeLong) SL = Ask - Low[StopLossBars] + SLBars;
if (tradeShort) SL = High[StopLossBars] + SLBars - Bid;
// Print (" SL bars = ", DoubleToStr(SL, Digits));
Any ideas how i this can be modified thanks
FTM