[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 21

 
rigonich:


Do you haveflag as a local variable?

P.S. When it's not quite clear what's going on, it's better to print out the values before and after the function or statement you want to check, to see how they change. Sometimes input values are not what we expect them to be, and finding where and why they become what they are is much easier in code than guessing why the program doesn't work correctly.


oh shit...exactly...if you take int flag,flagg; out of Start function...then everything works at once :)) another stupid rookie mistake :) THANK YOU!

 
lottamer:

oh shit...right...if you take int flag,flagg; out of the Start function...then everything works at once :)) another stupid rookie mistake :) THANK YOU!


It is not only beginners who may make such mistakes, for example, you may inattentively declare a local variable with a name which the global variable already has. The compiler will not generate errors in this case, but the program does not work "correctly". The main thing is to be able to detect such errors.
 

I am using this function to limit the number of simultaneously traded orders, but in fact the number of orders is 1 more than the number set in the MaxOrders variable. What may be the reason?

   for(i=0; i<=OrdersTotal(); i++)
    {
     if(OrderSelect(i,SELECT_BY_POS)==true)
      {
       if(OrderMagicNumber()==ExpertID)
        {
         if(i>=MaxOrders)
          return;
        }
      }
    }
 
silhouette:

I am using this function to limit the number of simultaneously traded orders, but in fact the number of orders is 1 more than the number set in the MaxOrders variable. What may be the reason?


We register orders starting from zero. That is why it looks like this:

 for(i=0; i<=OrdersTotal()-1; i++)
    {
     if(OrderSelect(i,SELECT_BY_POS)==true)
      {
       if(OrderMagicNumber()==ExpertID)
        {
         if(i>=MaxOrders)
          return;
        }
      }
    }
 
Roman.:

The accounting of orders comes from scratch. Therefore it is like this:



Thank you
 
Roman.:

Here's a look at how the textbook stochastic counts.





Thank you!!!
 

How can this be? I have an EA, it works. It buys, sells ... all clear stops and takei. but the loss is a lot, so I decide to prescribe another trend filter. two averages - fast and slow - on a very large TF. on H4.

The Expert Advisor should look like this

if (....)

{....

...}

once again - everything works!

and here I put a filter (before that I define MA1=iMA...) and almost at the very top of the if tree (the second condition - and the first one - time if ( Hour()>=7 && Hour()<20)

if (....)

if MA1>MA2

{

{....

...}}

no errors.

But 95% of trades are cut off! And on H4 the picture says the opposite - there must be lots of trades, becauseMA1>MA2 is executed for weeks!

can someone explain what is wrong?

 

When there are a lot of lines on the chart (horizontal), the labels (line price) on the price scale from these lines "clog" the whole scale.

What is this "tail" parameter with the line price? And is it possible to disable it somehow? (I haven't even found a manual way, but I need a software way)

And I'll just put the price in the line name - that's enough.

 
Help to know what is the error "EURUSD,M30: uninit reason 5" when the advisor works often when it needs to open a new position it writes this error and the whole system breaks down (( if there is any code for fixing this error please send me an example.
 
Frostr:
Help me check what is the error "EURUSD,M30: uninit reason 5" when my advisor is running often when it needs to open a new position it writes this error and the whole system breaks down (( if there is any code to help correct this error please post one example


Reason codes returned by UninitializeReason(). Can have any of the following values:

Constant .ValueDescription
0The script has completed its work independently
REASON_REMOVE1The program has been deleted from the chart
REASON_RECOMPILE2Program recompiled
REASON_CHARTCHANGE3The chart symbol or period has been changed
REASON_CHARTCLOSE4The chart is closed
REASON_PARAMETERS5Input parameters were changed by the user
REASON_ACCOUNT6Another account was activated
Reason: