Good afternoon )))) I wrote my first EA, but it turned out to be problematic))))))) This EA puts only sell orders even though the buy conditions are very simple and the EA seems not to see them.
if (ZZ2< pp1 ) { OpenPosition ("", OP_BUY, Lots_New,SLB,TPB, mn);}
if (pp1 < ZZ2) {OpenPosition("", OP_SELL, Lots_New, SLS,TPS, mn);}
If someone takes a look at the code, I'd be very grateful)))
Strange, in theory it shouldn't see the snappy SELL because you're using pa instead of pb.
double TPS= NormalizeDouble(pa-tp*po, Digits);// calculate Tp for sell double SLS= NormalizeDouble(pa+sl*po, Digits);// calculate SL for sell
int ic=IndicatorCounted();
if(Bars-ic-1>1) {ic=reinit();}
int limit=Bars-ic-1; //BarsPrev=Bars; // кол-во пересчетовif(History!=0 && limit>History) limit=History-1; // кол-во пересчетов по историиfor(int i=limit; i>=1; i--) // цикл по непосчитанным и предпоследнему барам
{
int n;
int iShift=i+Shift;
if (i==0)
Input[i]=iClose(Symb, Period(), iShift);
else
Input[i]=(iHigh(Symb, Period(), iShift)+iLow(Symb, Period(), iShift))/2;
}
As I understand it, it counts all bars except the last one.
Can you tell me how to make it recalculate the last bar at i=0 (there is already a condition for this in the loop)?
I have this question. Is the serial number of trades in the terminal assigned permanently or does it change? For example, if I opened three trades with numbers 0 - 1 - 2 and closed trade number 1, then trade numbers 0 and 2 will remain or will become 0 and 1?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Good afternoon )))) I wrote my first EA, but it turned out to be problematic))))))) This EA puts only sell orders even though the buy conditions are very simple and the EA seems not to see them.
if (ZZ2< pp1 ) { OpenPosition ("", OP_BUY, Lots_New,SLB,TPB, mn);}
if (pp1 < ZZ2) {OpenPosition("", OP_SELL, Lots_New, SLS,TPS, mn);}
If someone takes a look at the code, I'd be very grateful)))
Strange, in theory it shouldn't see the snappy SELL because you're using pa instead of pb.
double TPS= NormalizeDouble(pa-tp*po, Digits);// calculate Tp for sell
double SLS= NormalizeDouble(pa+sl*po, Digits);// calculate SL for sell
There is such a recalculation algorithm:
As I understand it, it counts all bars except the last one.
Can you tell me how to make it recalculate the last bar at i=0 (there is already a condition for this in the loop)?
Thanks so much for the answers)))) I replaced iClose with Close [0] and it worked out....though strangely...))))) thanks again)))
There is such a recalculation algorithm:
As I understand it, it counts all bars except the last one.
Can you tell me how to make it recalculate the last bar at i=0 (there is already a condition for this in the loop)?
no, you're writing >= 1 (greater than or equal to the 1st bar, i.e., you don't get to 0... change the condition to >=0
SZ
What's this about?
int iShift=i+Shift;No, you write >= 1 (Greater than or equal to 1 bar, i.e. you don't get to 0... change the condition to >=0
SZ
What's that for?
Right, totally forgot about my "experiments". Fixed 0 to 1 a while ago and it's still there. Thank you!
iShift is a shift, set in extern.
Right, forgot all about my "experiments". I changed it from 0 to 1 a while ago and it's still there. Thank you!
iShift is a shift, set in the extern.
yeah... but you write that you need to watch the 0 bar...
then remove
your shifter from there :) - put 0...
Please help. Can the conditions below be met???
We need to make so that if the current price crosses the MA, then the algorithm in { } is triggered: