[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 879

 
It turns out as follows. I have opened and closed a lot of orders, but need only one and that's it. Maybe, everything may be elementary, but I got stuck. I have been trying to ensure that, when a certain condition (crossing) is met, one order is opened and the variable gets a certain value. Then I have included this variable into the condition of opening of orders but nothing happens. One order is opened, then the second one, then the third one...
 
prom18:
The result is as follows. You open and close a lot of orders, while you need only one. Maybe, it all can be elementary, but I have not got a fix. I tried to make only one order be opened and the variable get a certain value when a certain condition is fulfilled (crossing). Then I have included this variable into the condition of opening of orders but nothing happens. One order is opened, then the second and the third ones.


I need code or a piece of code - without code just on the board level

and there is not much advice:

1) check for the number of open orders on this signal

2) check for the time of the signal (connect to the current bar if there is only one signal within the bar)

3) jointly 1) and 2)

 
abolk:


I need a code or a piece of code - without code just on the board level

and there is not much advice:

1) check for the number of open orders on this signal

2) check for the time of the signal (connect to the current bar if there is only one signal within the bar)

3) jointly 1) and 2)

Thank you! I will try it.

 
Thanks for the tip on debugging the EA. By the way, I'm still new to the forum and don't always understand the slang. What is IMHO? :)
artmedia70:

I don't remember telling you how to access the forum... :)

I don't think anyone will be able to help you here without the EA itself from the Optimization Log entries alone. Psychics have been resting for a decade... :)

And why are you trying to optimize it at all? Just run the test first and look for errors.

Optimization, if at all, is needed at the final step of testing of the Expert Advisor and the strategy as a whole

in order to find the optimum values of the variables. However, I personally, IMHO, believe that it is just a stupid fitting to the historical data,

therefore I try to do everything dynamically in my EAs relying on the EA itself in calculation of the optimum values of the variables.

 
boris.45:
What is IMHO? :)
You could just say, "In my opinion."
 

while or if ?

Professionals, please explain the ins and outs.

I tested it on GBPUSD on February 2, 2010.

№1

int start()
{ if(OrdersTotal()==0) //when there are no orders
OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask-60*Point,Ask+30*Point);
return; }

This one works, opened and closed 4 orders.

№2

int start()
{ while(OrdersTotal()==0) //when there are no orders
OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask-60*Point,Ask+30*Point);
return; }
This one doesn't want to work; here is what it says in the log:

Modified it a little, it worked.

№3

int start()
{ while(OrdersTotal()==0) //when there are no orders
OrderSend(Symbol(),OP_BUY,0.1,NormalizeDouble(Ask,4),3,
NormalizeDouble(Ask-60*Point,4),NormalizeDouble(Ask+30*Point,4));
return; }

Actually, questions:

Why with " if " (#1) all opening/closing prices with four-digit quotes, but closing the last order is at five-digit?

Why does "while" (#2) not want to work, what is wrong with the price?

Why does "while" (#3) when specifying the opening price through NormalizeDouble (Ask,4) cause the first order to open and the last order to close in five-digit quotes?

What is the fundamental difference between if and while in this case (#1 and #2)?

P.S. And if I run separately 8.02.10, all three work.

I would be very thankful for answers or links.

 

Can someone tell me how to write in an EA "if order profit is +5%, then ........"?

 
FoxUA:

who can tell me how to write in an EA "if order profit is +5% then ........".


define what does 5% mean ?

% shows the ratio of one value to the other, I think you are looking for a 5% equity increase, then

if (OrdersTotal()<1) eq=AccountBalance();
.....


if (AccountEquity()> eq+eq/100*5){
// прирост эквити на 5%


}

if you are still interested in order profit change, then OrderProfit() from remembered

 
IgorM:


Define what does it mean 5% ?

% shows the ratio of one value to the other, I think you are looking for an equity increase of 5%, then

if you are still interested in changing of the order profit, OrderProfit() from the memorized one


Maybe I didn't express it correctly, I need a change for example BalansEURUSD to show profit or loss in percentages "BalansEURUSD =5%" or something like that

and so on several pairs let's say for pound and dolren

one time

 
Vinin:
You could just say, "In my opinion."
Thank you, Victor... :) I'll add more of my own:
________________________________________________________________________________________________________
Literally: from English IMHO "In My Humble Opinion" (In My Humble Opinion or In My Honest Opinion).
Or colloquially in Russian, with slang: IMHO = "I have an opinion, you can't argue with it" ... :)))))