Coding help - page 407

 

Hello Guys, I need your help on an indicator I made. Basically, it is a tester that is supposed to be used only for optimizing settings of a strategy (and also test its performances). In testing mode (Optimize turned to False), it works great and gives the win rate and balance for the default parameters. But I have trouble making the optimization function work. The result for best settings always ends up to be the lower value (PeriodMin). I wonder if it's the way I'm using the buffers declared inside the Optimization double function (see lines 616 and 617, and lines 746 and 747 used to free the buffers). I guess it's not only that, because if I don't use these buffers (by turning AllowMultipleOpenTrades to False), it still gives not coherent results. If anyone can have a look and help, I'd be gratefull. Thanks very much.

Files:
 
airquest:
Not sure what you're trying to make. Maybe this ?

No i'm afraid not. Let me illustrate with a screenshot. At the pink upper arrow you can clearly see that the red bar of the LOW is allot larger then the blue bar of the HIGH. Yet the corresponding output in the Linear Bar Diff indicator is above zero!! (see lower pink arrow). When the red bar Low bar is larger then the blue High bar the difference of both bars should be negative, not positive. The green arrows show another example of the same problem.

Kind regards

Files:
example.png  25 kb
 
mrcodix:
No i'm afraid not. Let me illustrate with a screenshot. At the pink upper arrow you can clearly see that the red bar of the LOW is allot larger then the blue bar of the HIGH. Yet the corresponding output in the Linear Bar Diff indicator is above zero!! (see lower pink arrow). When the red bar Low bar is larger then the blue High bar the difference of both bars should be negative, not positive. The green arrows show another example of the same problem. Kind regards

So maybe this ? You need to see that the buffers 3 and 4 are not related to High VS Open and Low VS Open, but to Close VS Open.

 
mrcodix:
No i'm afraid not. Let me illustrate with a screenshot. At the pink upper arrow you can clearly see that the red bar of the LOW is allot larger then the blue bar of the HIGH. Yet the corresponding output in the Linear Bar Diff indicator is above zero!! (see lower pink arrow). When the red bar Low bar is larger then the blue High bar the difference of both bars should be negative, not positive. The green arrows show another example of the same problem. Kind regards

Or this is with the choice of using High/Low VS Open or Close VS Open.

 
airquest:
Hello Guys, I need your help on an indicator I made. Basically, it is a tester that is supposed to be used only for optimizing settings of a strategy (and also test its performances). In testing mode (Optimize turned to False), it works great and gives the win rate and balance for the default parameters. But I have trouble making the optimization function work. The result for best settings always ends up to be the lower value (PeriodMin). I wonder if it's the way I'm using the buffers declared inside the Optimization double function (see lines 616 and 617, and lines 746 and 747 used to free the buffers). I guess it's not only that, because if I don't use these buffers (by turning AllowMultipleOpenTrades to False), it still gives not coherent results. If anyone can have a look and help, I'd be gratefull. Thanks very much.

airquest

Your arrays recTP[] and recSL[] at line 602 are not resized (they are size 0, the way they are declared at the beginning of the loop), Try resizing them before the for() loop

 
airquest:
Or this is with the choice of using High/Low VS Open or Close VS Open.

No this is what i ment.

int start()

{

int counted_bars=IndicatorCounted();

int i;

//int UpDays, DownDays, NeutralDays;

double BarH, BarL, BarC;

//----

for(i=0; i<Bars; i++)

{

BarH = High - Open;

BarL = Open - Low;

BarC = Close - Open;

//if(BarC>0) UpDays +=1;

//else if(BarC<0) DownDays +=1;

//else if(BarC==0) NeutralDays +=1;

ExtMapBuffer1 = BarH;

ExtMapBuffer2 = BarL;

ExtMapBuffer5 = BarH - BarL;

}

//----

return(0);

}

I kinda figured it out myself now but thanks for the effort anyway.

Can anyone tell me why this indicator: Candles Ratio » Metatrader Files does not show the output for the last few candlesticks?? It doesen't appear to do that in the picture thats shown.

 
mladen:
airquest Your arrays recTP[] and recSL[] at line 602 are not resized (they are size 0, the way they are declared at the beginning of the loop), Try resizing them before the for() loop

Thanks Mladen, I did it, but still the optimization does not give correct results. If I turn Optimize to True, it gives the lowest value as the best setting (band period = 5), while on False and default BandsPeriod on 40, for example, it shows a better win rate than with 5. basically the idea of the optimization is to find which settings give the best win rate. I've re-read the code hundred times and can't find what's wrong. if you have any idea, otherwise maybe it's a lost cause lol.

This is with the ArrayResize added. Also fixed some bugs, but still not giving same results as without optimization:

Files:
 
airquest:
Thanks Mladen, I did it, but still the optimization does not give correct results. If I turn Optimize to True, it gives the lowest value as the best setting (band period = 5), while on False and default BandsPeriod on 40, for example, it shows a better win rate than with 5. basically the idea of the optimization is to find which settings give the best win rate. I've re-read the code hundred times and can't find what's wrong. if you have any idea, otherwise maybe it's a lost cause lol. This is with the ArrayResize added. Also fixed some bugs, but still not giving same results as without optimization:

Not sure why, but when checking results by writing a CSV file, the total trades, wins and balance are multiplied by a factor of 10 : http://clip2net.com/s/38YHODl ...

 
airquest:
Not sure why, but when checking results by writing a CSV file, the total trades, wins and balance are multiplied by a factor of 10 : Microsoft Excel - BB+CCI_FX-EURUSD-H1-SA-1.csv ...

airquest

As far as I see total trades and wins are OK (otherwise they would have to end in 0)

 
mladen:
airquest As far as I see total trades and wins are OK (otherwise they would have to end in 0)

Well, still... Here are some tests :

- Default settings (no optimization, WriteCSV to True) : http://clip2net.com/s/38YSV53

- Optimize set to True, PeriodMin to 20 and PeriodMax to 20 : http://clip2net.com/s/38YT2hN

The first one gives coherent values (CSV file and screen results match). That's normal, because both comes from the same variables. But in the second one, opti results are multiplied almost by 10 compared to screen results. Though, they should end up in the same results...

Anyway, no hurry, maybe with time I'll find out what's wrong. Thanks for your kind help Mladen.

Reason: