Coding help - page 88

 

Dear Mladen,

Sorry about the basic question - I am always in trouble when a code needs operation with date and time. There is a constant 120 in Line 97 of AverageJoe EA you posted in this forum a couple of days ago:

if (OrderType() == OP_SELL && CurTime()-LastSellTime >=120) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );

What is the measurement unit of that 120?

Regards,

Chrisstoff

 
mladen:
Chrisstoff Those are seconds (metatrader save time as a number of seconds passes since 1.1.1970 if I am not mistaken, but the point is that it always works with seconds when a datetime variable is declared or a function like CurrentTime() is called)

Mladen,

Thank you for the fast response.

 
chrisstoff:
Dear Mladen,

Sorry about the basic question - I am always in trouble when a code needs operation with date and time. There is a constant 120 in Line 97 of AverageJoe EA you posted in this forum a couple of days ago:

if (OrderType() == OP_SELL && CurTime()-LastSellTime >=120) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );

What is the measurement unit of that 120?

Regards,

Chrisstoff

Chrisstoff

Those are seconds (metatrader savea time as a number of seconds passed since 1.1.1970 if I am not mistaken, but the point is that it always works with seconds when a datetime variable is declared or a function like CurrentTime() is called)

 

Modify the indicators Thank you to!

#property indicator_chart_window

#property indicator_buffers 5

//---- input parameters

extern int TimeFramePeriod;

extern int N=100;

//

extern double CustoMA1;

extern double CustoMA2;

extern double CustoMA3;

extern double CustoMA4;

extern double high20;

extern double low20;

//

#property indicator_color1 Red

#property indicator_color2 Lime

#property indicator_color3 Orange

#property indicator_color4 Red

//--- buffers

double CustoMA1[];

double CustoMA2[];

double CustoMA3[];

double CustoMA4[];

double tr[];

//

int init() {

SetIndexStyle(0, DRAW_LINE);

SetIndexBuffer(0, CustoMA1);

SetIndexStyle(1, DRAW_LINE);

SetIndexBuffer(1, CustoMA2);

SetIndexStyle(2, DRAW_LINE);

SetIndexBuffer(2, CustoMA3);

SetIndexStyle(3, DRAW_LINE);

SetIndexBuffer(3, CustoMA4);

SetIndexStyle(4, DRAW_LINE);

SetIndexBuffer(4,tr);

return (0);

}

//---- buffers

