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
Problem in NormalizeDouble
I need 5th digit after decimal from price quote, it will display when using DoubleToStr function. I want to store a vlue get from object and use it for further calcullation i.e "price2"
could anyone please help me to solve this problem
Help With labels
could some one guide me on getting the labels to show
I changed the indicator to show futures and i tried but cant get the labels to work, I am very new at this. It is difficult to use just the ticker on the futures
I would like to input a label to show like
ZGG9 Gold 767.6 etc.
One line not two
I need one line ont 2 in the indicator so it would be (WPR + RSI)/2
thank you
need help on testing a EA
Hi, I get a EA which is reported to generate very good profit and I want to test it by using it the strategy tester. But the EA would only generate alerts, not doing any trades. I am a newbie to programming in MQL. Can anybody give me a hand on highlighting what parts of the code I should change in order to enable testing and give me some hints on the changes to be made? I have read the tutorial by codersguru but I think I understand it. But that is all.
Below is the source of the EA. A triilion thanks in advance:
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Yellow
#property indicator_color2 LimeGreen
#property indicator_color3 Red
#property indicator_color4 Yellow
#property indicator_color5 Cyan
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
extern bool Crash = false;
extern int TimeFrame = 0;
extern int Length = 5;
extern int Method = 2;
extern int Smoothing = 6;
extern int Filter = 5;
extern bool RealTime = true;
extern bool Steady = false;
extern bool Color = true;
extern bool Alerts = true;
extern bool EmailON = false;
extern bool SignalPrice = true;
extern color SignalPriceBUY = Yellow;
extern color SignalPriceSELL = Aqua;
extern int CountBars = 1485;
double fxlive[];
double fxlive_MTF[];
double DIR[];
double UpBuffer[];
double DnBuffer[];
double UpArrow[];
double DnArrow[];
bool TurnedUp = false;
bool TurnedDn = false;
datetime timeprev1=0;
datetime timeprev2=0;
int p=0;
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(8);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);
SetIndexBuffer(0,ea2test);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID);
SetIndexBuffer(1,UpBuffer);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID);
SetIndexBuffer(2,DnBuffer);
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,233);
SetIndexBuffer(3,UpArrow);
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,234);
SetIndexBuffer(4,DnArrow);
SetIndexBuffer(5,ea2test);
SetIndexBuffer(6,DIR);
SetIndexBuffer(7,ea2test_MTF);
if (Length < 2) Length = 2;
if (Method < 0) Method = 0;
if (Method > 3) Method = 3;
if (Smoothing < 0) Smoothing = 0;
if (Filter < 0) Filter = 0;
if ((TimeFrame < Period()) && (TimeFrame != 0)) TimeFrame = Period();
switch(TimeFrame)
{
case 1: string TimeFrameStr = "M1"; break;
case 5: TimeFrameStr = "M5"; break;
case 15: TimeFrameStr = "M15"; break;
case 30: TimeFrameStr = "M30"; break;
case 60: TimeFrameStr = "H1"; break;
case 240: TimeFrameStr = "H4"; break;
case 1440: TimeFrameStr = "D1"; break;
case 10080: TimeFrameStr = "W1"; break;
case 43200: TimeFrameStr = "MN1"; break;
default: TimeFrameStr = "";
}
string short_name = "ea2test" + TimeFrameStr + " | " + Length + " , " + Method + " , " + Smoothing + " , " + Filter + " | ";
IndicatorShortName(short_name);
return(0);
}
//+------------------------------------------------------------------+
int start()
{
if (Bars < 100) {IndicatorShortName("Bars less than 100"); return(0);}
if(timeprev1<iTime(NULL,TimeFrame,0)) {TurnedDn = false; TurnedUp = false; timeprev1=iTime(NULL,TimeFrame,0);}
if (!RealTime)
{
if(timeprev2==iTime(NULL,TimeFrame,0)) return(0);
timeprev2=iTime(NULL,TimeFrame,0);
p=TimeFrame/Period()+1; if (p==0) p=1;
}
double TR = 0, MH = 0, ML = 0, MO = 0, MC = 0, MC1 = 0;
if (CountBars>iBars(NULL,TimeFrame) || CountBars>Bars-Length-1) CountBars=MathMin(Bars-Length-1,iBars(NULL,TimeFrame)-Length-1);
if (Crash && CountBars>0){CountBars=CountBars-10; IndicatorShortName("Crash: "+CountBars+" ");}
if (Crash && CountBars<0) IndicatorShortName("Crash");
int i = CountBars;
ea2test = Close;
ea2test_MTF = Close;
while (i >= 0)
{
MH = iMA(NULL,TimeFrame,Length,0,Method,PRICE_HIGH,i);
ML = iMA(NULL,TimeFrame,Length,0,Method,PRICE_LOW,i);
MO = iMA(NULL,TimeFrame,Length,0,Method,PRICE_OPEN,i);
MC = iMA(NULL,TimeFrame,Length,0,Method,PRICE_CLOSE,i);
MC1 = iMA(NULL,TimeFrame,Length,0,Method,PRICE_CLOSE,i + Smoothing);
if (Steady==true) {MC=iMA(NULL,TimeFrame,Length,0,Method,PRICE_MEDIAN,i); MC1=iMA(NULL,TimeFrame,Length,0,Method,PRICE_MEDIAN,i+Smoothing);}
ea2test = MathAbs(((MC - MC1) / MathMax(MH - ML,MathMax(MH - MC1,MC1 - ML)) + (MC - MO) / (MH - ML)) * 0.5) * ((MC - MC1 + (MC - MO)) * 0.5);
ea2test = ea2test + ea2test;
if (Filter > 0) if (MathAbs(ea2test - ea2test) < Filter * Point) ea2test = ea2test;
if (TimeFrame > Period()) ea2test_MTF = ea2test;
i--;
}
if (TimeFrame>Period())
{
datetime TimeArray1[];
ArrayCopySeries(TimeArray1,MODE_TIME,Symbol(),TimeFrame);
int limit=CountBars+TimeFrame/Period();
for(i=0, int y=0;i<limit;i++) {if (Time<TimeArray1[y]) y++; ea2test=ea2test_MTF[y];}
}
for (i = CountBars; i >= 0; i--)
{
DIR = DIR;
if (ea2test - ea2test > 0) DIR = 1;
if (ea2test - ea2test > 0) DIR = -1;
if (Color == true)
{
if (DIR > 0)
{
UpBuffer = ea2test;
if (DIR < 0) UpBuffer = ea2test;
DnBuffer = EMPTY_VALUE;
}
else
{
if (DIR < 0)
{
DnBuffer = ea2test;
if (DIR > 0) DnBuffer = ea2test;
UpBuffer = EMPTY_VALUE;
}
}
}
if (Alerts == true)
{
UpArrow = EMPTY_VALUE; DnArrow = EMPTY_VALUE;
if ((DIR == 1) && (DIR == -1)) UpArrow = ea2test - (Ask - Bid);
if ((DIR == -1) && (DIR == 1)) DnArrow = ea2test + (Ask - Bid);
}
}
if (Alerts == true)
{
string AlertTXT;
if (UpArrow[0+p]!=EMPTY_VALUE && TurnedUp==false)
{
AlertTXT="ea2test BUY: "+Symbol()+" - "+Period()+" at "+ DoubleToStr(Close[0],Digits)+ " - "+ TimeToStr(CurTime(),TIME_SECONDS);
Alert(AlertTXT); if (EmailON) SendMail(AlertTXT,AlertTXT);
if (SignalPrice == true)
{
ObjectCreate("BUY SIGNAL: " + DoubleToStr(Time[0],0),OBJ_ARROW,0,Time[0],Close[0]);
ObjectSet("BUY SIGNAL: " + DoubleToStr(Time[0],0),OBJPROP_ARROWCODE,5);
ObjectSet("BUY SIGNAL: " + DoubleToStr(Time[0],0),OBJPROP_COLOR,SignalPriceBUY);
}
TurnedDn = false; TurnedUp = true;
}
if (DnArrow[0+p]!=EMPTY_VALUE && TurnedDn==false)
{
AlertTXT="ea2test SELL: "+Symbol()+" - "+Period()+" at "+ DoubleToStr(Close[0],Digits)+ " - "+ TimeToStr(CurTime(),TIME_SECONDS);
Alert(AlertTXT); if (EmailON) SendMail(AlertTXT,AlertTXT);
if (SignalPrice == true)
{
ObjectCreate("SELL SIGNAL: " + DoubleToStr(Time[0],0),OBJ_ARROW,0,Time[0],Close[0]);
ObjectSet("SELL SIGNAL: " + DoubleToStr(Time[0],0),OBJPROP_ARROWCODE,5);
ObjectSet("SELL SIGNAL: " + DoubleToStr(Time[0],0),OBJPROP_COLOR,SignalPriceSELL);
}
TurnedUp = false; TurnedDn = true;
}
}
return(0);
}
need some help
can anyone give me the code for adding set trading times to an ea as i only what it to trade for a few hwers a day, not all day
thank you all for your help
Hi, I get a EA which is reported to generate very good profit and I want to test it by using it the strategy tester. But the EA would only generate alerts, not doing any trades. I am a newbie to programming in MQL.
This is an indicator, not EA. Indicators can't open and close orders.
can anyone give me the code for adding set trading times to an ea as i only what it to trade for a few hwers a day, not all day thank you all for your help
If your time from 10am to 5pm, put this string at the beginning of start block:
if (TimeHour(TimeCurrent())=17)return(0);
thanks roger
so I need to check for ways to convert indicators to EA, right?
btw, can anyone tell me the main idea of the indicator?
Is it right
If your time from 10am to 5pm, put this string at the beginning of start block: if (TimeHour(TimeCurrent())=17)return(0);
thank you so much, is it in the right place , where I put it.
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
if (TimeHour(TimeCurrent())=17)return(0);
int start() {
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;