Some help on code

 

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

Reason: