for(int i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderMagicNumber()==Magic3) BuyOrdersInfo1(); {
- Your function call invalidates your OrderSelect. Call outside.
- Your function call is only part of the if magic. Everything else below the bracket is always called.
- Your function call invalidates your OrderSelect. Call outside.
- Your function call is only part of the if magic. Everything else below the bracket is always called.
Hi Dear William,
Thank you for answering
I changed the code this way but still could not get the desired result
int start() { BuyOrdersInfo1(); return(0); } //+------------------------------------------------------------------+ void BuyOrdersInfo1() { PriceOfHigherBuy=-99999; SumOfBuyOrders=0; //--- for(int i=0; i<OrdersTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if((OrderSymbol()=="GBPUSD") && (OrderMagicNumber()==Magic3) && (OrderType()==OP_BUY)) { SumOfBuyOrders++; PriceOfHigherBuy=MathMax(OrderOpenPrice(),PriceOfHigherBuy); { if(OrderTakeProfit()>(Bid-MathPow(10,-Digits)*PriceOfHigherBuy)) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-MathPow(10,-Digits)*PriceOfHigherBuy,OrderTakeProfit(),0,Green); } } } } } } //+------------------------------------------------------------------+
if(OrderTakeProfit()>(Bid-MathPow(10,-Digits)*PriceOfHigherBuy))
- MathPow(10-Digits) is the same as _Point.
- Point times a price is essentially zero, so you are comparing OTP to Bid which will always be true.
- Don't you want to move the OTP if it is less than the current high?
- You can't know the current high until you complete the loop.
- MathPow(10-Digits) is the same as _Point.
- Point times a price is essentially zero, so you are comparing OTP to Bid which will always be true.
- Don't you want to move the OTP if it is less than the current high?
- You can't know the current high until you complete the loop.
Pay attention to the photo, we have 8 open positions. Before the price reaches it, the expert must find out in which of these positions all the positions (purchase) are in profit, then let him put all the TPs on the entry point of the same position.
Don't you want to move the OTP if it is less than the current high?
All profit margins must be equal at the entry point of one of the top positions, provided that the sum of all positions is in profit.
Thanks,
Hi
With this code
I want the expert to check the high purchase order. If the price of all the positions is positive, bring all the TPs to the high buy position.
But this must be done before the price reaches a high order position
But the code has a problem and it does not do that//+------------------------------------------------------------------+ void BuyOrdersInfo1() { PriceOfHigherBuy=-99999; SumOfBuyOrders=0; //--- for(int i=0; i<OrdersTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if((OrderSymbol()=="GBPUSD") && (OrderMagicNumber()==Magic3) && (OrderType()==OP_BUY)) { SumOfBuyOrders++; PriceOfHigherBuy=MathMax(OrderOpenPrice(),PriceOfHigherBuy); } } } }
Hello dear
This Function returns the highest (not higher) price of buy orders(open price of 8th order). Is that what you want?
Hello dear
This Function returns the highest (not higher) price of buy orders(open price of 8th order). Is that what you want?
Hello
Thank you for your help
I want, for example, when positions 3 or 4 or later are opened, the TP of all positions should be at the entry point of one of the top positions.
Transfer the TP of all positions to the entry point of one of the higher positions provided that our total profit is in profit
Have you noticed that if you transfer TP to the last open price order, it means closing all active positions? (Although this is impossible because in BUY orders the TP must be higher than the current price)
Have you noticed that if you transfer TP to the last open price order, it means closing all active positions? (Although this is impossible because in BUY orders the TP must be higher than the current price)
Yes, I mean this
I want to put all the TPs in the price of one of the high open positions
Or position number 3 or 4 or 5 or 6 or 8
Provided that the sum of all positions is either overhead or the sum of all positions is in profit
Have you noticed that if you transfer TP to the last open price order, it means closing all active positions? (Although this is impossible because in BUY orders the TP must be higher than the current price)
What I want is perfectly stated in this photo
I hope you understand what I mean and help solve this problem
Thanks.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
With this code
I want the expert to check the high purchase order. If the price of all the positions is positive, bring all the TPs to the high buy position.
But this must be done before the price reaches a high order position
But the code has a problem and it does not do that