[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 606

 
Roger:


Show the function itself.

If it is void ClosePartPosBySelect(double Part), change to

void ClosePartPosBySelect()

But how can you pass a parameter into this function? Suppose:
if (x==2 && y==4) Part=0.5;
else Part=2;

ClosePartPosBySelect(Part);

Kim's ClosePosBySelect() function is changed so that it requires a passed parameter of the double type, which is the Part variable

 
keekkenen:

two ways

1. In the function where the value is changed, add an ampersand,

e.g. void function( double& Part ){}

then, when a value inside the function is changed, the new value will return to the place of call

2. remove the variable from the parameter list of the function, since the variable is defined globally, its value can be changed in any place of the code without passing it as a parameter...

The first variant is better, since there can be more than one globally declared variable (and inside one function)...


I have glanced through the post, in fact, the answer has already been given...

Thanks, I'll give it a try...
 
zelek:

Hello Dear Professionals.

I would really like to write an EA which would open two Sell and Buy orders at the same time.

Then after a certain amount of points (parameter lim), the losing order would be closed,

and a profitable one will be closed when the price has fallen below the maximum price since the order was opened

(a kind of virtual trailing stop).

In agony I have created this, but it does not work... does not work

Please suggest something

How do you think you will decide whether it is a pullback or a reversal? Or will you open two positions on every pullback? It's a bust...
 
artmedia70:
How do you pass a parameter to this function then?


If the parameter is declared globally, you don't need to pass it, directly assign the desired value. Only then it doesn't need to be overridden in the function.
 
It's interesting...

This is the whole of 2009... Only Momentum readings are used for entry:
On TF H1 we look for the moment of Momentum movement break, and on TF M5 we find the exact moment to enter the market. When opening a position, we check the time of the previous position opening, so as not to open the entire deposit at the time of the entry signal...
The time of entering the market is confirmed by Demarker's position in overbought/oversold zones on TF M5 and M15...
... By the way, without locking was also a positive result.

... Even the fact that I negligently ran the test only with Demarker, still gave interesting results:

It's something like this somewhere:

//---------------------------------------------------------
   MomML_0   =iMomentum(NULL,PERIOD_M5,14,PRICE_CLOSE,0);
   MomML_1   =iMomentum(NULL,PERIOD_M5,14,PRICE_CLOSE,1);
   MomML_2   =iMomentum(NULL,PERIOD_M5,14,PRICE_CLOSE,2);
   
   MomST_0  =iMomentum(NULL,PERIOD_H1,14,PRICE_CLOSE,0);
   MomST_1  =iMomentum(NULL,PERIOD_H1,14,PRICE_CLOSE,1);
   MomST_2  =iMomentum(NULL,PERIOD_H1,14,PRICE_CLOSE,2);
   
   DeM5     =iDeMarker(NULL,PERIOD_M5, 14,0);
   DeM15    =iDeMarker(NULL,PERIOD_M15,14,0);

//---------------------------------------------------------
//==============================================================================================
   // Поиск пересечений
//==============================================================================================  
//----------------------- Проверка условий для старшего ТФ --------------------    
// ---------- Покупка --------
   MomBuy56M15=false;
   if (
         MomST_0<100 && 
         MomST_1<100 && 
         MomST_2<100 &&
         MomST_0>MomST_1 &&
         MomST_1<MomST_2 &&
         DeM15<0.3
      )                                
         {   
            MomBuy56M15=true;
         }

// ---------- Продажа --------
   MomSell56M15=false;
   if (
         MomST_0>100 && 
         MomST_1>100 && 
         MomST_2>100 &&
         MomST_0<MomST_1 &&
         MomST_1>MomST_2 &&
         DeM15>0.7
      )                                
         {   
            MomSell56M15=true;
         }
//----------------------- Проверка условий для младшего ТФ ---------------------    
// ---------- Покупка --------
   MomBuy56M5=false;
   if (
         MomML_0<100 && 
         MomML_1<100 && 
         MomML_2<100 &&
         MomML_0>MomML_1 &&
         MomML_1<MomML_2 &&
         DeM5<0.3   
      )                                
         {   
            MomBuy56M5=true;
         }

// ---------- Продажа --------
   MomSell56M5=false;
   if (
         MomML_0>100 && 
         MomML_1>100 && 
         MomML_2>100 &&
         MomML_0<MomML_1 &&
         MomML_1>MomML_2 &&
         DeM5>0.7   // ... и тут ...
      )                                
         {   
            MomSell56M5=true;
         }      

//==============================================================================================
   // Вычисление основных торговых критериев
//====================================================================  
   if (
         MomBuy56M15==true &&
         MomBuy56M5 ==true
      )
      
      return(106);                       // Открытие Buy по стратегии 6 
 //====================================================================   
 
   if (
         MomSell56M15==true &&
         MomSell56M5 ==true
      )
      
      return(206);                       // Открытие Sell по стратегии 6 
 //====================================================================   

I wonder, if the result is similar, then why use momentum, which is good (as they say) for showing the moment of trend exhaustion (end)? When momentum breaks, the price kept going up and positions were opened at each new momentum break... So it was the early entries that I decided to lock...
What do you think about it?

 

you can't use zero bar in the tester, for the simple reason that despite the fact that it's only being formed (tester ticks) the tester has complete information about the prices of this bar, because it (the bar) is a fait accompli and the tester looks into the future taking data from the quotes history, not what it generates with ticks... shift one bar to the left and consider Momentums for 1,2,3 instead of 0,1,2 and demo 1 instead of 0...

It also makes sense to use only current m5 and multiply period where older prices are used. 14 * PERIOD_H1 / Period() and 14 * PERIOD_M15 / Period()

 
keekkenen:

you can't use zero bar in the tester, for the simple reason that despite the fact that it's only being formed (tester ticks) the tester has complete information about the prices of this bar, because it (the bar) is a fait accompli and the tester looks into the future taking data from the quotes history, not what it generates with ticks... shift one bar to the left and consider Momentums for 1,2,3 instead of 0,1,2 and demo 1 instead of 0...

It also makes sense to use only current m5 and multiply period where older prices are used. 14 * PERIOD_H1 / Period() and 14 * PERIOD_M15 / Period()

Why is it that if we print every close price of the zero bar in the tester, then on every tick the price is different? The same on higher timeframes, the same without visualization. So where is the visualisation?
 
well, if the result (dynamics) is not very different from that obtained using a zero bar, there may be no peek, but it is better to safeguard against illusions...
 

I've already racked my brains :) - here's the problem:

EA works in semi-automatic mode - its inputs are my outputs from positions, but I can not figure out - how to make the EA to make only one trade before my command for the next one, ie I just do not have a start/start button on the chart :) . My init() section is busy, and I can't disable my EA - its calculations are needed for correct trawling

 
keekkenen:
well, if the result (dynamics) is not very different from that obtained using a zero bar, there may be no peeking, but it is better to safeguard against illusions...
All illusions may be illusions, but by the end of 2008 all brotherhood of triggered Limits, faithfully adding depo, could not cope with drawdown, formed by positions opened using signals of indecks. :)

How is it possible to solve such problems?


Maybe there is some way to reduce such slippage? Your thoughts?

Reason: