Trailingstop EA won't work - page 2

 
FMIC:

@Mike.T: Something seems off with your PipMulytiplier code:

That does not seem to be correct! Why multiply it by 100 for 2 digit symbols? It should not be multiplied at all! It should be the same condition as 4 digit symbols.

Ummm... I stand under correction... but it works for Gold etc. that are only 2 decimals.... To be honest... I only trade the EUR/USD with my EA sooo... I could have that wrong... I'll double check it and post again if I am wrong... but thanx.... Maybe you could help me with my Array issue... you seem to know about them... I've been avoiding them for ages now...
 
FMIC:
Yes! For the reasons mentioned (see docs) as well as allowing you to merge both the Buy and Sell logic into one code block as I have demonstrated in my example.
Ok... I'm with you... that makes sense.... I've just become a better coder... thanx..
 
Mike.T:
Ummm... I stand under correction... but it works for Gold etc. that are only 2 decimals.... To be honest... I only trade the EUR/USD with my EA sooo... I could have that wrong... I'll double check it and post again if I am wrong... but thanx.... Maybe you could help me with my Array issue... you seem to know about them... I've been avoiding them for ages now...
I don't know about your brokers, but for the ones I use; the pip size of XAUUSD is 0.01 (2 digits, no multiplier)!
 
FMIC:
I don't know about your brokers, but for the ones I use; the pip size of XAUUSD is 0.01 (2 digits, no multiplier)!
The pip size is 0.01 dec... I agree... but the Lot value is greater.... lol.... I'm sure I had a reason for doing that.... I'll have to have a look at it and work it out again... 1 Lot EURUSD = $1 (Micro)   1 LOT XAUUSD = $10.... so take away the 5th decimal and add the 10x$ value and the pipmultiplier becomes 100.... maybe I could PM you.... I'm worried about hijacking this thread.... don't want to be kakked out by Raptor....lol
 
Mike.T:
The pip size is 0.01 dec... I agree... but the Lot value is greater.... lol.... I'm sure I had a reason for doing that.... I'll have to have a look at it and work it out again... 1 Lot EURUSD = $1 (Micro)   1 LOT XAUUSD = $10.... so take away the 5th decimal and add the 10x$ value and the pipmultiplier becomes 100.... maybe I could PM you.... I'm worried about hijacking this thread.... don't want to be kakked out by Raptor....lol

Don't mix up concepts! Pip size has nothing to do with lot size or pip value. A pip is a pip irrespective of its value!

By the way; for 1 Lot of EUR/USD, Value of 1 Pip = $10. For a pip value to be $1, it has to be 0.1 Lots (1 micro lot). Don't mix up concepts of micro lots or nano lots either.

 
@Mike.T: Tried to access your profile to sent a PM but your profile link gives an error (probably some bug in the sites code, due to you haveing a "." in your profile name.). So, if you wish, you are going to have to PM me!
 
FMIC:
@Mike.T: Tried to access your profile to sent a PM but your profile link gives an error (probably some bug in the sites code, due to you haveing a "." in your profile name.). So, if you wish, you are going to have to PM me!

Thanx FMIC.... there seems to be something wrong.... I'll look into it tomorrow and PM you if I can.... It's a Friday night in Portugal and SA... we should not be behind our computers...

Markets are closed... I'm going for a toot... 

 

Sorry Trader3000

Ummm... if you are going to be looking at Trailing Stops then you should really look at Break-evens....

The code is not that different and you can/should incorporate it into your EA/Script....

//+-----------------------------------------------------+
//| MOVE to BREAK-EVEN HEDGE  Function                  |
//+-----------------------------------------------------+

int CntLongHedge=0;
int CntShortHedge=0;    //  <-- this variable is the index used for the loop


void Move_To_Breakeven_Hedge()
{
   for(CntLongHedge = OrdersTotal() - 1; CntLongHedge >= 0 ; CntLongHedge --)  
   {
   
   if(OrderSelect(CntLongHedge,SELECT_BY_POS,MODE_TRADES)
      && OrderMagicNumber() == MagicNumberLongHedge
      && OrderSymbol() == Symbol()
      && OrderType() == OP_BUY
      && Bid - OrderOpenPrice() > Set_Break_Even_Hedge_Pips*PipMultiplier
      && OrderStopLoss() < OrderOpenPrice())
         {
              Ticket=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+(Break_Even_Hedge_Buffer*PipMultiplier),0,0,clrNONE);
         }
    }

   for(CntShortHedge = OrdersTotal() - 1; CntShortHedge >= 0 ; CntShortHedge --)  
   {

   if(OrderSelect(CntShortHedge,SELECT_BY_POS,MODE_TRADES)
      && OrderMagicNumber() == MagicNumberShortHedge
      && OrderSymbol() == Symbol()
      && OrderType() == OP_SELL
      && OrderOpenPrice()-Ask > Set_Break_Even_Hedge_Pips*PipMultiplier
      && (OrderStopLoss() > OrderOpenPrice()
      || OrderStopLoss() == 0))
      {
           Ticket=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-(Break_Even_Hedge_Buffer*PipMultiplier),0,0,clrNONE);
      }
   }
}


If you use both together... you can: 

1. Set a tight Break-Even...and then 

2. Let your Trailing stop move with your position... 

 

I does work....

Later... 

 

Thank you very much FMIC and Mike.  And don't worry about hijacking, because I can learn alot from you guys.  You are welcome to continue your discussion here if you wish.  I will work on all your advice and suggestions next week when the markets are open again.

PS: Mike I am also in SA(Pretoria) 

 
Trader3000:

Thank you very much FMIC and Mike.  And don't worry about hijacking, because I can learn alot from you guys.  You are welcome to continue your discussion here if you wish.  I will work on all your advice and suggestions next week when the markets are open again.

PS: Mike I am also in SA(Pretoria) 

Go for it.... 

Seems like there are a lot of us Saffers out there.... Greetings from Cape Town

Reason: