[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 47

 
PapaYozh:


No it isn't. It got even worse :)

Understand, RefreshRates() updates the values of the predefined Ask and Bid variables, you are using the value once stored in the Price variable.


Got it :-) I thought Price was only accessed when the execution in this function reaches OrderSend

 int OpenPosition(string AdvisorName,int Position,int Magic,double Lots,double StopLoss){ 
 int N; int Сount = 5; int Slippage = (CalculateSpread() * 2); double Price;
 string PeriodString = GetPeriod(Period());
 if(Position == OP_BUY){
 string OrderName = StringConcatenate(AdvisorName," - Покупка по рынку");
 string ErrorName = "Ошибка открытия ордера на покупку";
 string CriticalErrorName = "Невозможно открыть ордер на покупку";
 string MailCriticalErrorName = "Ошибка открытия"; color Arrow = Gold;}
 if(Position == OP_SELL){
 OrderName = StringConcatenate(AdvisorName," - Продажа по рынку"); ErrorName = "Ошибка открытия ордера на продажу";
 CriticalErrorName = "Невозможно открыть ордер на продажу";
 MailCriticalErrorName = "Ошибка открытия"; Arrow = YellowGreen;}
 
 while(IsTradeContextBusy() || !IsTradeAllowed()){int Interval = MathRand()+1000; 
 Print("Торговый поток занят. Повторная проверка через "+DoubleToStr((Interval/1000),0)+" сек"); 
 Sleep(Interval);} while(N < Сount){
 if(Position == OP_BUY){RefreshRates(); Price = NormalizeDouble(Ask,Digits);}
 if(Position == OP_SELL){RefreshRates(); Price = NormalizeDouble(Bid,Digits);}
 int Ticket = OrderSend(Symbol(),Position,Lots,Price,Slippage,StopLoss,0,OrderName,Magic,0,Arrow);
 if(Ticket > 0){if(OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES)){int Flag = 1; 
 PlaySound("recharge.wav"); break;}}
 else{Flag = 0; int PRM = GetLastError(); string ERR = Error(PRM,"OrderSend()"); 
 ErrorProcessing(AdvisorName+" "+PeriodString,ErrorName+" "+PRM+" ("+
 Error(PRM,"OrderSend()")+")","","OrderSend()"); N++; Sleep(5000);}
 if(N == Сount){ErrorProcessing(AdvisorName+" "+PeriodString,CriticalErrorName,
 MailCriticalErrorName+" "+PRM+" ("+Error(PRM,"OrderSend()")+")","OrderSend()");}}
 return(Flag);}
It seems to be right now, doesn't it?))
 
Dimoncheg:


Got it:-) I thought Price was only accessed when the execution in this function reaches OrderSend

Now it seems to be correct, right?))


I think so.
 
int BlackOrWhite(int countbar)
{
int result_=0;
 
if (iClose(NULL,0,countbar)-iOpen(NULL,0,countbar))
result_=1;
else
result_=-1;
 
if (iOpen(NULL,0,countbar)==iClose(NULL,0,countbar))
result_=0;
 
return(result_);
}

function, gives only one value for some reason + compiler swears :

'iClose' - comparison expression expected

I don't understand what's wrong.

if(BlackOrWhite(1)>0)
      {
so use it in the programme.
 
nuan:

function, gives only one value for some reason + the compiler frowns:

'iClose' - comparison expression expected

I don't understand what's wrong.

This is how I use it in my application.



if (iClose(NULL,0,countbar)-iOpen(NULL,0,countbar)>0)
   result_=1;
else
   result_=-1;

Or it goes like this

if (iClose(NULL,0,countbar)>iOpen(NULL,0,countbar))
   result_=1;
else
   result_=-1;
 
PapaYozh:

I think so.

Everything seems to be working, thank you.
 
Thank you very much.
 

Hi. I need some help. The question is this:

Once an order has been triggered no matter how all other orders need to be closed. And again by the condition new ones should open.

 
sergey_r:

Hi. I need some help. The question is this:

After an order has been triggered no matter how all other orders need to be closed. And again by the condition new ones should open.


Have you read the textbook at this point?
 

I have so far used

static bool order_opened = false;

if(order_opened){return(0);}

OrderSend(Symbol(),OP_BUYLIMIT,0.1,cena_buy,3,sl_buy,tp_buy,"",14774,0,Blue);
Alert (GetLastError()); // Error message on order placement
order_opened = true; // if the order has worked, do not open again

Now, we have to open a new order after the order has worked out.


 
sergey_r:

I have so far used

static bool order_opened = false;

if(order_opened){return(0);}

OrderSend(Symbol(),OP_BUYLIMIT,0.1,cena_buy,3,sl_buy,tp_buy,"",14774,0,Blue);
Alert (GetLastError()); // Error message on order placement
order_opened = true; // if the order worked, do not open again

Now we only need to open a new order after the order has worked out.



Read the tutorial and documentation, change the logic for opening, closing by pose condition, insert code via CTRL+ALT+M.