Coding help - page 178

 

Need Help to Code EA - >10% profit/month

Hi everybody, I have a very simple strategy that seems to be quite safe and give a nice yield, but is horribly tiresome by hand. That's why I would like somebody to help me code it, in order to both save the effort and be able to trade 24 hours. The strategy is really simple: place BUY STOPS and SELL STOPS 400 pips over and below the current price. The distance between lines should be able to be chosen externally, as well as the TP in pips and the Lots (starting 0.01). The SL is optional and also external. The system is left to work until an overall target profit is reached (also external). At that point, the program sells everything, cancels all pending orders and starts working again from scratch. Like I said, it is very simple. Pure mathematics, no laggards (indicators). With this strategy I have been making around 10% profit per month, depending on market conditions and money management. Over the long term is a very safe bet, but really tiring to execute manually. I use EURUSD, but if possible it would be a plus to be able to trade several pairs at the same time, just to diversify (although there is no real need for that, considering the results I have had so far).

 

is there anyone who can help me, I made ​​a code like this:

double ccia = iCCI(Symbol(),PERIOD_H1,14,PRICE_CLOSE,0);

double ccib = iCCI(Symbol(),PERIOD_H1,14,PRICE_CLOSE,1);

int Trend;

if (ccia>ccib&&ccia<=-150) Trend=0;

if (ccia=150) Trend=1;

of the code I wanted Trend value will only change when the condition. so when conditions Trend value = 0 will only be changed by the second IF. although cci value is between -150 and 150.

but why do I always get a value of 0 (zero) to the value of Trend.

 
Q_Mouze:
is there anyone who can help me, I made ​​a code like this:

double ccia = iCCI(Symbol(),PERIOD_H1,14,PRICE_CLOSE,0);

double ccib = iCCI(Symbol(),PERIOD_H1,14,PRICE_CLOSE,1);

int Trend;

if (ccia>ccib&&ccia<=-150) Trend=0;

if (ccia=150) Trend=1;

why do I always get the value 0 (zero) to the value of Trend.

Change it to this (to avoid having same value when there are no conditions met) :

double ccia = iCCI(Symbol(),PERIOD_H1,14,PRICE_CLOSE,0);

double ccib = iCCI(Symbol(),PERIOD_H1,14,PRICE_CLOSE,1);

int Trend=-1;

if (ccia>ccib&&ccia<=-150) Trend=0;

if (ccia=150) Trend=1;

At a moment CADCHF is showing a value different than the default -1

 
mladen:
Change it to this (to avoid having same value when there are no conditions met) :
double ccia = iCCI(Symbol(),PERIOD_H1,14,PRICE_CLOSE,0);

double ccib = iCCI(Symbol(),PERIOD_H1,14,PRICE_CLOSE,1);

int Trend=-1;

if (ccia>ccib&&ccia<=-150) Trend=0;

if (ccia=150) Trend=1;
At a moment CADCHF is showing a value different than the default -1

Thanks mladen, but

double CCIA = ICCI (Symbol (), PERIOD_H1, 14, PRICE_CLOSE, 0);

double CCIB = ICCI (Symbol (), PERIOD_H1, 14, PRICE_CLOSE, 1);

Trend int;

if (CCIA> CCIB CCIA && condition 1

if (CCIA = 150) Trend = 1; =====> condition 2

of the code I want if the condition 1 Trend value will be changed to 0, this condition will remain until the 2 conditions occur that will change the trend value being 1.

but that happens Trend value is always 0 only changed when in condition 2, when the value of cci passed or are under 100 value trend changed again to 0.

 
Q_Mouze:
Thanks mladen, but

double CCIA = ICCI (Symbol (), PERIOD_H1, 14, PRICE_CLOSE, 0);

double CCIB = ICCI (Symbol (), PERIOD_H1, 14, PRICE_CLOSE, 1);

Trend int;

if (CCIA> CCIB CCIA && condition 1

if (CCIA = 150) Trend = 1; =====> condition 2

of the code I want if the condition 1 Trend value will be changed to 0, this condition will remain until the 2 conditions occur that will change the trend value being 1.

but that happens Trend value is always 0 only changed when in condition 2, when the value of cci passed or are under 100 value trend changed again to 0.

Q_Mouze

To do that, one solution would be to use a static variable for trend instead

Then the code would be the following :

double ccia = iCCI(Symbol(),PERIOD_H1,14,PRICE_CLOSE,0);

double ccib = iCCI(Symbol(),PERIOD_H1,14,PRICE_CLOSE,1);

static int Trend=-1;

if (ccia>ccib&&ccia<=-150) Trend=0;

if (ccia=150) Trend=1;

In this case assignment to -1 would happen only at the first time the code is executed. After that, when new ticks come in, the Trend value would be "inherited" from a previous tick and that is what you are looking for

_____________________

If you wish to do that on historcal values (like an indicator) then you would need to declare Trend as a buffer and then you could do that for past values too

 

All the good days.

Help please.

As well will look signals from the indicator DSS Bressert + ahtf_ (FILTER)??

doing so:

//---------------------------

double aTrend[2];

aTrend[0] =iCustom(NULL, 0, "DSS Bressert + ahtf_(FILTER)", 6, 0);

aTrend[1] =iCustom(NULL, 0, "DSS Bressert + ahtf_(FILTER)", 6, 1);

if (aTrend[1] < aTrend[0]) // buy

{

Now the blue vertical line

}

if (aTrend[1] > aTrend[0]) // sell

{

Now the red vertical line

}

//---------------------------------

great difficulty in taking signal. Please help.

I'm sorry for my english ..

Thank you.

Picture and attach the indicator.

Files:
 
shtopr:
All the good days.

Help please.

As well will look signals from the indicator DSS Bressert + ahtf_ (FILTER)??

doing so:

//---------------------------

double aTrend[2];

aTrend[0] =iCustom(NULL, 0, "DSS Bressert + ahtf_(FILTER)", 6, 0);

aTrend[1] =iCustom(NULL, 0, "DSS Bressert + ahtf_(FILTER)", 6, 1);

if (aTrend[1] < aTrend[0]) // buy

{

Now the blue vertical line

}

if (aTrend[1] > aTrend[0]) // sell

{

Now the red vertical line

}

//---------------------------------

great difficulty in taking signal. Please help.

I'm sorry for my english ..

Thank you.

Picture and attach the indicator.

To see when are the signals on turn the interpolation off

Also, use buffer 6 for that. When it is 1 it is trend up, when it is -1 it is trend down and when current trend != previous trend there is a change in trend and there is a signal

 
mladen:
To see when are the signals on turn the interpolation off Also, use buffer 6 for that. When it is 1 it is trend up, when it is -1 it is trend down and when current trend != previous trend there is a change in trend and there is a signal

I did not get ((.

Please.

If this is possible ..

Show code.

Thank you.

P.S.

sorry for the translation

 
shtopr:
I did not get ((.

Please.

If this is possible ..

Show code.

Thank you.

P.S.

sorry for the translation

On your picture you are showing a 1 hour chart and daily indicator value

In the iCustom() call you are using current time frame. If you want to use daily time frame you must specify it in the iCustom call (otherwise the will never be the same)

Also, you are using an open bar call. If you plan to use multi time frame call from the EA then you should know that using an opened multi time frame bar in back-test will give invalid results (it will always "know the future") so you should not use an opened bar call if you plan to use multi time frame

 

Hi mladen,

could you kindly help to convert these two to rsi version of it separately? I try but not know how to do it, i.e. rsi of kairi, rsi of cci? thanks a lot for help.

Files:
cci.mq4  4 kb
kairi.mq4  8 kb
Reason: