# Momentum Prices

Do you need a trading robot? Orderit via Freelance service!
145
2014.02.28 11:26

Hello There

Here I am again trying another strategy and facing new issues.

I am importing in an array market prices and Momentum prices using 7 different mom periods

10,55,89,144,233,377,610 in 3 different positions.

The issue is that I don’t take mom prices for 233,377 and 610 for the last 2 position.

Every position needs at least the periods in candles plus the previous position.

For example ds_array_ATF[0][10][4] needs 610 Candles / Periods,

ds_array_ATF[1][10][4] needs 610 * 2 Candles / Periods,

ds_array_ATF[2][10][4] needs 610 *3 Candles / Periods.

I have come to a conclusion that mom fails to count all this Candles / Periods so it doesn’t return any value.

Can anyone imagine something else or knows any solution ?

Hera is my code…

```//+------------------------------------------------------------------+
//|                                        Mom Fibo Trading v1_3.mq4 |
//|                                                                  |
//+------------------------------------------------------------------+
#include <WinUser32.mqh>
#include <stderror.mqh>
#include <stdlib.mqh>
extern double percent_depo = 15;

double  long_order[4][4],             short_order[4][4];
int  long_order_mom,         short_order_mom;
int  long_order_again,       short_order_again;
int  long_order_mom_again,   short_order_mom_again;
int  no_close1, no_close2,   no_close3,no_close4;
double  lot_size = 1;
double  take_profitS = 500, take_profitSmom = 500, take_profit = 900, stop_loss =500,stop_lossS = 360,stop_lossSmom = 50;// an tha bgalei error ennoo

double startlong;

int mom_timeframe,  mom_applied_price;
extern int mom_period;

//--- Finding  Tops & Bottoms for 4H ------------------------------
int  ds_position;                      //------ Pointer of ds_array[][]
double  ds_array_ATF[20][30][20];        //------ DonchianSwing ARRAY [X][0]=VALUE & [X][1]= 1 top_4H / 0 BOTTTOM --
//-- Donchian  for 4H ---------------------------------------------
extern int  ds_periods=6;                    //------ Donchian Swing Periods
int  ds_timeframe = PERIOD_H1;

double money_management()
{
double lot;
double min_lot = MarketInfo(Symbol(),MODE_MINLOT);
double max_lot = MarketInfo(Symbol(),MODE_MAXLOT);
string symb    = Symbol();
double one_lot = MarketInfo(symb,MODE_MARGINREQUIRED);
double step    = MarketInfo(symb,MODE_LOTSTEP);
double free    = AccountFreeMargin();

if ( percent_depo > 100.0 ) percent_depo=100.0;
if ( percent_depo==0.0 )    lot=min_lot;
else                        lot=MathFloor((free*(percent_depo/100.0))*0.001);

if ( lot>max_lot ) lot = max_lot;
if ( lot<min_lot ) lot = min_lot;

return(lot);
}
//+--------------- Initialization --------------------------------------------------+
int init()
{
long_order_again = 1;      short_order_again = 1;
long_order_mom_again = 1;  short_order_mom_again = 1;
no_close1 = 1; no_close2 = 1; no_close3 = 1; no_close4 = 1;
}
//+--------------- Deinitialization ------------------------------------------------+
int deinit()
{return(0);}
//----- DS Initialization --------------------------------------------------------
void ds_init(int ds, int tf)
{
if ( tf == 4 )
{
if ( ds == 0 ) { ds_timeframe = PERIOD_H1; ds_periods = 10;}
if ( ds == 1 ) { ds_timeframe = PERIOD_H1; ds_periods = 55;}
if ( ds == 2 ) { ds_timeframe = PERIOD_H1; ds_periods = 89;}
if ( ds == 3 ) { ds_timeframe = PERIOD_H1; ds_periods = 144;}
if ( ds == 4 ) { ds_timeframe = PERIOD_H1; ds_periods = 233;}
if ( ds == 5 ) { ds_timeframe = PERIOD_H1; ds_periods = 377;}
if ( ds == 6 ) { ds_timeframe = PERIOD_H1; ds_periods = 610;}
}
}
//----- Mom Initialization -------------------------------------------------------
void mom_init(int mom, int tf)
{
if ( tf == 4 )
{
if ( mom == 0 ) { mom_timeframe = PERIOD_H1; mom_period = 22; mom_applied_price = PRICE_CLOSE;}
if ( mom == 1 ) { mom_timeframe = PERIOD_H1; mom_period = 55; mom_applied_price = PRICE_CLOSE;}
if ( mom == 2 ) { mom_timeframe = PERIOD_H1; mom_period = 89; mom_applied_price = PRICE_CLOSE;}
if ( mom == 3 ) { mom_timeframe = PERIOD_H1; mom_period = 144; mom_applied_price = PRICE_CLOSE;}
if ( mom == 4 ) { mom_timeframe = PERIOD_H1; mom_period = 233; mom_applied_price = PRICE_CLOSE;}
if ( mom == 5 ) { mom_timeframe = PERIOD_H1; mom_period = 377; mom_applied_price = PRICE_CLOSE;}
if ( mom == 6 ) { mom_timeframe = PERIOD_H1; mom_period = 610; mom_applied_price = PRICE_CLOSE;}
}
}
//----- Finding Tops & Bottoms for 1H --------------------------------------------
void find_ds_top_bottom(int depth, int ds, int mom, int snd_position, int tf)
{
//----- Fill    DS Array -------------------------------------------
int   i, db=0, dt=0;
double   z, x;
ds_init(ds, tf);
mom_init(mom, tf);

ds_position = 0;

for(i=0; i<3000; i++)
{
x = iCustom(Symbol(),ds_timeframe,"DonchianSwing_v2",ds_periods,0,i);
z = iMomentum(Symbol(),mom_timeframe,mom_period,mom_applied_price,i);
//z = iCustom(Symbol(),mom_timeframe,"Momentum Custom",mom_period,0,i);
//--Storing DS Prices----
if(x>0)
{
ds_array_ATF[ds_position][snd_position][tf] = x;
ds_array_ATF[ds_position][snd_position+10][tf] = z;
//------- Finding if it's top_1D or bottom_1D ---------------------
if ( ds_array_ATF[ds_position-1][snd_position][tf] > ds_array_ATF[ds_position][snd_position][tf])
{ ds_array_ATF[ds_position-1][snd_position+20][tf] = 1; ds_array_ATF[ds_position][snd_position+20][tf] = 0; db++; }
else
{ ds_array_ATF[ds_position-1][snd_position+20][tf] = 0; ds_array_ATF[ds_position][snd_position+20][tf] = 1; dt++; }
ds_position++;
}
if ( db >=depth && dt >=depth ) i=3001;
}
}

int ds(int c)
{
string txt;
switch(c)
{
case 0 : txt = 10; break;
case 1 : txt = 55; break;
case 2 : txt = 89; break;
case 3 : txt = 144; break;
case 4 : txt = 233; break;
case 5 : txt = 377; break;
case 6 : txt = 610; break;
}
return(txt);
}
//+--------------- Start -----------------------------------------------------------+
int start()
{
int   i,z,limit;

for( i=0; i<=6; i++ )
find_ds_top_bottom(3,i,i,i,4);

for( z=0; z<=6; z++ )
{
+ " DS["+(1)+"]["+(z)+"][4] : " + ds_array_ATF[1][z][4] + " DS["+(2)+"]["+(z)+"][4] : " + ds_array_ATF[2][z][4] + "\n";
+ " MOM["+(1)+"]["+(z+10)+"][4] : " + ds_array_ATF[1][z+10][4] + " MOM["+(2)+"]["+(z+10)+"][4] : " + ds_array_ATF[2][z+10][4] + "\n";
+ " T/B["+(1)+"]["+(z+20)+"][4] : " + ds_array_ATF[1][z+20][4] + " T/B["+(2)+"]["+(z+20)+"][4] : " + ds_array_ATF[2][z+20][4] + "\n";
}
}```
3243
2014.02.28 12:20
maleas_k:

For example ds_array_ATF[0][10][4] needs 610 Candles / Periods,

ds_array_ATF[1][10][4] needs 610 * 2 Candles / Periods,

ds_array_ATF[2][10][4] needs 610 *3 Candles / Periods.

i didnt read ur code yet
but the question begins, do u have enough history data for that
145
2014.02.28 13:10
qjol:
i didnt read ur code yet
but the question begins, do u have enough history data for that

Yes I do.

I import every month data that begins from 02/01/2001 and works perfectly in any other occasions.

That makes me very confident about my data cause I test many EAs every day.

3243
2014.02.28 13:23

i was more than happy to try helping u but i don't have the file "DonchianSwing_v2"

`iCustom(Symbol(),ds_timeframe,"DonchianSwing_v2",ds_periods,0,i);`
145
2014.02.28 14:05
qjol:

i was more than happy to try helping u but i don't have the file "DonchianSwing_v2"

oooopsssss
Files:
3243
2014.02.28 14:17

can you pinpoint the problem ?

145
2014.02.28 14:31
qjol:

can you pinpoint the problem ?

At your pic there isn't any.

Check out mine...

3243
2014.02.28 14:37

& as i asked @ the beginning before reading & testing ur code

qjol:
i didnt read ur code yet
but the question begins, do u have enough history data for that
145
2014.02.28 14:52
qjol:

& as I asked @ the beginning

At this point i have to mention that i am talking about Back Test and not Live. Because at live is ok.

Check Pic....

145
2014.03.01 11:52
Anybody...?
/