Need Help with setting take profit (code)
Embstj:
Hey there everyone!
It's been almost a year since I posted needing help. I've been able to figure everything out thus far. However- This time I've been stumped on what to do.
for(cnt = OrdersTotal(); cnt >= 0; cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); mode = OrderType(); if(OrderSymbol() == Symbol()) { if(mode == OP_BUY) { MyTakeProfit = OrderOpenPrice() + (TakeProfit*Point); MyStopLoss = OrderOpenPrice() - (TakeProfit*Point); Print("MyTakeProfit=",MyTakeProfit); } } } if(MyTakeProfit == Bid) { Print("Take Profit Level Reached"); if(Teir1 == true) { for(cnt = OrdersTotal(); cnt >= 0; cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol() == Symbol()) { if(mode == OP_BUY) { OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, Blue); Teir1 = false; Teir2 = true; } } } } }The problem is, is that the second block of code does not close the order like it should. I placed the Print functions within the two blocks to troubleshoot. It does Print the "MyTakeProfit" Correctly at the price it should, however- It doesn't print the "Take Profit Level Has Been Reached". It's like the Price never actually reached the Bid Price. When I tested it thought- The first order it places should meet the take profit level, and closed easily. Either way- the stop loss block of code is written almost the same exact way, and it doesn't work either.
Am I coding this wrong for some reason?
Thanks in advance,
Jacob
attach files inncluded takeprofit, stoplost and trailing stop. MA_CrossOver_EA.mq4 (6.11 KB)
Never mind everyone- I finally answered my own question. lol
-Jacob
Hey there everyone!
It's been almost a year since I posted needing help. I've been able to figure everything out thus far. However- This time I've been stumped on what to do.
The problem is, is that the second block of code does not close the order like it should. I placed the Print functions within the two blocks to troubleshoot. It does Print the "MyTakeProfit" Correctly at the price it should, however- It doesn't print the "Take Profit Level Has Been Reached". It's like the Price never actually reached the Bid Price. When I tested it thought- The first order it places should meet the take profit level, and closed easily. Either way- the stop loss block of code is written almost the same exact way, and it doesn't work either.Am I coding this wrong for some reason?
Thanks in advance,
Jacob