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
Need help
................
Hi,
Can you please give the code for previous bar.
This can be used in the EA to limit placing the orders when the previous bar is more than certain height.
Regards,
SIDDESHSiddesh and others that can help:
The code for the previous bar is below:
//to buy
double indicatorpast = icustom(....................,1);
double indicatornow = icustom(....................,0);
if (close[1]indicatornow) OpenBUY();
if (close[1]>indicatorpast && close[0]<indicatornow) OpenSELL();
but with this satatement, the expert opens positions not only when the price cross the indicator, it opens position above the indicator too. I want that the expert open position ONLY when it cross the indicator, so i tried that:
//to buy
double indicatorpast = icustom(....................,1);
double indicatornow = icustom(....................,0);
if (close[1]<indicatorpast && close[0]==indicatornow) OpenBUY();
if (close[1]>indicatorpast && close[0]==indicatornow) OpenSELL();
But this statement it is not performing.
Do you know what is happen? Because i think there arent errors in the statement.
The question is why is not opening at the exact point of cross when close[0]==Indicatornow? If the function would be with ==, we will prevent the open of orders above the point of crooss between the indicator and the close of the present bar but is not funtioning with this type of relationship between the variables.
People that can help:
The code for the previous bar is below:
//to buy
double indicatorpast = icustom(....................,1);
double indicatornow = icustom(....................,0);
if (close[1]indicatornow) OpenBUY();
if (close[1]>indicatorpast && close[0]<indicatornow) OpenSELL();
but with this satatement, the expert opens positions not only when the price cross the indicator, it opens position above the indicator too. I want that the expert open position ONLY when it cross the indicator, so i tried that:
//to buy
double indicatorpast = icustom(....................,1);
double indicatornow = icustom(....................,0);
if (close[1]<indicatorpast && close[0]==indicatornow) OpenBUY();
if (close[1]>indicatorpast && close[0]==indicatornow) OpenSELL();
But this statement it is not performing.
Do you know what is happen? Because i think there arent errors in the statement.
The question is why is not opening at the exact point of cross when close[0]==Indicatornow? If the function would be with ==, we will prevent the open of orders above the point of crooss between the indicator and the close of the present bar but is not funtioning with this type of relationship between the variables.
Do you have experimented the same problem? Abyone knows how resolve it?
Thanks, again.
People that can help:
The code for the previous bar is below:
//to buy
double indicatorpast = icustom(....................,1);
double indicatornow = icustom(....................,0);
if (close[1]indicatornow) OpenBUY();
if (close[1]>indicatorpast && close[0]<indicatornow) OpenSELL();
but with this satatement, the expert opens positions not only when the price cross the indicator, it opens position above the indicator too. I want that the expert open position ONLY when it cross the indicator, so i tried that:
//to buy
double indicatorpast = icustom(....................,1);
double indicatornow = icustom(....................,0);
if (close[1]<indicatorpast && close[0]==indicatornow) OpenBUY();
if (close[1]>indicatorpast && close[0]==indicatornow) OpenSELL();
But this statement it is not performing.
Do you know what is happen? Because i think there arent errors in the statement.
The question is why is not opening at the exact point of cross when close[0]==Indicatornow? If the function would be with ==, we will prevent the open of orders above the point of crooss between the indicator and the close of the present bar but is not funtioning with this type of relationship between the variables.
Do you have experimented the same problem? Abyone knows how resolve it?
Thanks, again.Because you are looking for an exact match between a returned 8 digit floating point value and price - they will almost never be equal with resolutions like that. Just check for a greater-than or less-than condition.
swicthing software
hi boys, I would need to turn this indicator or the trading relative sistem into language mql because this functions on metatrader 4. Am I changing broker and software, is someone able' to help me?
{Calculation of Expanded Regression Moving Average}
{BEGINNING}
{"-HShift" - BARS FORWARDS}
DataBars:= Ref(Price,- HShift);
e1:= Mov(DataBars,PeriodMA,TypeMA);
e2:= Mov(e1,PeriodMA,TypeMA);
e3:= Mov(e2,PeriodMA,TypeMA);
e4:= Mov(e3,PeriodMA,TypeMA);
e5:= Mov(e4,PeriodMA,TypeMA);
e6:= Mov(e5,PeriodMA,TypeMA);
c1:= -b*b*b;
c2:= 3*b*b+3*b*b*b;
c3:= -6*b*b-3*b-3*b*b*b;
c4:= 1+3*b+b*b*b+3*b*b;
MV:= c1*e6+c2*e5+c3*e4+c4*e3;
{Calculation of Time of Life MV
for elimination of distortion of initial values}
{T3 Moving Average}
e1:= Mov(Pr,PeriodMA1,TypeMA1);
e2:= Mov(e1,PeriodMA1,TypeMA1);
e3:= Mov(e2,PeriodMA1,TypeMA1);
e4:= Mov(e3,PeriodMA1,TypeMA1);
e5:= Mov(e4,PeriodMA1,TypeMA1);
e6:= Mov(e5,PeriodMA1,TypeMA1);
c1:= -b1*b1*b1;
c2:= 3*b1*b1+3*b1*b1*b1;
c3:= -6*b1*b1-3*b1-3*b1*b1*b1;
c4:= 1+3*b1+b1*b1*b1+3*b1*b1;
MA1:= c1*e6+c2*e5+c3*e4+c4*e3;
{Trend Up and Down}
UpTrend:=Mv>=MA1;
DownTrend:=MA1>=Mv;
{Signal Long and Short}
Long:= cross(Mv,MA1) and Mv>=MA1;
Short:= cross(MA1,Mv) and MA1>=Mv;
{OpenBuy and CloseBuy}
OpenBuy:= cross(Mv,MA1) and Mv>=MA1;
CloseBuy:= cross(MA1,Mv) and MA1>=Mv;
{OpenSell and CloseSell}
OpenSell:= cross(MA1,Mv) and MA1>=Mv;
CloseSell:= cross(Mv,MA1) and Mv>=MA1;
hi boys, I would need to turn this indicator or the trading relative sistem into language mql because this functions on metatrader 4. Am I changing broker and software, is someone able' to help me?
{T3 Moving Average}
e1:= Mov(Pr,PeriodMA1,TypeMA1);
e2:= Mov(e1,PeriodMA1,TypeMA1);
e3:= Mov(e2,PeriodMA1,TypeMA1);
e4:= Mov(e3,PeriodMA1,TypeMA1);
e5:= Mov(e4,PeriodMA1,TypeMA1);
e6:= Mov(e5,PeriodMA1,TypeMA1);
c1:= -b1*b1*b1;
c2:= 3*b1*b1+3*b1*b1*b1;
c3:= -6*b1*b1-3*b1-3*b1*b1*b1;
c4:= 1+3*b1+b1*b1*b1+3*b1*b1;
MA1:= c1*e6+c2*e5+c3*e4+c4*e3;
All this codes are similar, you could start by looking the T3 code
Global, put this before init()
In the order placement and/or order close stuff, wrap it in this:
{
if blah blah blah, gimme pips // not actual functions but you get the idea
if blah blah blah, close orders // um
}Common function outside main loop:
[CODE]//--- returns true if current bar just formed
bool NewBar()
{
if(PreviousBar<Time[0])
{
PreviousBar = Time[0];
return(true);
}
else
{
return(false);
}
return(false);
}Thanks nitty1 for the help. I'll try it.
Also thanks to waltini & devil2000. I should be able to figure it out now.
Account code for running on Demo freely
Hi:
Can someone tell me what code could be inserted to allow an EA that has account security code in it to also run freely on a demo account so users can test it before going live?
Is this even possible?
Thanks
Hi:
Can someone tell me what code could be inserted to allow an EA that has account security code in it to also run freely on a demo account so users can test it before going live?
Is this even possible?
ThanksFrom the metaeditor:
Returns TRUE if the expert runs on a demo account, otherwise returns FALSE.
Coding "Trend Condition" with StepMA
Buy condition:
StepMA (with Colour Mode: 2) is "long"
Stochastic crosses 20 from below to above
Sell condition:
StepMA (with Colour Mode: 2) is "short"
Stochastic crosses 80 from above to below
double StochCurrent = iStochastic(NULL, 0, 21, 3, 8, MODE_SMA, 0, MODE_MAIN, Bar + 0);
double StochPrevious = iStochastic(NULL, 0, 21, 3, 8, MODE_SMA, 0, MODE_MAIN, Bar + 1);
double TrendLong = iCustom(NULL, 0, "stepma_v7ea", 1, 1.0, 0, 0, 0, 0.0, false, 2, 0, 1, Bar + 0);
double TrendShort = iCustom(NULL, 0, "stepma_v7ea", 1, 1.0, 0, 0, 0, 0.0, false, 2, 0, 2, Bar + 0);
Buy if:
TrendLong && StochCurrent > 20 && StochPrevious < 20
Sell if:
TrendShort && StochCurrent 80
Can someone help me with the code of the "Trend Condition" in the above example, it does not work. I tried to call the buffer 1 and buffer 2 for long and short mode but I don't understand the code of this indicator. Thank you in advance!