Hi Raptor,
Thank you for your prompt response (and open mind with me). I will take your clue and try to get that.
Best Regards
Luis
Hi RaptorUk,
Two questions,
When you say proper indenting is that meaning to have close brackets for any open brackets ?
I mean instead of this . . . .
void AddLimitsBuy() { OrderSelect(Ticket,SELECT_BY_TICKET); OpenPrice = OrderOpenPrice(); StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL)*Point; RefreshRates(); UpperStopLevel = Ask + StopLevel; LowerStopLevel = Bid - StopLevel; if(StopLoss > 0) double BuyStopLoss = OpenPrice - (StopLoss * pt); if(TakeProfit > 0) double BuyTakeProfit = OpenPrice + (TakeProfit * pt); if(BuyStopLoss > 0 && BuyStopLoss > LowerStopLevel) { BuyStopLoss = LowerStopLevel - MinStop*pt; } if(BuyTakeProfit > 0 && BuyTakeProfit < UpperStopLevel) { BuyTakeProfit = UpperStopLevel + MinStop*pt; } if(IsTradeContextBusy())Sleep(10); if(BuyStopLoss > 0 || BuyTakeProfit > 0) { OrderModify(Ticket,OP_BUY,BuyStopLoss,BuyTakeProfit,0); } }
you have this . . .
void AddLimitsBuy() { OrderSelect(Ticket,SELECT_BY_TICKET); OpenPrice = OrderOpenPrice(); StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL)*Point; RefreshRates(); UpperStopLevel = Ask + StopLevel; LowerStopLevel = Bid - StopLevel; if(StopLoss > 0) double BuyStopLoss = OpenPrice - (StopLoss * pt); if(TakeProfit > 0) double BuyTakeProfit = OpenPrice + (TakeProfit * pt); if(BuyStopLoss > 0 && BuyStopLoss > LowerStopLevel) { BuyStopLoss = LowerStopLevel - MinStop*pt; } if(BuyTakeProfit > 0 && BuyTakeProfit < UpperStopLevel) { BuyTakeProfit = UpperStopLevel + MinStop*pt; } if(IsTradeContextBusy())Sleep(10); if(BuyStopLoss > 0 || BuyTakeProfit > 0) { OrderModify(Ticket,OP_BUY,BuyStopLoss,BuyTakeProfit,0); } }
Is that possible to take off the void from the function name CloseAll () in the sense to include it in the start function and at the very end put
return(0);
}
Hi RaptorUK, (again....)
I'm lost!!!
I've tried to do my up most to get this working, but without success.
First, I've include in just one block the get profit and close all orders and put it inside the start block.
Second I've let the AddLimitsBuy and AddLimitsSell functions as separate because I don't know how to call those functions very time an order is opened.
and for last the irritating error is there and I do not find a way to get rid of it.....
These are the two blocks of code that I try to get in only one
Any help here (if you still having patience)?
Best Regards
Luis
{ int pos; int Total=OrdersTotal(); if(Total>0) { for(int Profit=OrdersTotal()-1;pos>=0;pos--) if(OrderSelect(Profit,SELECT_BY_POS) && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol() && TakeProfit-OrderOpenPrice()>TakeProfit)CloseAll(); } }
void CloseAll() { int i,Op,Error; int Total=OrdersTotal(); if(Total>0) { for(int pos=OrdersTotal()-1;pos>=0;pos--) if(OrderSelect(pos,SELECT_BY_POS) && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol()) { Op=OrderType(); if(Op==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),Bid, UseSlippage, Yellow); } if(Op==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),Ask, UseSlippage, Yellow); } else { ObjectDelete("highline"); } } } }
Mix of last two blocks:
// Close All(close all open positions if last one reach TakeProfit) int OrdType, GLError; RefreshRates(); for(int OrderPos = OrdersTotal()-1; OrderPos >= 0; OrderPos--) if(OrderSelect(OrderPos, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber()== MagicNumber && OrderSymbol()== Symbol() &&(OrderProfit() + OrderSwap() + OrderCommission() > 0 ) { OrdType = OrderType(); if(OrdType == OP_BUY || OrdType==OP_SELL) { if(!OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), RealSlippage, Yellow)) GLError = GetLastError(); } else { ObjectDelete("highline"); } if(GLError > 0) Print("Error Closing/Deleting Order, error # ", GLError, " for ticket: ", OrderTicket()); } } } return(0); }
Hi RaptorUK, (again....)
Any help here (if you still having patience)?
Hi RaptorUk,
I understand your position and thank you for your support.
In the attach file sent have divide the whole code by blocks where on top is the main function of each one. Nevertheless at this very moment I'm write down more comments to better communicate what kind of results I'm looking from each one.
Thank you again for your support
Best Regards
Luis
Hi RaptorUk,
Here in attach is the whole code with a description of every function required.
I really appreciate a look and support.
Best regards
Luis
Hi RaptorUk,
Here in attach is the whole code with a description of every function required.
I really appreciate a look and support.
- 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 all,
In code I get the error message '(' - function definition unexpected, Could anyone help me to get this right ?
In attach is all the code and in Bold is where I suppose the problem is, nevertheless I've been uncessuful to get it right.
Thanks in advance for any help you cloud provide
Luis