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

 
splxgf >>:

Michey25


когда я отвечал код был несколько другим;)

хотя есть некоторые вопросы, результат опен(0) сильно зависит от текущего тайфрейма. непонятно откуда берутся cn и какого они типа.

Сделать Alert(Open[0],cn1,Open[0]<cn1,a,(a-cn1)<0.0008) религия не позволяет?

До кучи вместо i=1 лучше юзать break, это сделает выход из цикла сразу, а не будет прогонять все команды до конца.

int i=0;
   double a, b;
   while ( i==0)
   {
     a=MarketInfo("USDCAD", MODE_ASK);
     b=MarketInfo("USDCAD", MODE_BID); 
     if((Open[0]< cn1)&&(( a- cn1)<0.0008))
      {
       OrderSend("USDCAD",OP_BUY,1, a,1, SL, cn2);
       i=1;
       }
     if((Open[0]> cn11)&&(( cn11- b)<0.0008))
      {
       OrderSend("USDCAD",OP_SELL,1, b,1, SL1, cn21);
       i=1;
      }  
   }

cn, sl, cn2... All of them are double and are input parameters, and I enter them when I attach the EA to the chart. What does Alert have to do with it?

 
Rita >>:

В чем тут может быть причина, пож. подскажите ?

for(k = 0; k < iBars( Symbol_1,Period()); k++)

It runs a loop on all the bars and then it has one more embedded loop where in the first call all the bars are considered because the limit value is again equal to the number of bars in the window. Altogether we get the cycle by the number of bars squared, which is a bit redundant for such a simple task
 
Michey25 >>:

cn, sl, cn2... все типа double и являются входными параметрами, я их ввожу когда прикрепляю советник к графику. И причем здесь Alert?


You can display variable values and results of a condition with an alerts, add an if before each and see the result. This is a common method for debugging programs so that you don't have to guess and search.

 

Thank you. So at the beginning of the start() function I have to make some conditions manager, which defines call of functions that return control to the terminal and then, when a new tick is received, this manager will work again? Well... I'll have to completely rework the program logic...


So the test fails because the tester hangs waiting for a new tick? Will it work in real time? Um... It's important to be able to test it on the history. I will think about it. Thank you.

 
Jahspear >>:

Спасибо. То есть надо сделать в начале функции start() некий диспетчер условий, которые определяют вызов соответствующих ситуации функций, каждая из которые возвращают управление терминалу и дальше по получению нового тика этот диспетчер снова отрабатывает? Мдаа... придется полностью переделывать логику программы...


То есть тест не проходит, потому что тестер зависает в ожидании нового тика? А в реалтайме работать будет? Гм... все-таки возможностьоттестировать на истории это важно. Буду думать. Спасибо.

It should work in real time, the Expert Advisor is run in a separate thread and can think as long as it likes, and RefreshRates allows access to current quotes.

 
ntmmm >>:

Добрый день!

Подскажите пожалуйчта, как написать простой индикатор, который бы выделял определенный бар (должно задаваться в опциях), например в 12.30 вертикальной линией и подписать дни недели на графике (скажем где-то над хаем каждого дня)?

Спасибо!

take https://www.mql5.com/ru/articles/1382 and file it away

 
splxgf >>:

В реалтайме работать должно, эксперт выполняется отдельным потоком и может думать сколько ему взблагорассудится, а RefreshRates позволяет получать доступ к актуальным котировкам.

Thank you. I'm currently reworking the program logic so that it doesn't have loops. There is one more question that is not quite clear.

Sleep(100);


Is it how long in seconds?

And can it be used anywhere, not just in loops?

So that when a condition is met, you don't react immediately, but wait for a set time and check again, and then execute.

And won't it hang the tester?

 

ntmmm писал(а) >>

...Could you please tell me how to write a simple indicator that would highlight a certain bar (should be set in the options), for example at 12.30 with a vertical line and sign the days of the week on the chart (say somewhere above each day's hai)?

iTime indicator set

 
Jahspear >>:

Это сколько по времени в секундах?

И может ли использоваться не только в циклах, а в любом месте?

Чтобы при выполнении условия не сразу реагировать, а подождать заданное время и снова проверить, а потом уже выполнять.

И не повесит ли это тестер?

1. 0.1 (zero point one tenth)

2. could be anywhere

3. won't hang by itself, but if you set your mind to it... :)

 
alsu >>:

Thank you!

Reason: