Fit a sine wave

Indicators

Job finished

Execution time 19 days
Feedback from customer
Good job, did a lot of effort, thanks.

Specification

I have an indicator, it's an oscillator. I want to plot a sine wave on it that fits its shape closely: for this it needs to change amplitude, phase and period (frequency) all the time (because the oscillator is based on the market, which is not periodic). One of the buffers in the code should be the period of the sine wave: this is what I am interested in as an input for other indicators, so I should be able to use that: comment in the code which buffer it is in, and the code should be written that it is easy for me to take that value as an input for another indicator, or other code that will be added by me. So the idea is to break down an existing indicator into sine waves: decompose the signal with a 1 term Fourier decomposition f(x) =  a0 + a1*cos(x*w) + b1*sin(x*w). Fourier theory states that if the signal is stationary, you can break down any signal using sine and cosine functions as basis functions. 

The transition from the first sine wave (orange) with the first period (40) into the next sine wave (blue) with the next period (50) can be smooth if the difference in periods is not too large and the phase of the next wave is chosen to smoothly continue the previous one: the key thing is that the phase will have a value as if it was continuing the same wave: only the period and amplitude change: if you look at the red rectangle, you see that the blue curve is almost a continuation of the orange curve: in sine wave terminology this means that the phase of the combined wave only changed a little more than what one would expect if the orange wave would continue.

s1 

 The important element here is that the shape needs to be continuous: no sudden changes unless the input signal (indicator it’s calculated on) changes really suddenly.

 s2

 So above the picture is somewhat wrong because it thinks of this task as trying to fit segments of sines to the input signal: this is not really the case: you need to use the trick with the phase (use previous’ bar sine’s phase) to create a continuous output signal.

 s3

 

 

Above, if you look at the blue curve in Figure 1, you see that it first goes up, it accelerates its increase, then it reaches a maximum and then it goes down: first a bit quicker, then a bit slower. Now if you cut the blue line where the small vertical red lines are drawn you get pieces A, B & C as in Figure 2: green, yellow and gray respectively. Now if I look at the sine wave indicator that I attached, and leave the phase at 0 and the period at 1, and I play a bit with the period variable to get a sine wave from which part A could be cut out of, I see, after a bit of trial and error, that part A could be a part from a sine wave with a period of 40 (approximately: I did this manually, so I'm probably off by a more than a few digits): as you see in Figure 3: the red curve (sine wave with period 40) can pretty much follow the green curve (part A) without any interruption. The same goes for Figure 4 where the yellow curve (more or less: remember I drew it manually) is the start for a continuously flowing sine wave with period 50. In Figure 5 we see again that part C fits right into a part of a sine wave with period 120.

 

So in this example, the blue line is a combination of 3 sine waves: one with period 40, that turns into one with period 50, that gradually transforms into one with period 120. The interesting element is that we can see this in real time: if the period of the wave would be a constant 40,like in part A, there would be no fit any more. In fact there is probably an increase between part A and B: I should have put another piece in there because the blue line keeps increasing too long: this is where the period should be increased, and maybe even the amplitude also. So you are actually continuously fitting pieces of sine waves onto your input data.

 

 

Please use this type of loop:

 

int start()

  {

   int limit;

   //double ...;

   int counted_bars=IndicatorCounted();

   if(counted_bars<0) return(-1);

   if(counted_bars>0) counted_bars--;

   limit=Bars-counted_bars;

 

   for(int i=0; i<limit; i++)

   {   

 

   // here comes your code

 

   }

   return(0);

  }

 

 

The indicator will be given in a private message once you accept the project. I can also give you a primitive sine wave indicator in mql4 (that doesn't change phase, frequency and amplitude) and a linear regression indicator. 

Responded

1
Developer 1
Rating
(7)
Projects
17
18%
Arbitration
5
0% / 60%
Overdue
9
53%
Free
Similar orders
Hello, I would like to discuss with a good MT5 programmer to modify an indicator. The programmer must first provide a prototype before I create a personal order for him
Hello I'm trying to fix a indicator that I have, It's a .ex4 file, Can I just code a new indicator because I only have a failed version of it in a ex4 file. Here are the three files. They are EX4 files. So i wanted to have a trade panel that can fill up the whole screen where it shows all the pair symbols. MTF_TMA_Harmonic ex4 file is exactly what I'm looking for however the ex4 file for some reason doesn't work
I have a machine learning library in MT5 that I want to make an indicator with… You think you can help me? My strategy is simple... Predicting the Daily, Weekly, and Monthly High, Low, and Close prices... Then BUY @ LOW and SELL @ HIGH
My EA places orders when an arrow appears according to the pz day-trading indicator. 1) I need to change the indicator, so that it places orders when the stock indicator arrow appears. All other EA conditions remain the same. 2) I need it to place orders when the candle turns colored according to the Pvsar indicator. The only change is that for pvsra I need a buy order to be placed above the high of the candle that
Hello there, I'm trying to fix a indicator that I have, It's a .ex4 file, Can I just code a new indicator because I only have a failed version of it in a ex4 file. Here are the three files. They are EX4 files. So i wanted to have a trade panel that can fill up the whole screen where it shows all the pair symbols. MTF_TMA_Harmonic ex4 file is exactly what I'm looking for however the ex4 file for some reason doesn't
Hello I'm trying to fix a indicator that I have, It's a .ex4 file or Can I just code a new indicator because I only have a failed version of it in a ex4 file. Here are the three files. They are EX4 files. So i wanted to have a trade panel that can fill up the whole screen where it shows all the pair symbols. MTF_TMA_Harmonic ex4 file is exactly what I'm looking for however the ex4 file for some reason doesn't work
Hi everyone I have a question, is there anyone who can rewrite the code from tradinvivew pineditor to mql5 meta trader? It is about 150 line. My strategy has 50% success rate with RR 2,6. Tested for last one year, strategy works only in bull market. This is trading on gold, unfortunately I am not in the best financial position, in return I would send you the code, if you don't like it I understand that you will stop
Editing of strategy 30 - 60 USD
I have a strategy that i would like edited. I have a strategy where right now it takes profit at the next high or low. That can be removed if necessary. The SL is set using the current RSI Band Gap. I'd like the same to be done for the TP. You'll see in the settings that I have a SL and TP buffer. I would also like for those to be kept the same but again I just want the TP to be the RSI Band Gap. It'll make more
need a professional developer to modify my current indicator. Need to add time frame parameter with true .false option. Which i set true show only those TF signal and when all signal match with the current TF ( to enter trade). Alert get generated. Price is non negotiable .please don't respond if you don't agree to price. Thank you
create a scanner for find bos and choch indicator on the chart, I want the indicator based on line charts rather than candlesticks .the indicator can scanner all symbols and all timefimes when i want. Create a panel that displays symbols, time and indicates whether it is bos or choch. the scanner can alert to my phone terminal. If you are interested please contact me

Project information

Budget
100 - 150 USD
VAT (21%): 21 - 31.5 USD
Total: 121 - 181.5 USD
For the developer
90 - 135 USD
Deadline
from 1 to 7 day(s)