
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
when you start your Metatrader the EA has to find out if there is a trade open
I do only the loop counting down for checking trades if there's a trade
If I set it at the beginning on one and OrdersTotal() >0 then I make it checking trades if(.......> || .......> ){do the loop....
are you sure u gave me the code that gave u the results shown on above? i tested it on 1440 (1 DAY ) period and no trades were executed. however when i change it to 1M many trades were executed
OK here goes.....I will attempt to help here if I can.
This Ma_Shift question is one that I had for sometime and was never able to get a clear answer on.
If you will notice in your code you are using a shift of 8 on your Moving averages.... what does this mean?
This makes a 3 pip difference in the value on this 08:00 candle as shown here in the data window.
Which brings us to the question; What is the "Shift" setting at the end for?
Well as you mouse over your chart with the data window open and move from candle to candle
you will see the numbers change for the 5 SMA as you go from candle to candle...
That is what that last SHIFT value is about... keeping in mind that the current candle that is being
drawn is candle zero... the last completed candle is candle 1 so if there are 1000 total candles on
your chart they are numbered backwards from 999 on the left edge of your chart to 0 where you
are currently. So if you want to know what the value of the 5 SMA was 5 completed candles ago
you put a 5 in that last spot... of course as time progresses... candle 5 will change to the next candle.
Now as was mentioned .. if you are always geting the value of candle 0.. then that value is constanly
changing with price. So you may take a signal and then the indicator repaints on you .. but if you are
always asking for the info from candle 1 it is done and will not change....
I hope this helps...
I've redone everything and fixed the loop,slippage, fixed the moving average and RSI values, made sure that every opened positions are closed before start new position. but when i backtest it, nothing happens, no buy/sell were executed... whats the problem with it again?
the init() function only runs at start up and not on every tick like the start() function.. you will need to put the moving averages back into the start function instead of in the init() only for it to work so that it keeps getting fresh numbers...
Reworked
Add in a feature where the EA will check if there are any pending orders before deciding to open a new position. If theres a pending or opened order then it wont attempt to open anymore.at
i see that everyone uses a loop to check if there is an open position before buying, i cant see the logic of that. as long as OrdersTotal is > 0 there are opened orders and my EA will not seek to open more positions.
fixed the decreasing loop.
This time it gives me OrderClose error 138 which cannot be solved by adding refreshrates()
and i still end up losing money which i shouldnt be.
i cant think of anything else to fix...
Reworked
Add in a feature where the EA will check if there are any pending orders before deciding to open a new position. If theres a pending or opened order then it wont attempt to open anymore.at
i see that everyone uses a loop to check if there is an open position before buying, i cant see the logic of that. as long as OrdersTotal is > 0 there are opened orders and my EA will not seek to open more positions.
fixed the decreasing loop.
This time it gives me OrderClose error 138 which cannot be solved by adding refreshrates()
and i still end up losing money which i shouldnt be.
i cant think of anything else to fix...
Why did you place the logic for opening a buy before you check the trades your EA have open on your account ????
What will happen now ???? with the programming you have so far ???
Assume you have an account running with your EA. You open manually a trade for GBPUSD.
how many trades is OrdersTotal() with that trade ???
Your code.... for BUY
what is this doing now ??? and for what reason is it doing so ???
Why did you place the logic for opening a buy before you check the trades your EA have open on your account ????
What will happen now ???? with the programming you have so far ???
Assume you have an account running with your EA. You open manually a trade for GBPUSD.
how many trades is OrdersTotal() with that trade ???
Your code.... for BUY
what is this doing now ??? and for what reason is it doing so ???
buy only if the conditions of buy has been met and if no positions has been opened
buy only if the conditions of buy has been met and if no positions has been opened
Assume you have an account running with your EA. You open manually a trade for GBPUSD.
will the condition be true
would you please let me have a look at your codes?
i wnt to know why i failed and how to get it right.
.
Your message to me I can give you the full code directly.....
That won't be for free. For that you have to use Jobs section and pay to get it...
You will get it then there
.
Another way is read your topics well
We are helping you here to learn how to program it yourself. That is free Help
We show you your errors and help you in the direction how to solve.
I show the code I have the moment you have learned a way to write it ....
No need to pay then and you can that moment compare it with the code you made here with help of this forum
....
my last question here is still not answered
Assume you have an account running with your EA. You open manually a trade for GBPUSD.
will the condition be true
.
. In other topic OrderClose error 138
you have been helped there very well (RaptorUK and WHRoeder thanks for explanation there I think very well done)
.
Another question I have for you is
Why did you change the Timeframe in this calculating Moving Average
This is not the same as I gave,
It is not calculating the right value on other chart Daily
.
So take time learning and practise and read carefully the help you get here on this forum
or you pay someone to program for you at a site like Jobs
would you please let me have a look at your codes?
i wnt to know why i failed and how to get it right.
.
Your message to me I can give you the full code directly.....
That won't be for free. For that you have to use Jobs section and pay to get it...
You will get it then there
.
Another way is read your topics well
We are helping you here to learn how to program it yourself. That is free Help
We show you your errors and help you in the direction how to solve.
I show the code I have the moment you have learned a way to write it ....
No need to pay then and you can that moment compare it with the code you made here with help of this forum
....
my last question here is still not answered
Assume you have an account running with your EA. You open manually a trade for GBPUSD.
will the condition be true
.
. In other topic OrderClose error 138
you have been helped there very well (RaptorUK and WHRoeder thanks for explanation there I think very well done)
.
Another question I have for you is
Why did you change the Timeframe in this calculating Moving Average
This is not the same as I gave,
It is not calculating the right value on other chart Daily
.
So take time learning and practise and read carefully the help you get here on this forum
or you pay someone to program for you at a site like Jobs
is OrdersTotal() suppose to reveal the total amount of pending orders and market orders regardless they were opened through EA or manual?
I was thinking in this way. My EA will always check if there are open orders and if there are, it wont open anymore orders and it will only open new orders when there are no open orders hence
I think its working fine because my results section shows me the order sequence 1,1,2,2,3,3,4,4 which means an order is closed before new order is opened.
the variables for moving average and RSI changed due to testing reasons. I was experimenting it on different time frame/period but didnt change it back when i post it here.
and the most bizarre of all , my code will ONLY execute buy order. it has never executed not even one...sell order. thats just weird,
in a nutshell, the problems i am still facing now.
1. it only executes buy but never execute sell despite the fact i have coded the sell
2. still making negative profit which i am confidence this strategy isnt suppose to.