Thread: How to code?
View Single Post
  #120 (permalink)  
Old 06-25-2006, 10:16 PM
Aaragorn's Avatar
Aaragorn Aaragorn is offline
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
Code debugging issue...trailing stop trigger..coders wanted

PHP Code:
for(cnt=0;cnt<total;cnt++) {
OrderSelect(cntSELECT_BY_POSMODE_TRADES);
if(
OrderType()<=OP_SELL && OrderSymbol()==Symbol()) {
if(
OrderType()==OP_BUY){
if(
TrailingStop>0) {
if(
Bid-OrderOpenPrice()>Point*TrailingStopTrigger) {
if(
OrderStopLoss()<Bid-Point*TrailingStop) {
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
return(
0);
}
}
}
}else{
if(
TrailingStop>0) {
if((
OrderOpenPrice()-Ask)>(Point*TrailingStopTrigger)) {
if((
OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) {
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(
0); 
I'm still learning code. This is supposed to trigger a trailing stop to engage as a specified level. I can see from some test results that it didn't trigger when it should have.

I'm wondering if this is written correctly as 'Point*TrailingStopTrigger' is it supposed to multiply or simply add the value of the TrailingStopTrigger to Point for sell positions and subtract if for buy positions. Is that why it's not triggering like it's supposed to? Or is there something else?
Reply With Quote