[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 10

 
volshebnik:
As much as I've tried Code Base, nothing has been profitable (I haven't quite got through it yet). Otherwise, I would have bet on it for real by now. In optimization - good, in the test - bad. Just this search of all MAs in optimization, as it seems to me, will give the best variant of my strategy while there are MA (5), MA(12), MA(18), MA(23) and MA(28). But these may not be the best MAs. And, instead of dealing with each of them (also their intersections), wouldn't it be easier to run a genetic algorithm in optimization to select the best MAs ? So that's the question that came up in my previous post.

I think the logic of the solution is lame there. Formulate the problem correctly (you can do it without your code), abstract from it a bit and write the conditions of the problem clearly...
 
Roman.:

The logic of the solution is lame there, in my opinion. Formulate the problem correctly (you can do it without your code), abstract from it a bit and write the conditions of the problem clearly...
The problem: We wait for the break of MA, then the first fractal. Breach of the first fractal is a signal for the trade. But with different MA periods, fractals may be in different places (by time) because, depending on the period and type of smoothing, some МАs "break" earlier and others later and, correspondingly, signals to a trade are different. So I want to try all МА to find out the one that gives the best (more profitable) signal (if it is correct at all, I cannot assert yet). I want to search and run through each MA of 50 periods, and with 4 options - eksponential, smoothed, etc. - very-very long. If we transfer the МА period, TP and SL to an external variable in the optimization, we will immediately see what is better. But I can't optimize beyond МА period = 7 for some reason. So I am looking for some help.
 
volshebnik:
The task: we wait for the break of the MA, then the first fractal. The penetration of the first fractal is a signal for the transaction. But with different periods of MAs fractals may be in different places (by time) because, depending on the period and type of smoothing, some MAs "break" earlier, others - later and, accordingly, signals to the trade - different. So I want to try all МА to find out the one that gives the best (more profitable) signal (if it is correct at all, I cannot assert yet). I want to search and run through each MA of 50 periods, and with 4 options - eksponential, smoothed, etc. - very-very long. If we transfer the МА period, TP and SL to an external variable in the optimization, we will immediately see what is better. But I can't optimize beyond the МА period = 7 for some reason. So I'm looking for some help.


Solution:

I will give for buy (sell - by analogy):

1. MA fracture - get MA values on bars 3, 2 and 1 - compare. If MA values on bars 3>2 and 2<1, it is a break.

2. then - fractal - penetration - a signal to make a deal

   
   double fractal_l;
   double fractal_h;
     
   fractal_h = iFractals(Symbol(),PERIOD, MODE_UPPER, 3);
   if(fractal_h!=0)  upfractal=iFractals(Symbol(), PERIOD, MODE_UPPER, 3); 
   
   fractal_l = iFractals(Symbol(), PERIOD, MODE_LOWER, 3);
   if(fractal_l!=0)  dwfractal=iFractals(Symbol(),PERIOD, MODE_LOWER, 3); 

   if (Ask > upfractal) {открытие ордеров при пробитии последнего (свежайшего) фрактала }


As far as the enumeration of MA is concerned - place it in external (optimizable) variables:

Period_MA (you can set from 2 to 240 in increments of 2), MODE - (method of МА calculation - range of changes 0 to 3 step 1), PRICE_TYPE -(price constant - range of changes 0 to 6 step 1), I heard that when working within the day MA should be calculated using average values (close price is not important), when working on the daily candles MA should be calculated by day close prices.

PERIOD - you change it manually with each subsequent optimization - 1,5,15,30,60,240...

Press F1 on the iMA - carefully read everything there again.

Well, and of course TP and stop loss optimize as usual.

 double MA_1 = iMA(Symbol(),PERIOD,Period_MA,0,MODE, PRICE_TYPE, 1);
 double MA_2 = iMA(Symbol(),PERIOD,Period_MA,0,MODE, PRICE_TYPE, 2);
 double MA_3 = iMA(Symbol(),PERIOD,Period_MA,0,MODE, PRICE_TYPE, 3);
P.S. Don't forget to write an information on the test results... :-)))
 
Roman, thank you very much ! I will compare it with my EA. I will be sure to report on the test results. Your work will not go to waste. Your previous martingale offer is in my research queue, if I am close to the grail )) I will also let you know.
 
volshebnik:
Roman, thank you very much ! I will compare it with my EA. I will be sure to report on the test results. Your work will not go to waste. Your previous martingale offer is in my research queue, if I am close to the grail )) I will also let you know.

Sense, we are waiting...
 
I wonder how the OrderModify() function will work if the "price" parameter is set differently than it was? For example, there was OrderPrice=1.3200, and in the OrderModify function let's set it to 1.3300. Who knows? (myself in practice and in the tester did not have to check, sorry)
 
ikatsko:
I wonder how the OrderModify() function will work if the "price" parameter is set differently than it was? For example, there was OrderPrice=1.3200, and in the OrderModify function let's set it to 1.3300. Who knows? (I haven't checked it myself in practice and in the Strategy Tester, sorry)

change the open price of a pending order if the order type allows it
 
abolk:

If the order type allows it, it will change the opening price of the pending order

What do you mean "if the order type allows"? An open order may be of BUY or SELL type.

Suppose the order changes the price, but where would it spend the difference? On the plus or minus balance? Is it so? And there will be the spread, too? So, the old order (spread) is closed and the new one is opened?

 
ikatsko:

What do you mean "if the order type allows"? An open order may be of BUY or SELL type.

Suppose the order changes the price, but where would it spend the difference? On the plus or minus balance? Is it so? And there will be the spread, too? So, the old order (spread) is closed and the new one is opened?

The function will only be able to change the price at which the pending order is set. If you try to change the open price of the market order, this function will return an error, something like "Invalid function parameter". You can find more details in help of this function - I am too lazy to give you links as I am too sleepy... :)
 
artmedia70:
This function will only be able to change the pending order open price. If you try to change the open price of the market order, this function will return an error, something like "Invalid function parameter". Please see more details in this function help - I am too lazy to give you links as I am too sleepy... :)

Yes, thank you for your attention! I was too lazy to look and wrote a question. Sorry. BUT did look and figured it out (without experimenting). price - new price for pending order or opening price for market order. Good night!

Reason: