Questions from Beginners MQL4 MT4 MetaTrader 4 - page 77

 
John Smith:


In the code, the values are taken as follows:

Value[1] = current/current+6

Value[2] = current+1/current+7

Value[3] = current+2/current+8


The division is a piece of momentum formula with a window of 6 bars.

Is there an error in such an entry?

Where did you find the window?

And what do you think your expression Value[1] = current/current+6 will be equal to, if current=1, I think 7?

 

Hello, everyone!

I need some help. I am writing an EA. It uses a trading panel based on CAppDialog. The problem is that when I start to switch timeframes the panel is not always but often splits. And the guts of the old panel remain and a new one is drawn but not correctly. I have only to delete the chart and start a new one since it's impossible to continue working with this chart and the panel.

I am attaching the EA for review and analysis.

Thank you for all your help.

Files:
6f5djt.mq4  18 kb
 
Rustem71:

Hello, everyone!

I need some help. I am writing an EA. It uses a trading panel based on CAppDialog. The problem is that when I start to switch timeframes the panel is not always but often splits. And the guts of the old panel remain and a new one is drawn but not correctly. I have only to delete the chart and start a new one since it's impossible to continue working with this chart and the panel.

I am attaching the EA for review and analysis.

Thank you for all your help.


When you switch the TF you have to re-initialize the panel...

and dig in the classes, the panel is not deleted completely during deinitialization

 
Taras Slobodyanik:


When switching TFs, the panel needs to be re-initialised...

and dig into the classes, the panel is not deleted completely when deinitialised

I haven't quite figured it out yet. I have to dig through a lot of classes. But the question is why the first switch goes well and the next one kills the panel. I have already removed all unnecessary things from it. I left only the frame so to speak. But the problem remains. I'm working on it now. If you have any ideas I'd love to hear about it.

Thank you!


Now I found out that the first time the panel is deleted and re-created by the init, and the second time the panel remains hanging.

Maybe the iniit should not be loaded the second time? Or delete it in some other way.

Files:
mrdv0d.mq4  7 kb
 

I just started to understand it, I need help from the pros.

I want to use the built-in stochastic indicator to receive notification of a signal (slow and fast stochastic crossing outside the 80/20 boundaries)

I have understood how to get data with iStochastic: I write my own indicator, call iStochastic for bars, analyze it and send alert.

I don't understand what to do in this situation: if I use a big timeframe, for example 4 hours, then a new bar will appear at the end of the timeframe,

and the indicator is called to recalculate. I.e. the timeout is 4 hours.

But I want to analyze the information constantly, i.e. as soon as the price changes (bid ask) recalculate the stochastics and

if criteria meet the condition I want to be notified. I don't want to wait for the end of timeframe and appearance of a new candle.

Please advise where to look and if it is possible to implement.

Maybe I don't fully understand the essence of the processes and am digging in the wrong place, I am a novice).

 
Rustem71:

I haven't quite figured it out yet. There are a lot of classes to dig through. But the question is why the first switch goes well and the next one kills the panel. I've already removed all the unnecessary things from it. I left only the frame so to speak. But the problem remains. I'm working on it now. If you have any ideas I'd love to hear about it.

Thank you!


Now I found out that the first time the panel is deleted and re-created by the init, and the second time the panel remains hanging.

Maybe the iniit should not be loaded the second time? Or delete it in some other way.


All done! ThanksTaras Slobodyanik gave me an idea.

During the init, prohibited to create a panel if there was a change of TF. And in deinit prohibited to delete the panel if change of TF occurs.

 
VladPro77:

I just started to understand it, I need help from the pros.

I want to use the built-in stochastic indicator to receive notification of a signal (slow and fast stochastic crossing outside the 80/20 boundaries)

I have understood how to get data with iStochastic: I write my own indicator, call iStochastic for bars, analyze it and send alert.

I don't understand what to do in this situation: if I use a big timeframe, for example 4 hours, then a new bar will appear at the end of the timeframe,

and the indicator is called to recalculate. I.e. the timeout is 4 hours.

But I want to analyze the information constantly, i.e. as soon as the price changes (bid ask) recalculate the stochastics and

if criteria meet the condition I want to be notified. I don't want to wait for the end of timeframe and appearance of a new candle.

Please advise where to look and if it is possible to implement.

Maybe I don't fully understand the essence of the processes and am digging in the wrong place, I am a novice).


// Инициализируем переменную для проверки
datetime time_svecha;        //время предыдущей свечи 
...

// В начале исполнительного кода проверяем на приход новой свечи:
if(iTime(NULL,PERIOD_CURRENT,0) == time_svecha) return;

...

// В конце исполнительного кода присваиваем время новой свечи 
time_svecha = iTime(NULL,PERIOD_CURRENT,0);
 
Can you tell me what needs to be done in the trading panel so that it can work in the tester specifically in visualisation mode. Or is it very complicated?
 
Rustem71:
Can you tell me what needs to be done in the trading panel so that it can work in the tester specifically in visualisation mode. Or is it very complicated?


If for an indicator, it should work
If it's for Expert Advisors, events don't happen in the Strategy Tester (for Expert Advisors) and the timer doesn't work...

If it works in the tester, then the panel is drawn differently - ask objects (have changed / moved) and redrawn as needed, react to clicks...
Also, emulate the timer, if necessary.

 
Rustem71:


Thank you, but not quite the same)

I describe the following situation.

1. The timeframe ended, a candle was formed. The indicator is recalculated, it is drawn.

2. A new timeframe starts.( There is nonew candle until its end). Bid and Ask change during this timeframe.

I want to react to these price changes (during the current timeframe, the candle is not formed yet).

It's not even a question of drawing the charts, but of fixing the moment by a condition. I want to receive an alert as soon as the stochastics have crossed (we have three hours left till the end of the timeframe and the condition is fulfilled now).

And the chart can be drawn when the timeframe ends.

Reason: