[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 159

 
BooGUY:

todem, I tried if (d1!=0)

but the EA still opens in a wrong place. In general, it should change Buy to Sell, but sometimes it opens twice for Sell. Maybe I have not copied something.


don't you think it's lagging?
 
DhP:

The number of passes can be reduced by:

1. Increasing the pitch.

2. Reduce the parameter optimisation range.

3. Reduce number of parameters to be optimised.

4. Enable "Genetic algorithm".


Here's more about Genetic Algorithm..... if you can)))

 

Guys, how about the advisor.... I know there is no limit to how good an advisor can be, but in your opinion what is the profitability of an advisor (annual return) ??????

Over a year.... I got the following:

Maximum drawdown: 8.69% (3768$)

Profit: $27464.5 just over 100 percent

Total trades: 142

I traded a fixed lot: 1 lot

My first EA...thanks to everyone who helped)

 

let's say I have an Expert Advisor (My_expert) and an indicator (My_indicator)

Expert Advisor uses indicator data (currently via iCustom)

Can I make the Expert Advisor add the indicator to the chart during initialization and delete it during deinitialization?

 

I'm trying to write an Expert Advisor that would close the order the next day (in any case). But the order is not closed for some reason (please, advise why?

Below is the code for sell:


if (OrdersTotal()==0) {

OPENORDER ("Sell");
}
int TC = int TimeCurrent();
int OM = int OrderMagicNumber();

if (OrdersTotal()==1 && OrderType()==OP_SELL && TC-OM>86400){ // DayMove(3)<0 && DayMove(2)<0 && DayMove(3)<0 && DayMove(4)<0 && DayMove(5)>0
CLOSEORDER("Sell");
}

This is the open/close order function:

void CLOSEORDER(string ord)
{
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if (OrderSymbol()!=Symbol()||Magic!=OrderMagicNumber()) continue;
if (OrderType()==OP_BUY && ord=="Buy")
OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE);
if (OrderType()==OP_SELL && ord=="Sell")
OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE);
}
}
}
//--------------------------------------------------------------------


void OPENORDER(string ord)
{
int error;
//Magic=TimeDay(CurTime();
Magic = TimeCurrent();
if (ord=="Buy" ) error=OrderSend(Symbol(),OP_BUY, LOT,Ask,2,SL,TP, "EMA WMA RSI",Magic,3);
if (ord=="Sell") error=OrderSend(Symbol(),OP_SELL,LOT,Bid,2,SL,TP, "EMA WMA RSI",Magic,3);
if (error==-1) ShowERROR(error,0,0);
return;
}

 
Vovo4ka:

Guys, how about the advisor.... I know there is no limit to how good an advisor can be, but in your opinion what is the profitability of an advisor (annual return) ??????

Over a year.... I got the following:

Maximum drawdown: 8.69% (3768$)

Profit: $27464.5 just over 100 percent

Total trades: 142

I traded a fixed lot: 1 lot

My first EA...thanks to everyone who helped)

If it is a graph in an optimised area, there is nothing to say about its future performance. If it is a chart in an unoptimised area, then there is hope that it will be profitable. And the truth will be revealed when working on the real account.
 
ILL:

...
int OM = int OrderMagicNumber();
...


The order must be pre-selected with OrderSelect(), this is not the case here.
 
ilunga:

The order must be pre-selected using OrderSelect(), this is not the case in what you have given.


Hooray!!! It worked=)

Thank you very much.

 
todem:

Let's do it together. I have a dummy indicator showing the current direction - do you need it?


No problem - let's do it together. All the developments are listed in the previous links... It's not just about checking in a loop. Looking for options to write in each truth to an array - but haven't dealt with arrays yet.

//+-------------------------------------------------------------------------------+
// Проверка смены тренда 
bool TrendChange(int Period_MAb, int Period_MAm, int nB)
{
  double maB1=iMA(NULL, 0, Period_MAb, 0, MODE_EMA, PRICE_WEIGHTED, 1);
  double maM1=iMA(NULL, 0, Period_MAm, 0, MODE_EMA, PRICE_WEIGHTED, 1);   
  for (int i=0; i<nB; i++) 
  {
    double maB=iMA(NULL,0, Period_MAb, 0, MODE_EMA, PRICE_WEIGHTED, i);
    double maM=iMA(NULL,0, Period_MAm, 0, MODE_EMA, PRICE_WEIGHTED, i); 
     if ((maM<maB && maM1>maB1)||(maM>maB && maM1<maB1)){
//     Alert("TrendChange-true");
     return(true);
     }
  }
  return(false);   
}

So - this function works! Who may need it!

BUT! The question is about economy of resources - as my machine is not the strongest one, and this function is checked often. So it turns out that every tick we have to recalculate a bunch of old bars (for example in my case nB=610 ). The only way to solve this problem is to write a flag into an array and then check the entire array and the last bar for truth. Does anybody have other variants? Any suggestions?

 
ILL:


Yay!!! It worked=)

Thank you very much.

You're welcome))

Who would answer me now))

Reason: