# Arráy help

69

My array dont work for lots

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

//                        DO NOT DELETE THIS HEADER

//

//                 ForexEAdvisor Strategy Builder version 0.2

//

// THIS EA CODE HAS BEEN GENERATED USING FOREXEADVISOR STRATEGY BUILDER 0.2

// on: 11/7/2016 8:23:42 PM

// Disclaimer: This EA is provided to you "AS-IS", and ForexEAdvisor disclaims any warranty

// or liability obligations to you of any kind.

// UNDER NO CIRCUMSTANCES WILL FOREXEADVISOR BE LIABLE TO YOU, OR ANY OTHER PERSON OR ENTITY,

// FOR ANY LOSS OF USE, REVENUE OR PROFIT, LOST OR DAMAGED DATA, OR OTHER COMMERCIAL OR

// ECONOMIC LOSS OR FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, STATUTORY, PUNITIVE,

// EXEMPLARY OR CONSEQUENTIAL DAMAGES WHATSOEVER RELATED TO YOUR USE OF THIS EA OR

// Because software is inherently complex and may not be completely free of errors, you are

// USE THIS EA AT YOUR OWN RISK.

//

// Before adding this expert advisor to a chart, make sure there are NO

// open positions.

//                      DO NOT DELETE THIS HEADER

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

extern int MagicNumber=10001;

extern double Lots =0.1;

extern double StopLoss=50;

extern double TakeProfit=50;

extern int TrailingStop=50;

extern int Slippage=3;

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

//    expert start function

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

double lot[1]={1};

int lot1[];

int start()

{

double MyPoint=Point;

if(Digits==3 || Digits==5) MyPoint=Point*10;

double TheStopLoss=0;

double TheTakeProfit=0;

if( TotalOrdersCount()==0 )

{

int result=0;

{

{

lot[0]=5;

lot[1]=2;

lot[2]=3;

lot[3]=4;

return(result);

}

if(result>0)

{

TheStopLoss=0;

TheTakeProfit=0;

OrderSelect(result,SELECT_BY_TICKET);

OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);

}

return(0);

}

if((Bid<Open[0])) // Here is your open Sell rule

{

{

lot[0]=5;

lot[1]=2;

lot[2]=3;

lot[3]=4;

return(result);

}

if(result>0)

{

TheStopLoss=0;

TheTakeProfit=0;

if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;

if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;

OrderSelect(result,SELECT_BY_TICKET);

OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);

}

return(0);

}

}

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

{

if(OrderType()<=OP_SELL &&

OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber

)

{

{

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)

{

if(OrderStopLoss()<Bid-MyPoint*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);

return(0);

}

}

}

}

else

{

if(TrailingStop>0)

{

{

{

return(0);

}

}

}

}

}

}

return(0);

}

int TotalOrdersCount()

{

int result=0;

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

{

if (OrderMagicNumber()==MagicNumber) result++;

}

return (result);

}
7364

Can you specify "does not work"? What do you expect, what do you get - have you tried the debugger, checked _LastError, ....?
16110

1.  Play video Please edit your post. For large amounts of code, attach it.

2. matheustn12: My array dont work for lots
"Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
• We hate EA builder
• You couldn't be bothered to learn mql4, therefor there is no common language for us to communicate.
• There are only two choices: learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem, but we are not going to debug your hundreds lines of code.
• EA builder makes bad code counting up while closing multiple orders.
• EA builder makes bad code Bars is unreliable (max bars on chart) volume is unreliable (miss ticks) Always use time
• EA builder makes bad code Not adjusting for 4/5 digit brokers
• EA builder makes bad code not checking return codes.
• EATree uses objects on chart to save values - not persistent storage (files or GV+Flush.) No recovery (crash/reboot.)

4.  How big did you define lot? It is big enough for the assignments? double lot[1]={1};int start(){  :       {lot[0]=5;lot[1]=2;lot[2]=3;lot[3]=4;
69

whroeder1:
1.  Please edit your post. For large amounts of code, attach it.

2. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.

4.  How big did you define lot? It is big enough for the assignments? double lot[1]={1};int start(){  :       {lot[0]=5;lot[1]=2;lot[2]=3;lot[3]=4;

Sorry,I want lots fixed ,I just made one here, Lots goes from 1 to 9 and then to not return to the initial lots.

SorrY EA Generation

extern int MagicNumber=10001;
extern double Lots =0.1;
extern double StopLoss=50;
extern double TakeProfit=50;
extern int TrailingStop=50;
extern int Slippage=3;
//+------------------------------------------------------------------+
//    expert start function
//+------------------------------------------------------------------+

int numero[]={1,3,3,4,5,6,7,8,9};
int n,result;

int start()
{
double MyPoint=Point;
if(Digits==3 || Digits==5) MyPoint=Point*10;

double TheStopLoss=0;
double TheTakeProfit=0;
if( TotalOrdersCount()==0 )
{
int result=0;
{

{
for(n=0;n<1000;n++){
result=numero[n]+OrderLots();

}

if(result>0)
{
TheStopLoss=0;
TheTakeProfit=0;
OrderSelect(result,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
}
return(0);

}
if((Bid<Open[0])) // Here is your open Sell rule
{

{

for(n=0;n<1000;n++){
result=numero[n]+OrderLots();

}

if(result>0)
{
TheStopLoss=0;
TheTakeProfit=0;
if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
}
return(0);
}
}
}

for(int cnt=0;cnt<OrdersTotal();cnt++)
{
if(OrderType()<=OP_SELL &&
OrderSymbol()==Symbol() &&
OrderMagicNumber()==MagicNumber
)
{
{
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
{
if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
return(0);
}
}
}
}
else
{
if(TrailingStop>0)
{
{
{
return(0);
}
}
}
}
}
}
return(0);
}

}

int TotalOrdersCount()
{
int result=0;
for(int i=0;i<OrdersTotal();i++)
{
if (OrderMagicNumber()==MagicNumber) result++;

}
return (result);
}

69

So, the order of the lot is 1,2,3,4,5,6,7,8,9. I want it when it gets back pro lot initial

At each loss continues the fixed lots, and when it wins back to initial lots

New post=https://www.mql5.com/en/forum/161112

You can delete this Post

Array HELP Update
• www.mql5.com
So, the order of the lot is 1,2,3,4,5,6,7,8,9...
Moderator
5677

Or you can continue here.
69

Marco vd Heijden:
Or you can continue here.
:( okay
69

What's wrong with this?

Only open purchase order.

extern int MagicNumber=10001;
extern double Lots =0.1;
extern double StopLoss=50;
extern double TakeProfit=50;
extern int TrailingStop=50;
extern int Slippage=3;
//+------------------------------------------------------------------+
//    expert start function
//+------------------------------------------------------------------+

double lotsfactor=1,ilots;
double initiallotsfactor=1;

int numero[]={2,3,3,4,5,6,7,8,9};
int n,result;

int start()
{
double MyPoint=Point;
if(Digits==3 || Digits==5) MyPoint=Point*10;

double TheStopLoss=0;
double TheTakeProfit=0;
if( TotalOrdersCount()==0 )
{
int result=0;
{

{
for(n=0;n<numero[n];n++){
result=numero[n]+OrderLots();

if(result>0)
{
TheStopLoss=0;
TheTakeProfit=0;
OrderSelect(result,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
}

}
return(0);
}
if((Bid<Open[0])) // Here is your open Sell rule
{

{

for(n=0;n<numero[n];n++){
result=numero[n]+OrderLots();

result=OrderSend(Symbol(),OP_SELL,numero[n],Bid,Slippage,0,0,MagicNumber,0,Red);

if(result>0)
{
TheStopLoss=0;
TheTakeProfit=0;
if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
}
return(0);
}

}
}
}

for(int cnt=0;cnt<OrdersTotal();cnt++)
{
if(OrderType()<=OP_SELL &&
OrderSymbol()==Symbol() &&
OrderMagicNumber()==MagicNumber
)
{
{
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
{
if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
return(0);
}
}
}
}
else
{
if(TrailingStop>0)
{
{
{
return(0);
}
}
}
}
}
}
return(0);
}

}

int TotalOrdersCount()
{
int result=0;
for(int i=0;i<OrdersTotal();i++)
{
if (OrderMagicNumber()==MagicNumber) result++;

}
return (result);
}

int martingalefactor()
{
int histotal=OrdersHistoryTotal();
if (histotal>0)
{
for(int cnt=histotal-1;cnt>=0;cnt++)
{
if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
if(OrderProfit()<0)
{

}
else
{
lotsfactor=initiallotsfactor;
if(lotsfactor<=0)
{
lotsfactor=1;
}
return(lotsfactor);
}
}
}
}
}
return(lotsfactor);
}