One thing you may want to change is
if ( ordtotal < 0 )
from the chunk of code you posted you could see that the ordtotal will never get below 0, therefore the lines inside the if block will never get executed...
Also take a look at this line please:
while ( b < 0 )
it will never get executed unless b<0, however I dont see anywhere in the code you initialize b with a value less then 0, so the lines inside the loop will never get executed i.e. a trade wont be opened...the same is true for the sell order. ..
One thing you may want to change is
if ( ordtotal < 0 )
from the chunk of code you posted you could see that the ordtotal will never get below 0, therefore the lines inside the if block will never get executed...
Also take a look at this line please:
while ( b < 0 )
it will never get executed unless b<0, however I dont see anywhere in the code you initialize b with a value less then 0, so the lines inside the loop will never get executed i.e. a trade wont be opened...the same is true for the sell order. ..
Thanks a lot
you are welcome :)
you could always contact me at automatedfx@gmail.com if you would like to discuss it further...
thank you
Automated
Thank you
I have started coding my EA. I am by no means a decent coder for MQL b/c I've never
seen C++/C.
My settings are as follows: There are two indicators: IND1 [indicator] and IND2. IND1 has 1 line, IND2 has 2 lines. Lines = lines on a chart. For instance, Bollinger bands indicator has 3 lines, but isn't used
in this example. Both INDs have their 0.0 level shown on the chart; although, only
IND1's is used.
My logic is as follows: when IND1 crosses its 0 level the first time and goes into negative, send the SELL order. Wait for the IND2 to have its line1 cross line2 and send the BUY order, automatically closing the SELL submitted by IND1. If there's
a 2nd/3rd/etc 0 level crossing by IND1 into either positive or negative before the BUY, disregard that crossing, do nothing and proceed w/ that first SELL
order[otherwise there will be a 2nd/3rd/etc SELL order w/ no corresponding BUY
order]. When the BUY order is executed by the IND2 [IND2's line1 has crossed line2], wait for the following crossing of 0 [into the negative] by IND1 and send the
SELL order, automatically closing the BUY order submitted by IND2.
I'm going to include my coding. Please take a look at it, b/c it isn't graphing
anything and isn't working. Does everything make sense?
Here's the code itself:
#property copyright "Copyright © 2008 BDHT" #define MAGIC 689 //do not take into consideration //the names of the indicators //they're fabricated extern double lots = 0.1; // Lots extern double TP = 140; // Take Profit extern double SL = 30; // Stop Loss static int prevtime = 0; static int res = 0; double IND2_line1, IND2_line2, IND1, IND1_prev, IND2_line1_prev; int init() { IND2_line1 = iIND2_line1(NULL,0,0,MODE_MAIN,0); IND2_line2 = iIND2_line2(NULL,0,0,MODE_SIGNAL,0); IND1= iCustom(NULL, 0, "IND1", 0, 0, 0); IND1_prev= iCustom(NULL,0, "IND1", 0, 0, 1); IND2_line1_prev = iCustom(NULL, 0, "IND2", 0, 0, 1); return(0); } int deinit() { return(0); } int start() { //Make sure there are no open orders; if yes - stop if (OrdersTotal() > 0) return (0); if (IND1< 0 && IND1 < IND1_prev && IND1_prev > 70 && IND2_line1 < 0 && IND2_line2 < 0) { // 70 may be 10; simply means that the IND1_prev was greater than 0 res=OrderSend(Symbol(),OP_SELL,lots,Bid,3,Bid+SL*Point,Ask+TP*Point,"My EA",MAGIC,0,Blue); return(0); } if (IND2_line1 > IND2_line2 && IND2_line1_prev < IND2_line1) { res=OrderSend(Symbol(),OP_BUY,lots,Ask,3,Ask+SL*Point,Bid+TP*Point,"My EA",MAGIC,0,Blue); return(0); }It doesn't graph anything either... I know there has to be something wrong, but what is it?
There are many problems with your code.
One problem, code within init() is only executed one time.
Code withing start() executes every tick
Code within init() executes once per intitialization/start/restart of the EA
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This code's purpose is to check if there's any active order opened by this EA. If none, it will open 2 orders, buy and sell. I haven't test it on real market because it's sunday now, but from backtester, there's no trade appear. What's wrong with these codes?
Thank you