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

 
nemo811:
Thank you. Is that the right thing to do?

Yes. I think so.
 
No. Sum=0 must be placed before the For statement.
 
6166961669:

I'm not sure how much it would cost to order an EA, but I'm sure I can get it to work in both charts.

Ah, and in general it is possible to make it work once for 2 different currencies (simultaneously on two charts) and opened on each of the different trades.

For example, I bought on the first one and sold on the second one?

And on closure of one of the transactions opened the opposite of the already open transaction....

And may be someone knows, maybe there is such an Expert Advisor, just a good idea came to my mind.....


Anything can be done. Please write to me in person. We'll make a deal.
 
FOReignEXchange:
Oh no. Sum=0 should be placed before For operator.

It's all working. Thank you. I found another error in the process.

I'm going to do a bit more work to see if anything else pops up, and I'll post the result in the general database.

Thanks again for your help.

 
nemo811:

It's all working. Thank you. I found another error in the process.

I'm going to do a bit more work to see if anything else pops up, and I'll post the result in the general database.

Thanks again for all your help.


You're welcome. You're welcome.
 

To: FOReignEXchange

If I at this point in the execution of the program

extern bool Buy = true;

extern double PriceBuy = 0;

int start()
{
if (Buy)
{OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-50*Point,Ask+50*Point);
PriceBuy = ??????????????????;}

return;
}

I'll specify the assignment" PriceBuy = ??????????????????;" - "PriceBuy = Ask;"

Can I be sure that as the program progresses (i.e. opening a new order with the specified conditions)

"PriceBuy will have the same value?

 
OTPOK:

To: FOReignEXchange

If I at this point in the execution of the program

extern bool Buy = true;

extern double PriceBuy = 0;

int start()
{
if (Buy)
{OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-50*Point,Ask+50*Point);
PriceBuy = ??????????????????;}

return;
}

I'll specify the assignment" PriceBuy = ??????????????????;" - "PriceBuy = Ask;"

Can I be sure that as the program progresses (i.e. opening a new order with the specified conditions)

"PriceBuy will have the same value?


How can extern double PriceBuy = 0 ? Only the constants are specified in the global variables. If it's removed from there altogether, the answer is as follows:

If no other values are assigned to the PriceBuy variable elsewhere, the value of PriceBuy = Ask; will remain valid until the calculations reach the new order opening again. Upon reaching there again, the variable will be assigned the new value PriceBuy = Ask; it will correspond to the Ask price at the moment of opening the new order.

What is the problem? It is clear.

 
FOReignEXchange:


How is it extern double PriceBuy = 0 ? Only constant numbers are specified in global variables.

Please do not confuse Our Beginners.

First: the PriceBuy variable in this case is an external variable. And an external variable is global by definition!

Second: You can assign any value to an external variable in the EA's code, but then it will lose its meaning (to be an external variable). And the global variables are precisely used to store and change their values within the entire code (the scope - the entire program). Read more.

Thirdly, if there is a Slippage in the OrderSend trade function and we want to open a Buy order, the order will not necessarily open at the Ask price because the execution of a trade order issued by the OrderSend function takes some time and the price may move away from that value.

The code shown on the previous page will be more correct:

abolk:
extern bool Buy = true;
extern double PriceBuy = 0; 
int start() 
{
   if(Buy) 
   {
     int ticket=OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-50*Point,Ask+50*Point);
     if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
        PriceBuy=OrderOpenPrice();
   }
   return(0); 
}
 
MaxZ:

Therefore, the more correct code is the one already cited on the previous page, and I quote:


"It's the way you like it. Everyone's handwriting is different. Maybe your handwriting is correct, but it looks messy to me.

I wouldn't do it that way.

First of all, I'm not quite sure why I should declare a variable there and what the point of it is I don't understand either.

Secondly, the line PriceBuy = Ask; is located right after the OrderSend function. And as far as I understand, calculations are immediately passed to the next line as soon as this function finishes its execution. I don't think the Ask price can change. I try to write everything as simple as possible, reducing the number of characters, if it doesn't interfere with normal operation of the program. I can assign a value the same way as you do, I don't see a problem here. I wrote the first and simplest thing that came to mind.

 
Right. Right. I misnamed the variable. I'll give you that. Your theory's good. But your logic isn't.
Reason: