How to code? - page 47

 

Thanks MrPip

I mostly get where you are coming from, I will give it ago and ask again if I get stuck.

cheers

 
MrPip:
Corrections in Red below. Robert

Thank you Robert.. that helped..

 

Bar count down with MTF indictaors

MTF = multi time frame indicators

double BarCountDownInSec()

{

double g;

g=Time[0]+Period()*60-TimeCurrent();

return(g);

}

The above function gives the second count down for bars in the current chart. So if placed on a 5 min chart, it will show second count down for each 5 min bar.

Q: How do I get seconds count down for a 15 minute bar (ie 3x 5 min bars), when I am in a 5 min chart, so a count down of 15 minutes from 6.00 to 6.15. then 6.15 to 6.30, while I am in a 5 min chart ???

 

Problem with my programming (BUG)

Hi,

Can someone help to clear the bug for me. I was almost there just that the draw histogram don't appears unless i conpile the code again.

Please help!!! Please Please Please

Regards

Files:
 

icustom problem

What is the string name of this indi that I should use for an iCustom part of an EA

I have tried

MT4-LevelStop-Reverse-vBO-4

MT4-LevelStop-Reverse-

MT4-LevelStop-Reverse

vBO-4

vB0.4

vtsbh2483-

MT4-LevelStop-Reverse-" + INDICATOR_VERSION + "(

So I have no idea what to do next.

or do I need to put in the ATRMode,Manual Mode etc String Names

Any help would be great

 

Can anybody see the error? I can't see where the error is in this code. I keep getting. Any help in pointing this out would be great. Thanks

LongSig Variable not defined

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

//| Calculate open positions |

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

int CalculateCurrentOrders() {

buys=0; sells=0;

string symbol=Symbol();

//----

for(int i=0;i<OrdersTotal();i++)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) continue;

if(OrderSymbol()==Symbol() && OrderMagicNumber()==expertId)

{

if(OrderType()==OP_BUY || OrderType()==OP_BUYSTOP) buys++;

if(OrderType()==OP_SELL || OrderType()==OP_SELLSTOP) sells++;

}

}

//---- return orders volume

if(buys>0) return(buys);

else return(-sells);

}

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

//| Check for open order conditions |

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

void CheckForSignals() {

buysig=false;

sellsig=false;

closebuy=false;

closesell=false;

double MOM = iCustom (NULL,0,"Momentum-ZL",MOMPeriod,0,shift);

double SRL = iCustom (NULL,0,"MT4-LevelStop-Reverse-vBO-4",UseATRMode,NonATRStopPips,ATRPeriod, ATRMultiplier,ATRSmoothing,UpArrowColor,DnArrowColor,ArrowDistance,233);

double SRS = iCustom (NULL,0,"MT4-LevelStop-Reverse-vBO-4",UseATRMode,NonATRStopPips,ATRPeriod, ATRMultiplier,ATRSmoothing,UpArrowColor,DnArrowColor,ArrowDistance,234);

double QQE_RsiMa = iCustom(NULL,0,"QQE",0,shift);

double QQE_TrLevelSlow = iCustom(NULL,0,"QQE", 1, shift);

double QQE_RsiMaPrev = iCustom(NULL,0,"QQE",0,shift + 1);

double QQE_TrLevelSlowPrev = iCustom(NULL,0,"QQE", 1, shift + 1);

double Pivot = iCustom (NULL,0,"Pivot Points Multitimeframe",midpivots,Fhr,daily,weekly,monthly,1,shift)

bool LongSig = QQE_RsiMaPrev QQE_TrLevelSlow >50.0;

bool ShortSig = QQE_RsiMaPrev > QQE_TrLevelSlowPrev && QQE_RsiMa < QQE_TrLevelSlow<50.0;

bool LongSig2 = MOM>0.0;

bool ShortSig2 = MOM<0.0;

bool LongSig3 = SRL>Pivot;

bool ShortSig3 = SRS<Pivot;

buysig = LongSig && LongSig2 && LongSig3;

sellsig = ShortSig && ShortSig2 && ShortSig3;

closebuy=sellsig;

closesell=buysig;

}

