- how to catch place a buy before it spikes
- I cant get to anything on the MQL5- I Keep Getting Error messages. Can anyone help.
- Why this code shows a wrong result?
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
- A "Boom" spike is simply an up tick (with a price higher than the previous tick).
- A "Crash" drop is simply a down tick (with a price lower than the previous tick).
In both cases, they are not related to the M1 bars. During the lifetime of a single 1 minute bar, there can often be multiple spikes on the "Boom", or drops in the "Crash".
So, instead of looking at the bar data, look at the tick data.
- A "Boom" spike is simply an up tick (with a price higher than the previous tick).
- A "Crash" drop is simply a down tick (with a price lower than the previous tick).
In both cases, they are not related to the M1 bars. During the lifetime of a single 1 minute bar, there can often be multiple spikes on the "Boom", or drops in the "Crash".
So, instead of looking at the bar data, look at the tick data.
- A "Boom" spike is simply an up tick (with a price higher than the previous tick).
- A "Crash" drop is simply a down tick (with a price lower than the previous tick).
In both cases, they are not related to the M1 bars. During the lifetime of a single 1 minute bar, there can often be multiple spikes on the "Boom", or drops in the "Crash".
So, instead of looking at the bar data, look at the tick data.
Okay , so how do i access tick data?
For example, by using ...
Gets ticks in the MqlTick format into ticks_array
- www.mql5.com
// Define your spike threshold double spikeThreshold = 0.0001; // Variables to store the number of spikes and ticks int spikeCount = 0; int tickCount = 0;
i have used the used the tick data to check for a spike but the code doesnt detect any spike i have attached image to show result
// Variable to store the last tick price double lastTickPrice = 0.0; int OnInit(){ //--- //--- return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { //--- ExpertRemove(); } void OnTick() {
// OnTick function MqlTick currentTick; if(SymbolInfoTick(Symbol(), currentTick)) { // Increase the tick count tickCount++; // Check if this is not the first tick if(tickCount > 1) { // Calculate the price difference double priceDifference = MathAbs(currentTick.last - lastTickPrice); // Check if there is a price spike if(priceDifference > spikeThreshold) { // Increase the spike count spikeCount++; // Print information about the spike Alert("Spike detected! Number of spikes: ", spikeCount, ", Number of ticks: ", tickCount); } } // Update the last tick price lastTickPrice = currentTick.last; } Comment("Spike detected! Number of spikes: ", spikeCount, ", Number of ticks: ", tickCount); }
on the image i have drawn a redline from whence the code started counting i have added two difference images to show my results
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use