Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
You show us just a fragment of the code and I can guess only.
I supposed you start to check the history after the last order is closed, so you need to know time when is was closed. The most fresh closed order is in the end of the history, so you don't need to know another and "break" stop checking.
It is tons of methods to find the proper order in the history, you have type, magic number, comments etc.
I am trying to add a delay after a buystop order has been deleted. I have writen the code below and although it compiles ok, it doesn't work.
Can anyone see what I am doing wrong or give me the line of code that will work for this.
thanks
Code:
// Time Delay for the next "Buy Stop" Order after buystop is deleted.
if (MayOpenDeferOrder && NextBuyStop_Order_Minutes !=0)//Time Delay for the next Buy Stop Order
{
int ordersHistoryTotal = OrdersHistoryTotal();
for (int o=ordersHistoryTotal;o<=0;o--) //Count down until it hits the total trades in history
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) //Getting all historical trades
if ((Symbol() == OrderSymbol()) && (OrderComment() == "Buy Stop Deleted.")) continue;
// "Buy Stop Deleted." is the user comment
//added when a buystop order is deleted.
{
if(((TimeCurrent() - OrderOpenTime())/60) < NextBuyStop_Order_Minutes) MayOpenDeferOrder = false;
break; //MayOpenDeferOrder==BuyStop Order
}
}
}
For some reason, I cannot edit my post but the use of the "i" instead of the o in the order select statement has been changed and it still does not work
Quote:
Originally Posted by asgard2
Code:
// Time Delay for the next "Buy Stop" Order after buystop is deleted.
if (MayOpenDeferOrder && NextBuyStop_Order_Minutes !=0)//Time Delay for the next Buy Stop Order
{
int ordersHistoryTotal = OrdersHistoryTotal();
for (int o=ordersHistoryTotal;o<=0;o--) //Count down until it hits the total trades in history
{
if(OrderSelect(o,SELECT_BY_POS,MODE_HISTORY)) //Getting all historical trades
if ((Symbol() == OrderSymbol()) && (OrderComment() == "Buy Stop Deleted.")) continue;
// "Buy Stop Deleted." is the user comment
//added when a buystop order is deleted.
{
if(((TimeCurrent() - OrderOpenTime())/60) < NextBuyStop_Order_Minutes) MayOpenDeferOrder = false;
break; //MayOpenDeferOrder==BuyStop Order
}
}
}
For some reason, I cannot edit my post but the use of the "i" instead of the o in the order select statement has been changed and it still does not work
a) always use braces around the then-clauses (and else-clases). That might help you seeing program flow mistakes. E.g., there is a dubious "break" in the for-clause.
b) the order list is not necessarily in time order; it can be reordered via the GUI.
void OpenBuy()
{
int ticket,err;
if (!GlobalVariableCheck("InTrade")) {
GlobalVariableSet("InTrade", CurTime()); // set lock indicator
ticket = OrderSend(Symbol(),OP_BUY,lot2,Ask,1,0,Ask+TP*Poin t,"Ask-StopLoss*Point,EA Order",magic,0,Red);
GlobalVariableDel("InTrade"); // clear lock indicator
}
}
void OpenSell()
{
int ticket,err;
if (!GlobalVariableCheck("InTrade")) {
GlobalVariableSet("InTrade", CurTime()); // set lock indicator
ticket = OrderSend(Symbol(),OP_SELL,lot2,Bid,1,0,Bid-TP*Point,Bid+StopLoss*Point,"EA Order",magic,0,Red);
GlobalVariableDel("InTrade"); // clear lock indicator
}
}
to
Code:
void OpenBuy()
{
int ticket,err;
if (!GlobalVariableCheck("InTrade")) {
GlobalVariableSet("InTrade", CurTime()); // set lock indicator
ticket = OrderSend(Symbol(),OP_BUY,lot2,Ask,1,0,0,"Ask-StopLoss*Point,EA Order",magic,0,Red);
GlobalVariableDel("InTrade"); // clear lock indicator
}
}
void OpenSell()
{
int ticket,err;
if (!GlobalVariableCheck("InTrade")) {
GlobalVariableSet("InTrade", CurTime()); // set lock indicator
ticket = OrderSend(Symbol(),OP_SELL,lot2,Bid,1,0,0,"EA Order",magic,0,Red);
GlobalVariableDel("InTrade"); // clear lock indicator
}
}
Thank you very much for your kindness, Roger09.
Please accept my apology for my late response.
I will test the code and I will be back to you for the result.
=s=
Hi,
I need to place some lable in proportion to the total number of pixels of x-axis and y-axis of the window. But how can I get the total number of pixels?
Cheers.
xecret
The result was not as I expected.
What I meant by Hide TP is not without TP level, instead, it is invisible yet still taking profit as set in parameter.