forex software

Create and Test Forex Strategies

forex software

Skip to forum content

Forex Software

Create and Test Forex Strategies

You are not logged in. Please login or register.


Forex Software → Technical Indicators → I need help to customize this indicator

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 7

1 (edited by Houro 2017-09-08 12:07:03)

Topic: I need help to customize this indicator

Hello,
First of all after posting this post I found that i should have posted it in  Developers Forum so please transfer this topic to Developers Forum if its needed.
I decided to make a custom indicator from momentum indicator for an experiment but i faced some errors in coding it. I know probably my custom indicator is not useful, but i need it so please help me to fix the cide.
I attached the code. Most parts of it is the main momentum.cs file but i just added some lines to it. My changes start from line 111 and ends to line 133.
The usual moment indicators takes a moving average from (price[bar] - price[bar - period]) but i want to only substract the price of first bar, i mean price[1], from minimum value of all other bars. I exactly mean this: price[1] - minimumprice[1 to period]. For examplke if there is 10 bars, i want to have this:
price[1] - minimumprice[1 to 10]
My code has this error.
ERROR: "Momentum" compilation failed.
     Line 133 Column 16: Cannot implicitly convert type 'double' to 'double[]'.
Please help me to fix this issue.
I attached my customed code. (not important but I also changed the indicator name to mymomentum to avoid facing problem with this).
Thanks a lot in adavnce for your help.

Post's attachments

Momentum.cs 13.42 kb, 1 downloads since 2017-09-08 

You don't have the permssions to download the attachments of this post.

Re: I need help to customize this indicator

Now it loads up. But I think your calculation is off.

Post's attachments

myMomentum.cs 13.42 kb, 3 downloads since 2017-09-08 

You don't have the permssions to download the attachments of this post.

3 (edited by Houro 2017-09-08 13:53:50)

Re: I need help to customize this indicator

Thank you so much footon but i have a question. I wanted the momentum of first bar to be subtracted from minimum if last bars. I mean i wanted to have momentum = momen1[1] - myminimum; but the coded you provided gives  momentum[bar] = momen1[1] - myminimum;
As i mentioned before, the usual momentum indicator subtracts current bar's momentum from moving average of last i.e 20 bar's momentums but i want to subtract current bar's momentum from minimum momentum of last i.e 20 bars.
Could you please review it again?

Re: I need help to customize this indicator

You are not correct. Standard momentum subtracts previous price from current price, previous price is defined by period, meaning how many bars ago.

momentum[bar] = price[bar] - price[bar - period];

If one wishes so, the initial momentum value can be smoothed, this means making a moving average out of it.

 if (smoothing > 0)
momentum = MovingAverage(smoothing, 0, maMethod, momentum);

What I did was move your one line into for loop because you left array out in the open, hence your error. That's it.

If I understand you correctly, you have to change the same line to:

momentum[bar] = momen1[bar] - myminimum;

Another tip - momen1[1] is the second value of the array, not the last.

Hope this helps to steer you in the right path.

5 (edited by Houro 2017-09-08 19:35:54)

Re: I need help to customize this indicator

Thank you so much for your great help. My problem is solved now because of your help.
I just have another little question. I am a little confused about current bar and previous ones.
For example this code below is from three bars swing pattern wrote by popov. The link is here
http://forexsb.com/forum/topic/1199/thr … dalhoseny/

for (int bar = firstBar; bar < Bars; bar++)
{
    // Long trade
    if (Close[bar - 3] < Open[bar - 3] && // Candle 1 is black

In above code Close[bar - 3] is 4th previous bar?
So the high price of the current bar which is not closed yet would be
high[bar]?

Re: I need help to customize this indicator

Yes, High[bar] is current bar.

Re: I need help to customize this indicator

Thank you very much for your excellent support.

Posts: 7

Pages 1

You must login or register to post a reply

Forex Software → Technical Indicators → I need help to customize this indicator

Similar topics in this forum