what is wrong with this code?

 

Hi guys,

I want you to look at my code,i just finished working on it,the code is attached to this mail,

ignore the stochastics and ema indicators,

my new strategy is based on macd on bar 1,and cci 50 on current forming bar(bar 0)

i want it to open buy if cci 50 is greater than 0,on the current bar, and macd value is greater than macd signal on bar 1,

reverse is the case for sell position,

What i want you to do is to check out my buy and sell conditons based on what i explained above,if it is correct or not, and also my trailing stop condition,if is well written.

Any advise will be highly appreciated.

Thanks.

Files:
 
11011980 wrote >>

Hi guys,

I want you to look at my code,i just finished working on it,the code is attached to this mail,

ignore the stochastics and ema indicators,

my new strategy is based on macd on bar 1,and cci 50 on current forming bar(bar 0)

i want it to open buy if cci 50 is greater than 0,on the current bar, and macd value is greater than macd signal on bar 1,

reverse is the case for sell position,

What i want you to do is to check out my buy and sell conditons based on what i explained above,if it is correct or not, and also my trailing stop condition,if is well written.

Any advise will be highly appreciated.

Thanks.

Error in Stochastic calculation:

Current: iStochastic(NULL, 0, 5, 3, 3, MODE_MAIN, 1, MODE_SMA, 1);

Correct:iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, PRICE_CLOSE, MODE_SIGNAL, 1);

Use the pre-defined values to make your code easier to read:

PRICE_CLOSE 0 Close price.
PRICE_OPEN 1 Open price.
PRICE_HIGH 2 High price.
PRICE_LOW 3 Low price.
PRICE_MEDIAN 4 Median price, (high+low)/2.
PRICE_TYPICAL 5 Typical price, (high+low+close)/3.
PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.

Loop backwards when closing trades or open orders:

Old: for(cnt = 0; cnt < OrdersTotal(); cnt++)

New: for(cnt=OrdersTotal()-1;cnt >=0; cnt--)

 
wadem000 wrote >>

Error in Stochastic calculation:

Current: iStochastic(NULL, 0, 5, 3, 3, MODE_MAIN, 1, MODE_SMA, 1);

Correct:iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, PRICE_CLOSE, MODE_SIGNAL, 1);

Use the pre-defined values to make your code easier to read:

PRICE_CLOSE 0 Close price.
PRICE_OPEN 1 Open price.
PRICE_HIGH 2 High price.
PRICE_LOW 3 Low price.
PRICE_MEDIAN 4 Median price, (high+low)/2.
PRICE_TYPICAL 5 Typical price, (high+low+close)/3.
PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.

Loop backwards when closing trades or open orders:

Old: for(cnt = 0; cnt < OrdersTotal(); cnt++)

New: for(cnt=OrdersTotal()-1;cnt >=0; cnt--)

thanks a lot,

does any body have another suggestion?

expecting your comments.

 

Hello pros,

I am still expecting you to criticize my code.

Any error detected will be highly appreciated.Thanks.

Reason: