[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

 
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.
 
costy_ >> :

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?









 
Klinskih >> :

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:

                    if(Bid >= (OrderOpenPrice()+ Profit1*Point)

need:

                    if(Bid >= OrderOpenPrice()+ Profit1*Point)



 

How to declare a one-dimensional array without applying a write to each memory cell (is it possible)

  ии[1]=ExtMapBuffer1[0]; ии[2]=ExtMapBuffer2[0];  ии[3]=ExtMapBuffer3[0]; 

but by a one-dimensional sequence

  ии[3]={ExtMapBuffer1[0],ExtMapBuffer2[0],ExtMapBuffer3[0]} 

or is one-dimensional sequence only for numeric and logical constants!!!?

 
TheXpert >> :

Got it:

>> we have to:



Thank you, friend!

 
future >> :

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)

int OrdersDayTotal(string Symb)
 {
int cnt,
OrdersDayTotal=0,
Time0=iTime(NULL,PERIOD_D1,0);

for( cnt=0; cnt<OrdersTotal(); cnt++)
   {
   OrderSelect( cnt, SELECT_BY_POS, MODE_TRADES);
   if(OrderSymbol()== Symb && OrderType()<2)
      {
      if(OrderOpenTime()> Time0) OrdersDayTotal++;
      }
   }
for( cnt=0; cnt<OrdersHistoryTotal(); cnt++)
   {
   OrderSelect( cnt, SELECT_BY_POS, MODE_HISTORY);
   if(OrderSymbol()== Symb && OrderType()<2)
      {
      if(OrderOpenTime()> Time0) OrdersDayTotal++;
      }
   }
return( OrdersDayTotal);
 }

Counts orders Buy and Sell, for a given symbol, opened today. No pending orders.

if(OrdersDayTotal(Symbol())==0) {...}

something like this)

 
Stepan241 >> :

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.
 
Stepan241 >> :

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.
Reason: