Universal code for Short and Long only

 

Hi!

Is there any universal code for Buy orders only and Sell orders only according to the Bollinger Band upper and lower line?

When code is implemented to an EA it should give an 4110 and 4111 error code. Even if the EA would like to make a sell order in the Long mode it should not be able to do that and give the error code 4111 and in the Short mode a Buy order should give the error code 4110.

One can easily make the EA only go short or long by manually shosing it in the external settings of the EA when you put it on a live chart, but then it would not be automatic and you would have to sit by the computer all the time.

#The BB should get its variables only from the H4 period even if the EA is on a different time period.

#When the price goes under the bottom line of BB and closes it should start Sell orders only, but it will still allow the EA to only do short posisions until the price goes over the upper line of BB and closes. There it should change the setting to Long mode. And vice vers the other way around.

#When it goes from Short mode to Long mode or from Long mode into Short mode it should close all open orders(True or False option)

Is there anything like this or can it be done?

//OneandOnly666

 
OneandOnly666:
Hi!

Is there any universal code for Buy orders only and Sell orders only according to the Bollinger Band upper and lower line?

When code is implemented to an EA it should give an 4110 and 4111 error code. Even if the EA would like to make a sell order in the Long mode it should not be able to do that and give the error code 4111 and in the Short mode a Buy order should give the error code 4110.

One can easily make the EA only go short or long by manually shosing it in the external settings of the EA when you put it on a live chart, but then it would not be automatic and you would have to sit by the computer all the time.

#The BB should get its variables only from the H4 period even if the EA is on a different time period.

#When the price goes under the bottom line of BB and closes it should start Sell orders only, but it will still allow the EA to only do short posisions until the price goes over the upper line of BB and closes. There it should change the setting to Long mode. And vice vers the other way around.

#When it goes from Short mode to Long mode or from Long mode into Short mode it should close all open orders(True or False option)

Is there anything like this or can it be done?

//OneandOnly666

Errors are raised from terminal (and broker). You can not replace error handling routine in mql with your custom error handling routine

 
mladen:
Errors are raised from terminal (and broker). You can not replace error handling routine in mql with your custom error handling routine

Ok! So if you exclude the error codes, can it be done then? Had the error codes in the description just to make my self clearer about the universal code description.

 
OneandOnly666:
Ok! So if you exclude the error codes, can it be done then? Had the error codes in the description just to make my self clearer about the universal code description.

In that case it is a simple case of putting the entry and exit conditions in the EA correctly. Pay attention to the conditions and you can get it correctly

 
mladen:
In that case it is a simple case of putting the entry and exit conditions in the EA correctly. Pay attention to the conditions and you can get it correctly

Im just interested in getting an universal code that I can implement in different EAs, so I dont have to recode everyone. The code should still stop the EA from making Buy orders in the Short mode and Sell orders in the Long mode. Just as the settings in the Terminal, short only, long only.

 
OneandOnly666:
Im just interested in getting an universal code that I can implement in different EAs, so I dont have to recode everyone. The code should still stop the EA from making Buy orders in the Short mode and Sell orders in the Long mode. Just as the settings in the Terminal, short only, long only.

There is no such thing as universal code

Each and every conditions checking code is highly specific to the strategy

 
mladen:
There is no such thing as universal code Each and every conditions checking code is highly specific to the strategy

So I cant put the code in the end of the EA code and the extern int in the beginning to over ride the settings in the EA? As a is trade allowed code?

 
OneandOnly666:
So I cant put the code in the end of the EA code and the extern int in the beginning to over ride the settings in the EA? As a is trade allowed code?

Maybe a good starting point to get some clarifications to what you are looking for would be this post : https://www.mql5.com/en/forum/172969/page2

 
mladen:
Maybe a good starting point to get some clarifications to what you are looking for would be this post : https://www.mql5.com/en/forum/172969/page2

I understand your point but I just asked if somebody could help me create it not get a course on how it is done!

Thanks for your help anyway.

Maybe there is somebody else that is willing to help me?

 
OneandOnly666:
I understand your point but I just asked if somebody could help me create it not get a course on how it is done!

Thanks for your help anyway.

Maybe there is somebody else that is willing to help me?

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

 
OneandOnly666:
I understand your point but I just asked if somebody could help me create it not get a course on how it is done!

Thanks for your help anyway.

Maybe there is somebody else that is willing to help me?

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.