Code 4, Code 5

I probably have mentioned before that I use codes for trail stops,

code 1 applies a 1-pip stop loss first upon hitting 4-pips in gains,

code 2 applies the same protective stop loss, but starting from 8-pip in gains, and

code 3 jumps over the first 3 lower steps and only starts trailing upon having made progress beyond 1/2 of the fluctuation size (i.e. 4 pips locked in beyond a 16+4-pip move) which comes in handy when the market does a whole lot of nothing and would likely take you out for break evens with its back and forth motions.

One recent modification was to figure in the swap when determining about applying the trail ( OrderProfit()+OrderSwap()>0 ).

Code 4 is actually an automatic target setting: it adjusts the get out level relative to the last 8-sample low/ high and displaces it by kickback * points – if the position went into gains, and if the new kickback displacement leaves the minimum of 1 pip on the bone (my EUR/USD round trip cost is 0.6 pips)

Code 5 is quite stylishly adjusts the target to E-16: this is where you would be expecting your wave 4 to end and start wave 5, if your count is correct.

/////Long Target - Code 4

if( OrderType()==OP_BUY && OrderProfit()>0 && OrderStopLoss()==.4 && OrderTakeProfit()!=NormalizeDouble(iLow(symbol,15,iLowest(symbol,15,MODE_LOW,8,0))+kickback*Point,4) && OrderOpenPrice()<NormalizeDouble(iLow(symbol,15,iLowest(symbol,15,MODE_LOW,8,0))+kickback*Point,2)-10*Point
 ) 
       { OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(iLow(symbol,15,iLowest(symbol,15,MODE_LOW,8,0))+kickback*Point,4), OrderExpiration());
          Print("LONG Target Set @ "+DoubleToStr(NormalizeDouble(iLow(symbol,15,iLowest(symbol,15,MODE_LOW,8,0))+kickback*Point,4),4));}

/////Short Target  - Code 4

if( OrderType()==OP_SELL && OrderProfit()>0 && OrderStopLoss()==4 && OrderTakeProfit()!=NormalizeDouble(iHigh(symbol,15,iLowest(symbol,15,MODE_HIGH,8,0))-kickback*Point,4) && OrderOpenPrice()>NormalizeDouble(iHigh(symbol,15,iLowest(symbol,15,MODE_HIGH,8,0))-kickback*Point,2)+10*Point
 ) 
     {   OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(iHigh(symbol,15,iLowest(symbol,15,MODE_HIGH,8,0))-kickback*Point,4) , OrderExpiration());
           Print("SHORT Target Set @ "+DoubleToStr(NormalizeDouble(iHigh(symbol,15,iLowest(symbol,15,MODE_HIGH,8,0))-kickback*Point,4),4));  }    
      

/////Long Target - Code 5

if( OrderType()==OP_BUY && OrderProfit()>0 && OrderStopLoss()==.5 && OrderTakeProfit()!=NormalizeDouble(iMA(symbol,30,32,0,MODE_EMA, PRICE_CLOSE,0),4) && OrderOpenPrice()<NormalizeDouble(iMA(symbol,30,32,0,MODE_EMA, PRICE_CLOSE,0),4)
 ) 
       { OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(iMA(symbol,30,32,0,MODE_EMA, PRICE_CLOSE,0),4), OrderExpiration());
          Print("LONG Target Set to E-16 @ "+DoubleToStr(NormalizeDouble(iMA(symbol,30,32,0,MODE_EMA, PRICE_CLOSE,0),4),4));}

/////Short Target  - Code 5

if( OrderType()==OP_SELL && OrderProfit()>0 && OrderStopLoss()==5 && OrderTakeProfit()!=NormalizeDouble(iMA(symbol,30,32,0,MODE_EMA, PRICE_CLOSE,0),4) && OrderOpenPrice()>NormalizeDouble(iMA(symbol,30,32,0,MODE_EMA, PRICE_CLOSE,0),4)
 ) 
     {   OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(iMA(symbol,30,32,0,MODE_EMA, PRICE_CLOSE,0),4) , OrderExpiration());
           Print("SHORT Target Set to E-16 @ "+DoubleToStr(NormalizeDouble(iMA(symbol,30,32,0,MODE_EMA, PRICE_CLOSE,0),4),4));  }    

run your cycle over the open trades:

for(i=OrdersTotal()-1; i>=0 ; i--)
 {   
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
        { 
           Print("Access to orders list failed with error (",GetLastError(),")");
           break;
        }
The hedging starts at 4-pips above the candle high with the arrow, and balloons into a full hedge within 10 pips, but for total naked risk I use the value 7-pips out.

I am currently net 4 lots short, and booked $468.02 in gains, which means that today I managed to purchase 10 pips of movement relative to the naked risk carried forward. This 10-pip measure is the name of the game plus not losing equity when you are managing holdings.

Kickback is 90-160 points depending on recent data.