[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 341
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Saved indication parameters are "entered" into the indicators once during the initialisation of the template, then "they become completely independent"/.
All changed indicator parameters are saved in the template, if you have changed the indicator parameters, resave the template.
>> Thank you!
mazepa 08.12.2009 17:42
ANSWER: on the CODE!
If I understand the algorithm, then at the set time we open buy (sell), if the price has passed >10 pips in the other direction, then we close the order and stand in the opposite direction.
For closing, I am using my own universal function.
//Function for closing all market orders in--------------------------------------------------------------------------------------------------
void _CloseAllOrder()
{
for(int i=0; i<OrdersTotal(); i++) //cross all orders for all currencies
{
if (OrderSelect(i,SELECT_BY_POS)==true) //if the order is successfully selected
{
if (OrderSymbol()!=Symbol()) continue; //if the order is in the wrong currency, continue the search
{
switch(OrderType()) //in the required order, determine the type (Bue_Sell) and close it
{
case 0:OrderClose(OrderTicket(),OrderLots(),Bid,2);break;
case 1:OrderClose(OrderTicket(),OrderLots(),Ask,2);break;
}
}
}
}
return;
}
So now before opening in the opposite direction you just write _CloseAllOrder()
Friends, I am just learning. Please don't look at the contents of the program, just help me find a bug in the program:
int start()
{
switch(CurrentState)
{
case STATE_SHORT:
MyOrderTicket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 1, 0, 0,NULL, 1, 0, Red);
OrderSelect(MyOrderTicket,SELECT_BY_TICKET);
if (OrderModify(OrderTicket(),OrderOpenPrice(),Bid+90*Point,Bid-Profit1*Point,0,Green)==true)
{CurrentState=STATE_1;
break;
}
case STATE_1:
OrderSelect(MyOrderTicket,SELECT_BY_TICKET);
if(Ask <= OrderTakeProfit())
{CurrentState=STATE_SHORT;
break;
}
if(Bid >= (OrderOpenPrice()+Profit1*Point)
{CurrentState=STATE_SHORT;
break;
}
}
//----
return(0);
}
The error is as follows: \end_of_program' - unbalanced left parenthesis. Where is the error?
Friends, I am just learning. Please don't look at the contents of the program, just help me find a bug in the program:
Got it:
need:
How to declare a one-dimensional array without applying a write to each memory cell (is it possible)
but by a one-dimensional sequence
or is one-dimensional sequence only for numeric and logical constants!!!?
Got it:
>> we have to:
Thank you, friend!
One more question. If (OrdersTotal()==0) this... if the number of open orders is equal to zero... then how will it be...if the number of orders opened FOR THE DAY is equal to zero.
Isn't there something like OrdersDayTotal?
no, but we can always write our own function)
Counts orders Buy and Sell, for a given symbol, opened today. No pending orders.
if(OrdersDayTotal(Symbol())==0) {...}
something like this)
mazepa 08.12.2009 17:42
ANSWER: On COD!
If I understand the algorithm, we open buy (sell) at the set time, if the price has moved >10 pips in the other direction, we close the order and move in the opposite direction.
I use my own universal function to close it.
//Function to close all market orders in window--------------------------------------------------------------------------------------------------
void _CloseAllOrder()
{
for(int i=0; i<OrdersTotal(); i++) //cull all orders for all currencies
{
if (OrderSelect(i,SELECT_BY_POS)==true) //if the order is successfully selected
{
if (OrderSymbol()!=Symbol()) continue; //if the order is in the wrong currency, continue the search
{
switch(OrderType()) //when the required order is submitted, define its type (Bue_Sell) and close it
{
case 0:OrderClose(OrderTicket(),OrderLots(),Bid,2);break;
case 1:OrderClose(OrderTicket(),OrderLots(),Ask,2);break;
}
}
}
}
return;
}
So now you just write _CloseAllOrder() before opening in the opposite direction
The function is the bomb it took me a couple of pages. Thank you very much.mazepa 08.12.2009 17:42
ANSWER: On COD!
If I understand the algorithm, we open buy (sell) at the set time, if the price has moved >10 pips in the other direction, we close the order and move in the opposite direction.
I use my own universal function to close it.
//Function to close all market orders in window--------------------------------------------------------------------------------------------------
void _CloseAllOrder()
{
for(int i=0; i<OrdersTotal(); i++) //cull all orders for all currencies
{
if (OrderSelect(i,SELECT_BY_POS)==true) //if the order is successfully selected
{
if (OrderSymbol()!=Symbol()) continue; //if the order is in the wrong currency, continue the search
{
switch(OrderType()) //when the required order is submitted, define its type (Bue_Sell) and close it
{
case 0:OrderClose(OrderTicket(),OrderLots(),Bid,2);break;
case 1:OrderClose(OrderTicket(),OrderLots(),Ask,2);break;
}
}
}
}
return;
}
So now you just write _CloseAllOrder() before opening in the opposite direction
The function is the bomb it took me a couple of pages. Thank you very much.