double buff[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

//int init()

//{

//if (Bars < MIN_BARS_REQUIRED) return(-1);

//IndicatorDigits(Digits);

//SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);

//SetIndexBuffer(0, buff);

//string paramDesc = "("+getPeriodDesc(TimeFramePeriod) + ", "")";

//IndicatorShortName("" + paramDesc);

// Set Index Labels

//SetIndexLabel(0, "" + paramDesc);

//----

//return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int start()

{

int Limit;

int counted_bars=IndicatorCounted();

//----

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit=Bars-counted_bars;

int i=0;

for (i=Mathmin(Bars-5,Limit);i>=0;i--);

tr[]=MathMax(MathMax(High-Low,MathAbs(Close-High)),MathAbs(Close-Low));

higt20=H=HHV(H,N);

low20=L=LLV(L,N);

//

MA1=H-tr[]*0.1;

MA2=H-tr[]*0.2;

MA3=L+tr[]*0.1;

MA4=L+tr[]*0.2;

//

CustoMA1=REF(MA1,BarsSince(higt20));

CustoMA2=REF(MA2,BarsSince(higt20));

CustoMA3=REF(MA3,BarsSince(low20));

CustoMA4=REF(MA4,BarsSince(low20));

//

Plot(CustoMA1,"TREND",colorRed);

Plot(CustoMA2,"TREND",colorLime);

Plot(CustoMA3,"TREND",colorOrange);

Plot(CustoMA4,"TREND",colorRed);

//----

return(0);

//+------------------------------------------------------------------+

string getPeriodDesc(int aNumMinutes)

{

switch(aNumMinutes)

{

case PERIOD_M1 : return("M1");

case PERIOD_M15: return("M15");

case PERIOD_M30: return("M30");

case PERIOD_H1 : return("H1");

case PERIOD_H4 : return("H4");

case PERIOD_D1 : return("D1");

case PERIOD_W1 : return("W1");

case PERIOD_MN1: return("MN1");

case 0: return("Chart");

default: return("M" + aNumMinutes);

}

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

double getDeMarker(int aShift)

{

return(iDeMarker(NULL, TimeFramePeriod, 13, iBarShift(NULL, TimeFramePeriod, Time[aShift])));

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int start()

{

for(int shift=Bars-1;shift>=0;shift--)

{

buff[shift]=getDeMarker(shift);

}

return(0);

}

//+------------------------------------------------------------------+

Sorry ! Paste the code here

Kreangast

2013/5/21

 
Kreangast:
Modify the indicators Thank you to!

#property indicator_chart_window

#property indicator_buffers 5

//---- input parameters

extern int TimeFramePeriod;

extern int N=100;

//

extern double CustoMA1;

extern double CustoMA2;

extern double CustoMA3;

extern double CustoMA4;

extern double high20;

extern double low20;

//

#property indicator_color1 Red

#property indicator_color2 Lime

#property indicator_color3 Orange

#property indicator_color4 Red

//--- buffers

double CustoMA1[];

double CustoMA2[];

double CustoMA3[];

double CustoMA4[];

double tr[];

//

int init() {

SetIndexStyle(0, DRAW_LINE);

SetIndexBuffer(0, CustoMA1);

SetIndexStyle(1, DRAW_LINE);

SetIndexBuffer(1, CustoMA2);

SetIndexStyle(2, DRAW_LINE);

SetIndexBuffer(2, CustoMA3);

SetIndexStyle(3, DRAW_LINE);

SetIndexBuffer(3, CustoMA4);

SetIndexStyle(4, DRAW_LINE);

SetIndexBuffer(4,tr);

return (0);

}

//---- buffers

double buff[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

//int init()

//{

//if (Bars < MIN_BARS_REQUIRED) return(-1);

//IndicatorDigits(Digits);

//SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);

//SetIndexBuffer(0, buff);

//string paramDesc = "("+getPeriodDesc(TimeFramePeriod) + ", "")";

//IndicatorShortName("" + paramDesc);

// Set Index Labels

//SetIndexLabel(0, "" + paramDesc);

//----

//return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int start()

{

int Limit;

int counted_bars=IndicatorCounted();

//----

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit=Bars-counted_bars;

int i=0;

for (i=Mathmin(Bars-5,Limit);i>=0;i--);

tr[]=MathMax(MathMax(High-Low,MathAbs(Close-High)),MathAbs(Close-Low));

higt20=H=HHV(H,N);

low20=L=LLV(L,N);

//

MA1=H-tr[]*0.1;

MA2=H-tr[]*0.2;

MA3=L+tr[]*0.1;

MA4=L+tr[]*0.2;

//

CustoMA1=REF(MA1,BarsSince(higt20));

CustoMA2=REF(MA2,BarsSince(higt20));

CustoMA3=REF(MA3,BarsSince(low20));

CustoMA4=REF(MA4,BarsSince(low20));

//

Plot(CustoMA1,"TREND",colorRed);

Plot(CustoMA2,"TREND",colorLime);

Plot(CustoMA3,"TREND",colorOrange);

Plot(CustoMA4,"TREND",colorRed);

//----

return(0);

//+------------------------------------------------------------------+

string getPeriodDesc(int aNumMinutes)

{

switch(aNumMinutes)

{

case PERIOD_M1 : return("M1");

case PERIOD_M15: return("M15");

case PERIOD_M30: return("M30");

case PERIOD_H1 : return("H1");

case PERIOD_H4 : return("H4");

case PERIOD_D1 : return("D1");

case PERIOD_W1 : return("W1");

case PERIOD_MN1: return("MN1");

case 0: return("Chart");

default: return("M" + aNumMinutes);

}

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

double getDeMarker(int aShift)

{

return(iDeMarker(NULL, TimeFramePeriod, 13, iBarShift(NULL, TimeFramePeriod, Time[aShift])));

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int start()

{

for(int shift=Bars-1;shift>=0;shift--)

{

buff[shift]=getDeMarker(shift);

}

return(0);

}

//+------------------------------------------------------------------+

Sorry ! Paste the code here

Kreangast

2013/5/21

That is someone trying to combine code from tadestation with a code from metatrader. It will not work that way and it can not be combined that way

 

To :mladen

Could you into MT4 okay? A section of TS code, I will not write MT4 . Thank you.

Kreangast

2013-5-21

 
Kreangast:
To :mladen

Could you into MT4 okay? A section of TS code, I will not write MT4 . Thank you.

Kreangast

2013-5-21

From that what you posted it is not possible to see what it should do

 

To :mladen

I would like to ask how to do ?

Thank you

Kreangast

 
Kreangast:
To :mladen

I would like to ask how to do ?

Thank you

Kreangast

For start, you will first have to read these : https://www.mql5.com/en/forum/172969/page2 and then something similar for tradestation and then you can convert code from one coding language to another coding language

 
mladen:
For start, you will first have to read these : https://www.mql5.com/en/forum/172969/page2 and then something similar for tradestation and then you can convert code from one coding language to another coding language

But this code does not write , trouble you into MT4 okay ? Extremely grateful

Kreangast

2013/5/21

Reason: