Thread: Ask!
View Single Post
  #1075 (permalink)  
Old 05-02-2008, 04:01 PM
Dave137 Dave137 is offline
Senior Member
 
Join Date: Oct 2007
Posts: 223
Dave137 is on a distinguished road
Red face Triple Trailing Stop Problem - Please Help In Coding!

PHP Code:
void TrailingPositions() {
  
double pBidpAskpp;

  
pp MarketInfo(OrderSymbol(), MODE_POINT);
  if (
OrderType()==OP_BUY) {
   
pBid MarketInfo(OrderSymbol(), MODE_BID);

//BreakEven routine
    
if (BreakEven>0) {
      if ((
pBid-OrderOpenPrice())>BreakEven*pp) {
         if ((
OrderStopLoss()-OrderOpenPrice())<0) {
            
ModifyStopLoss(OrderOpenPrice()+0*pp);
         }   
      }    
    }
    
    if (
TrailingStop>0) { 
    
    if ((
pBid-OrderOpenPrice())>TrailingStop_Over135*pp){ //15 pips TS
    
    
ModifyStopLoss(pBid-TrailingStop_Over135*pp);
    
    if (
pBid-OrderOpenPrice()>TrailingStop_Over90*pp && pBid-OrderOpenPrice()<TrailingStop_Over135*pp){ //55 pips TS
    
    
ModifyStopLoss(pBid-TrailingStop_Over90*pp);

    if ((
OrderOpenPrice()-pAsk)>TrailingStop +TrailingStep+1*pp && (OrderOpenPrice()-pAsk) < TrailingStop_Over90*pp+TrailingStep-1*pp || OrderStopLoss()==0) {//75 pips TS
      
    
ModifyStopLoss(pAsk+TrailingStop*pp);
    
    
 
        return;
      }
     }
    }
   }
  } 
Three levels of Trailing Stop:
1) 75 Pips TS up to first 90 Pips Profit.
2) 55 Pips TS after 90 but only up to 135 pips profit.
3) 15 Pips TS after 135 pips profit.

The problem I am having is the Trailing Stop moves both up and down as the price moves up and down . . It should just be moving up as the price profit increases and stop if the price starts dropping! How do I get it to stop moving down as the price drops - The Trailing Stop is acting like a Yo-Yo as the price moves up and down.

I am not sure how to stop this from happening?? Please, I need your expertise!

Humbly,

Dave

Last edited by Dave137; 05-02-2008 at 05:47 PM.
Reply With Quote