void CheckForOpen() {

if (last==Time[0]) return;

int res,ord;

double entry,stop,profit;

ord=CalculateCurrentOrders();

if (ord!=0) CheckForClose();

ord=CalculateCurrentOrders();

//---- buy conditions

if (buys<ConsecutiveTrades && buysig) {

res=OpenAtMarket(OP_BUY,Lots);

if (res<0) Print("Error opening BUY order : ",ErrorDescription(GetLastError()));

else last=Time[0];

}

//---- sell conditions

if (-sells<ConsecutiveTrades && sellsig) {

res=OpenAtMarket(OP_SELL,Lots);

if (res<=0) Print("Error opening SELL order : ",ErrorDescription(GetLastError()));

else last=Time[0];

}

}

int OpenAtMarket(int mode,double lot) {

int res,tr,col;

double openprice,sl,tp;

tries=0;

while (res<=0 && tries<OrderTriesNumber) {

tr=0; while (tr<5 && !IsTradeAllowed()) { tr++; Sleep(2000); }

RefreshRates();

if (mode==OP_SELL) {

openprice=Bid;

col=Red;

} else {

//openprice=nd(Ask);

openprice=Ask;

col=Blue;

}

res=OrderSend(Symbol(),mode,lot,openprice,slippage,sl,tp,EAName+expertId,expertId,0,col);

tries++;

}

return(res);

}

Fixed IT

 

Try the first on your list with a number zero 0 instead of a letter O for vB0-4.

Robert

Beno:
What is the string name of this indi that I should use for an iCustom part of an EA

I have tried

MT4-LevelStop-Reverse-vBO-4

MT4-LevelStop-Reverse-

MT4-LevelStop-Reverse

vBO-4

vB0.4

vtsbh2483-

MT4-LevelStop-Reverse-" + INDICATOR_VERSION + "(

So I have no idea what to do next.

or do I need to put in the ATRMode,Manual Mode etc String Names

Any help would be great
 

Thanks Mr Pips

Sorted it

 
MrPip:
Corrections in Red below. Robert

i tried this but it seems not to work.. i only want one trade per day..

for(int a=0;a<OrdersTotal();a++)

{

if (OrderSelect(a,SELECT_BY_POS,MODE_TRADES) == true)

{

if (OrderSymbol()== Symbol() && OrderMagicNumber()== Magic_Number)

{

if (TimeDay(OrderOpenTime()) >= TimeDay(TimeCurrent())) Trade = false;

if (TimeDay(OrderOpenTime()) < TimeDay(TimeCurrent())) Trade = true;

}

}

}
 
antone:
i tried this but it seems not to work.. i only want one trade per day..

I have used this in other EAs and it works correctly.

I check for trade closed today instead of open today.

Usage in start is

if (LastTradeClosedToday()) return(0);

// code here to open new trades

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

//| LastTradeClosedToday |

//| Check History to see if last trade closed today |

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

bool LastTradeClosedToday()

{

int cnt, total;

bool Closed;

total = HistoryTotal();

for (cnt = total - 1; cnt >= 0; cnt--)

{

OrderSelect (cnt, SELECT_BY_POS, MODE_HISTORY);

if(OrderSymbol()!=Symbol()) continue;

if (OrderMagicNumber() != MagicNumber) continue;

Closed = false;

if (OrderType() == OP_BUY)

{

if (TimeDay(OrderCloseTime()) == TimeDay(TimeCurrent()))

{

Closed = true;

}

cnt = 0;

}

if (OrderType() == OP_SELL)

{

if (TimeDay(OrderCloseTime()) == TimeDay(TimeCurrent()))

{

Closed = true;

}

cnt = 0;

}

}

return (Closed);

}

Reason: