[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 40

 
Noterday:

I have inserted a new block in my EA to calculate the lot size of the position to be opened. The idea is as follows:

1. Stop is set to the High of the current day in case of Sell position, and to the Low of the day in case of Buy position.

2. When the condition for opening of the order triggers, this block for lot calculation starts to be executed. The distance to the High/ Low of the day in points is calculated and I loop through the lots starting from 0.1 to find the needed lot (5% when a stop has triggered)

But such lines appear in my journal:

2011.01.30 16:59:47 TestGenerator: unmatched data error (volume limit 1107 at 2011.01.13 14:45 exceeded)

As soon as I turn off this block, everything is OK. Where am I wrong? Can you tell me please?

Here is the code itself:

It is unlikely that the tester message is related to your code.

Try again and again to recalculate all timeframes in Quote Archive.

The message says that the volume of 1107 was reached at 14:45, which is completely impossible, as the trading continued till 24:00.

However, this error is quite negligible.

 
Saltan:

When trying to compile a include file (*.mqh) an error '\end_of_program' - no function defined. What's wrong and how to fix it?

extern double Lots = 0.0;
extern int Percent = 0;
extern int StopLoss = 100;
extern int TakeProfit = 40;
extern int TrailngStop = 100;

int Level_New;
int Level_Old;


It happens and it is normal. For example, in my Variables.mqh - expert's external and global variables are specified...when compiling, it says '\end_of_program' - no function defined, some kind of missing end in program, no function defined, but when compiling expert itself, everything is OK - 0 errors, 0 warnings. (*.mqh) - do not compile separately, when compiling the Expert Advisor itself, the compiler will put all its inludes together and it will decide whether there are errors, no errors, etc. :-))) So everything is normal. Try to compile itself...

P.S. When compiling other inludes, compiler may write that some global variable is not defined... Of course, it doesn't have to be defined if you have it in a completely different inline. Note the order in which the inludes are placed... If a variable is defined in one inlude and used in another, the first inlude has to be placed before the second, otherwise an error will occur during compilation - some variable is not defined, in general all global variables are defined in the outer inlude. Or alternatively they can be defined in any other, if only this one uses these variables. Somehow... It's rather vague but should be understandable. Try it out.

 
DhP:

It is unlikely that the tester message is related to your code.

Try again and again to recalculate all timeframes in Quote Archive.

The message says that volume 1107 was reached at 14:45, which is completely impossible, as trading continued until 24:00.

However, this error is quite negligible.

Well, when this block is commented out, everything is fine in the tester. So the error is in this block...
 
100yan:
No problem... But how do you determine the current value of the TF in the code?

Period() would help
 
Sergey_Rogozin:

I looked at the cover of the STUDY book from all sides and still don't understand anything...))

Everywhere I see it written like this:

Is the below writing fair if I want to get Price = OrderOpenPrice() for further processing and setting Stops?

It works for me, but is this acceptable?

Your line is as valid as the first one.

This way you can get any information about an open order,

but only once at the time of opening confirmation.

See https://docs.mql4.com/ru/trading/OrderSe nd

 
Noterday:
Well, when this block is commented out, everything is fine in the tester. So the error is in this block...
    double DistanceToHighDay = MathAbs(HighDay-Ask)*10000;
    double DistanceToLowDay  = MathAbs(Bid-LowDay)*10000;

Most likely due to your handling of the day's data, which is not consistent in volume with the minutes,

and the tester warns you about it.
 
The HighDay and LowDay variables are used not only in this block, but also in other places in the program, so I think they have nothing to do with it. Do you think the algorithm of that block is correct?
 

Can someone do a better job?

1. A stop is placed on the High of the day at a Sell position.

2. Then we calculate the distance in pips from the current price to the High of the day.

3. Calculate how much this distance will be in $ with 0.1 lot and calculate how much it will be in % of the deposit. If it will be less than 5%, then count for 0.2 lots and so on until it exceeds 5%.

And then this will be the lot size you need.

My code does not work for some reason....though everything seems to be written correctly.

 

WHO KNOWS?

how do I programmatically refer to the Bollinger that says - apply to "Previous Indicator's Data" ? what should I put in the applied_price field ?

thanks

 

Good day to all. Question: How do I get CheckEvents to work? The Events file (from Komposter) is in the include directory. There is an example in EventsExpert.mq4:

CheckEvents( MagicNumber );

        if ( eventBuyClosed_SL > 0 )
                Alert( Symbol(), ": Buy-позиция закрыта по СтопЛоссу!" );

But I don't need Alert. I need the pending order to be deleted when the market order closes at Stop Loss.

CheckEvents( Magic==0 );
    
   if (eventBuyClosed_SL > 0)
   ??????????? 
        
   DELETE("Buy Stop");

What should I put instead of the Alert? If this function is suitable for the purpose.