Dear newbies! Some questions discussed here are very specific and really deserve tips and help. But some, well, frankly, arise from the fact that starting to program some EXPERT writers do not even read a textbook on MCL. HINT: Download the tutorial (5 mb) and read it and you will not have to wait for an answer from the forum - it will be in your head.
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.
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()
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.
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.
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.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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
ии[3]={ExtMapBuffer1[0],ExtMapBuffer2[0],ExtMapBuffer3[0]}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.