Universal code for Short and Long only - page 2

 
mladen:
The things you are asking are very similar to questions that lead to creation of that course. Hence the link : since already someone was talking about very similar things you are asking it is always good to read what is already told and known on some subject all the best

Ok,thanks!

I will read the post and see if I can figure something out.

Still interested in somebody that could do it for me though.

//Thomas

 
mrtools:
OneandOnly666, its hard to make a universal code since all EA's have different buy and sell routines, but like Mladen said can simply enter your buy and sell conditions into the code and that should do it. So for example for bollinger bands can do something like

double upBands = iBands(NULL,PERIOD_H4,Length,Deviation,0,PRICE_CLOSE,MODE_UPPER,shift);

double dnBands = iBands(NULL,PERIOD_H4,Length,Deviation,0,PRICE_CLOSE,MODE_LOWER,shift);

Then in your buy and sell routine

if(Close[shift] > upBand && rest of your buy conditions);

if(Close[shift] < dnBand && rest of your sell conditions);

For closing would simply be a matter of using the bands again for your closing routine.

The problem I see is that it should still make sell orders after going under the bottom line and after that going over it again. Because the EA should only change to buy orders after hitting the upper line. In between it should still be making buy orders or sell orders according to the last crossover. All buy and sell orders are determined by other indicator values, not the BB line crossover. The BB lines only give direction if the orders should be buy or sell.

If you take the indicator TOPTREND, it shows a red line if the bottom line of BB has been crossed and a blue line if the top line of BB has been crossed.

Making that indicator determine if the EA is allowed to make buy or sell orders is what Im thinking of.

The EA have SL and TP so the BB lines should not close the orders. Unless it goes from top line to bottom line or bottom line to top line, then it should close all open possisions and change direction of the Buy/Sell allowed.

Do you understand what Im looking for?

 
mrtools:
Thomas, its hard to make a universal code since all EA's have different buy and sell routines, but like Mladen said can simply enter your buy and sell conditions into the code and that should do it. So for example for bollinger bands can do something like

double upBands = iBands(NULL,PERIOD_H4,Length,Deviation,0,PRICE_CLOSE,MODE_UPPER,shift);

double dnBands = iBands(NULL,PERIOD_H4,Length,Deviation,0,PRICE_CLOSE,MODE_LOWER,shift);

Then in your buy and sell routine

if(Close[shift] > upBand && rest of your buy conditions);

if(Close[shift] < dnBand && rest of your sell conditions);

For closing would simply be a matter of using the bands again for your closing routine.

YES!

I managed to solve the problem thanks to you mrtools.

The answer was in the code of the TOPTREND indicator Im using, and of course the directions you gave me.

But now to other problems I got!

The EA follows the BB trend in the 4H chart, but when trading it waits 4 hours to change direction after it has closed over the bottom or the upper line.

Is there any way to solve this?

Maybe to have the 4H BB indicator react to the 1H movement instead. In that case it will only wait 1 hour after closing over a line.

I know I can change the BB to 1 Hour in the EA code, but then it will not be according to the 4 H chart movement as I want. Just want it to react faster to the crossover and closing.

 
OneandOnly666:
YES!

I managed to solve the problem thanks to you mrtools.

The answer was in the code of the TOPTREND indicator Im using, and of course the directions you gave me.

But now to other problems I got!

The EA follows the BB trend in the 4H chart, but when trading it waits 4 hours to change direction after it has closed over the bottom or the upper line.

Is there any way to solve this?

Maybe to have the 4H BB indicator react to the 1H movement instead. In that case it will only wait 1 hour after closing over a line.

I know I can change the BB to 1 Hour in the EA code, but then it will not be according to the 4 H chart movement as I want. Just want it to react faster to the crossover and closing.

Maybe in your closing routine use the bollinger bands with an adjustable timeframe .

Reason: