Metaquote software corp, pls help me , i'm getting frustrated

To add comments, please log in or register
Asiwaju Williams Olayemi Mim
137
Asiwaju Williams Olayemi Mim  

Hello Metaquote,

i got attracted to mql4 platform because of the automated trading opportunity, but i am having problem coding my strategy to a robot,

my strategy is to buy when the stochastics are below 80,and sell when they are greater than 20, but all my efforts have proved abortive,

i have used different variables,but still the ea still buys above 80 and sells below 20, it respects all the other signals except the overbought and oversold signals, and i don't have any idea on what next to do, kindly

look into it and help me out. the code has been attached .

thanks.

Files:
William Roeder
22318
William Roeder  
buy when the stochastics are below 80,and sell when they are greater than 20
if(traden==1 && signal==1 && OrderAngaben[2]<=0  && STOCH1<=OVB && stocha1<=OVB && STOCH1>STOCH2  && sar<Low[0] && macdm>macds && ADXM>ADXS) 
CheckForOpen(OP_BUY, Lots, "EA", Magicnumber);
if(traden==1 && signal==2 && OrderAngaben[2]<=0  && STOCH1>=OVS && stocha1>=OVS && STOCH1<STOCH2 && sar>High[0] && macdm<macds && ADXM<ADXS) 
CheckForOpen(OP_SELL, Lots, "EA", Magicnumber);
And what about the case where they are between 20-80. Your code doesn't check, therefore as written is buy below 20 else sell.
Asiwaju Williams Olayemi Mim
137
Asiwaju Williams Olayemi Mim  

thanks for your response to my post, but my problem is that the EA places a Buy order both when the stochastics are above 80 and below 80 as long as other conditions(signals) are true, and it also place a Sell order both when the stochastics are below and above 20,as long as all the other conditions are true,

meanwhile i only want it to place a Buy order when the stochastics are below 80 not above, and place a Sell order when stochastics are above 20 not below.

please, if you know the solution to this problem kindly modify my code and upload it.

thanks.

Paul
327
Paul  
jmorgan:

thanks for your response to my post, but my problem is that the EA places a Buy order both when the stochastics are above 80 and below 80 as long as other conditions(signals) are true, and it also place a Sell order both when the stochastics are below and above 20,as long as all the other conditions are true,

meanwhile i only want it to place a Buy order when the stochastics are below 80 not above, and place a Sell order when stochastics are above 20 not below.

please, if you know the solution to this problem kindly modify my code and upload it.

thanks.

Paul
327
Paul  
forestmyopia:

You stated, "i only want it to place a Buy order when the stochastics are below 80 not above, and place a Sell order when stochastics are above 20". I think there is a flaw in your logic. What you want the ea to do is this: Buy when the the base or signal line crosses up above the 20 line. Sell when the base or signal line crosses down below the 80 line. This implies that your ea must first test the following conditions: If the base or signal line is already above the 80 line, check to see if it crosses down below the 80 line. If the base or signal line is not above the 80 line, then your ea doesn't need to check if a sell condition is triggered. If the base or signal line is below the 20 line, check to see if it crosses up above the 20 line. If the base or signal line is not below the 20 line, then your ea doesn't need to check if a buy condition is triggered. One cheap and dirty way that I solve problems like this is I create 2 ea's. One that only enters long positions and the other only takes short positions. If you want your ea's to continously trade long and short positions, depending on your stochastic crosses, then you place the long trade ea on one chart of a given currency pair and you place the short trade ea on a seperate chart with the same given currency pair, each position with its own unique magic number. Then the long ea only trades when the signal crosses up from below 20. The short ea only trades when the signal crosses down from above 80. I do it this way because I am lazy and it makes coding easier for me.
Asiwaju Williams Olayemi Mim
137
Asiwaju Williams Olayemi Mim  
no,what i mean is this, i would like the EA to Buy when stochastics main is reading any value between 0 and 80, and it should Sell when the stochatics is reading any value between 20 and 100. hope you understand me now?
Paul
327
Paul  
jmorgan:
no,what i mean is this, i would like the EA to Buy when stochastics main is reading any value between 0 and 80, and it should Sell when the stochatics is reading any value between 20 and 100. hope you understand me now?


Okay, try this Veitch diagram or K-map approach. Make a drawing on a blank piece of paper as follows: Near the top of the paper draw a horizontal line and label it 100. Just a little below that, draw a second horizontal line and label it 80. Then move down and draw the 20 horizontal line and finally, the 0 horizontal line. Now, lets graphically represent what you want your ea to do. You want the ea to buy when the k or main signal is between the 0 and 80 horizontal lines. So, fill in the space between the 0 and 80 horizontal lines with anything you want, lets say cross-hatching lines that slant down to the right. Next, you want the ea to sell when the main is between the 20 and 100 horizontal lines. Fill in the space between these two lines with cross-hatching that slants down to the left. Stand back and look at your graphical masterpiece. What do you see? What does the diagram tell you? You should see that your right and left cross-hatching lines intersect between the 20 and 80 horizontal lines. It is within this region that you want your ea to simultaneously buy and sell! You will have a very confused ea if you want that.

Asiwaju Williams Olayemi Mim
137
Asiwaju Williams Olayemi Mim  

Hello guys,

i am still looking for someone to help me fix this issue, so that the EA will stop placing buy order within Stochastic overbought area(above 80), and also not place a sell order within oversold area(below 20).

please help me, God bless you all.

To add comments, please log in or register