Trade Loop With Array

 

Hi,

I am trying to do the following:

Loop through open trades. For each open trade in loop:

  1. Check profit amount of each open trade for previous candle close
  2. Check profit amount of each open trade for current candle close (i.e. profit amount at current market value)
  3. If profit amount of candle close[0] < profit amount of candle close[1], close trade

Thanks in advance for your help :)

 
Forex987:

Hi,

I am trying to do the following:

OK, you are trying to do it . . . how is it going ?
 
Forex987: If profit amount of candle close[0] < profit amount of candle close[1], close trade

No need for all that. For a buy, profit increases when the market goes up. So if Close[0] < Close[1] then current profit < profit at candle close[1].
So do you think you'll make any money if you close all trades the moment market drops one point below Close[1]?

 
WHRoeder:

No need for all that. For a buy, profit increases when the market goes up. So if Close[0] < Close[1] then current profit < profit at candle close[1].
So do you think you'll make any money if you close all trades the moment market drops one point below Close[1]?


I was thinking the same logic but isn't it possible that close[0] < close[1] but current profit remains the same? Meaning, doesn't the market have to move a certain amount in order for current profit to change?

Here's an approximation using blocks but it's not as accurate as comparing current profit to previous profit. Clearly, this needs some custom code using an array but I'm not sure how to do it: http://fxdreema.com/shared/3d0EGJopb

re: effectiveness of this strategy, I'm not looking to close all trades when market level drops but only those trades whose current profit is 0.00. Essentially, the idea is to prevent these trades from slipping back into the minus :)

 
  1. Profit = (OrderClosePrice - OrderOpenPrice) * DeltaPerLot * OrderLots. No it's not possible
  2. Move the stop loss to the OrderOpenPrice and it will be closed at break even (ignoring slippage)
 

thanks for your responses :)

1. I assume if OrderCloseTime = 0 then OrderClosePrice will take the value at the current tick?

What do DeltaPerLot and OrderLots mean?

2. Is there a way to move stop loss to OrderOpenPrice even if current market price is less than broker's minimum s/l away from open price? I have tried this using ea but it always says "Too short s/l requested, minimum will be taken".

 
  1. OrderClosePrice is Bid (Buy) or Ask (Sell) on open orders
  2. DeltaPerLot is the change in profit per lot per change in price.
  3. Waht is OrderLots()? RTFM!
  4. You can set the stop loss anywhere you want (subject to Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial)
 
thanks for that info :)