Is this the right way for optimizing indicator

Hi all AB coders
if I used the optimization for watching list around 20 symbols it will take around 3 days
for individual symbol around 2 minutes

//////////////////////////////////////////////    MACD OPT SETING    ////////////////////////////////////////////////////////
OptimizerSetEngine("cmae");
M_FAST = 12 ;
M_SLOW = 26 ;
M_SIG = 9 ;


function ParamOptimize ( description, defaultVal, minv, maxv, step )
{
    return Optimize( description, Param( description, defaultVal, minv, maxv, step ), minv, maxv, step );
}

///////*****************************************************************************************************//////////
///////*****************************************************************************************************//////////
///////***********************************         MACD OPT       ******************************************//////////
///////*****************************************************************************************************//////////
///////*****************************************************************************************************//////////


MACD_FAST = ParamOptimize ( "MACD Fast", M_FAST, 8, 20, 1 );
MACD_SLOW = ParamOptimize ("MACD Slow", M_SLOW, 17, 35, 1 );
MACD_SIG = ParamOptimize ( "Signal average", M_SIG, 2, 25, 1 );

MACD_FAST_MultiMA = EMA(C,MACD_FAST)  ;

MACD_SLOW_MultiMA = EMA(C,MACD_SLOW) ;

MACD_line = MACD_FAST_MultiMA -  MACD_SLOW_MultiMA  ;
MACD_signal_line = EMA(MACD_line,MACD_SIG)  ;
MACD_zero_line  =  MACD_line -  MACD_signal_line ;



///////*****************************************************************************************************//////////
///////*****************************************************************************************************//////////
///////***********************************         RSI OPT        ******************************************//////////
///////*****************************************************************************************************//////////
///////*****************************************************************************************************//////////

RSI_period = 14 ;
Low_level_RSI = 30 ;
HI_LEVEL_RSI = 70 ;
RSI_per_opt = ParamOptimize ( " RSI period ", RSI_period, 3, 30, 1 );
RSI_OPT_INDC = RSI ( RSI_per_opt ) ;


///////*****************************************************************************************************//////////
///////*****************************************************************************************************//////////
///////***********************************   Stochastic RSI OPT   ******************************************//////////
///////*****************************************************************************************************//////////
///////*****************************************************************************************************//////////

StochRSI_period = 14 ;
Low_level_StochRSI = 30 ;
HI_LEVEL_StochRSI = 70 ;
StochRSI_per_opt = ParamOptimize ( " StochRSI period ", StochRSI_period, 3, 30, 1 );
Min_RSI_per_opt = ParamOptimize ( " MINRSI period ", StochRSI_period, 3, 30, 1 );
MAX_RSI_per_opt = ParamOptimize ( " MAXRSI period ", StochRSI_period, 3, 30, 1 );
Min_RSI = Min(RSI(StochRSI_per_opt),Min_RSI_per_opt) ;
MAX_RSI = Max(RSI(StochRSI_per_opt),MAX_RSI_per_opt) ;
StochRSI_OPT_INDC = ( RSI_OPT_INDC - Min_RSI ) / ( MAX_RSI - Min_RSI ) ;





///////*****************************************************************************************************//////////
///////*****************************************************************************************************//////////
///////***********************************         MFI OPT        ******************************************//////////
///////*****************************************************************************************************//////////
///////*****************************************************************************************************//////////

MFI_period = 14 ;
Low_level_MFI = 30 ;
HI_LEVEL_MFI = 70 ;
MFI_per_opt = ParamOptimize ( " MFI period ", MFI_period, 3, 30, 1 );
MFI_OPT_INDC = MFI ( MFI_per_opt ) ;

Buy  = ( MACD_line AND MACD_signal_line < MACD_zero_line AND Cross( MACD_line , MACD_signal_line ) ) OR ( RSI_OPT_INDC < Low_level_RSI ) OR ( MFI_OPT_INDC < Low_level_MFI ) 
       OR ( StochRSI_OPT_INDC < Low_level_StochRSI )  ;
Sell = ( MACD_line AND MACD_signal_line > MACD_zero_line AND Cross( MACD_signal_line , MACD_line ) ) OR ( RSI_OPT_INDC > HI_LEVEL_RSI ) OR ( MFI_OPT_INDC > HI_LEVEL_MFI ) 
       OR ( StochRSI_OPT_INDC > HI_LEVEL_StochRSI )  ;
Filter = 1 ;
AddColumn( MACD_FAST, "MACD_FAST", 1.2 );
AddColumn( MACD_SLOW, "MACD_SLOW", 1.2 );

in buy and sell conditions I but the basic ones only

thank you

Unfortunately your question isn't clear enough and does not provide all necessary details to give you an answer. Please follow this advice: How to ask a good question

You did not explain what you really want. What is your GOAL? You ask about right way. In what sense? What do you expect to hear from people here?

i did optimization system for many indicators as you can see above.

like

and I use

what I did is it the right way using the ( ParamOptimize ) .

thank you

this for watchlist

and 2 minuets and it show me 2 days

for current

less than 3 minuets

watchlist filter

 Buy  = ( MACD_line AND MACD_signal_line < MACD_zero_line AND Cross( MACD_line , MACD_signal_line ) ) OR ( RSI_OPT_INDC < Low_level_RSI ) OR ( MFI_OPT_INDC < Low_level_MFI ) 
       OR ( StochRSI_OPT_INDC < Low_level_StochRSI )  ;
Sell = ( MACD_line AND MACD_signal_line > MACD_zero_line AND Cross( MACD_signal_line , MACD_line ) ) OR ( RSI_OPT_INDC > HI_LEVEL_RSI ) OR ( MFI_OPT_INDC > HI_LEVEL_MFI ) 
       OR ( StochRSI_OPT_INDC > HI_LEVEL_StochRSI )  ;
       
watchlistCheck = InWatchListName( "MyOptimizList" ) ;

thank you

You did NOT ASK any question in your last post.

I guess that what you intended to ask was: "why estimated completion time varies?"
but again, you did not ask any question, so it is answering the question that was never asked.

Anyway, as it is too obvious for me and I am not really keen to explain for Nth time the absolute basics, I left it to ChatGPT to explain you why estimated time varies if you are using non-exhaustive optimization (you are using CMA-ES).

Here is what it said:

When an application displays a progress indicator for non-exhaustive optimization, it is trying to give the user an estimate of how much time is remaining until the optimization process is complete. However, this estimation can be a wild guess, especially for optimization techniques such as particle swarm optimization or CMA-ES, which may terminate sooner when a convergence point is reached.

The progress indicator typically works by dividing the optimization process into smaller steps and tracking the completion of each step. For example, if the optimization process requires a million steps, the progress indicator may update every thousand steps to show how much of the process is complete.

However, estimating the time remaining based on completed steps can be challenging because the time required for each step may vary widely. Some steps may require only a fraction of a second, while others may take minutes or even hours. Additionally, optimization algorithms such as particle swarm or CMA-ES can converge quickly or slowly, depending on the problem being solved and the settings used.

As a result, the time estimation for a progress indicator is often a rough estimate that is subject to change as the optimization process progresses. It is important for users to understand that the estimate is not always accurate and may vary widely from the actual time required to complete the optimization.

Overall, the progress indicator is a useful tool for providing users with an idea of how much progress has been made during an optimization process. However, it is important to keep in mind that the estimate is not always accurate, especially for non-exhaustive optimization techniques that may terminate sooner than expected.

Now if the question is what you typed in subject line "is this the right way for optimizing indicator" then the answer is you are not optimizing indicator. You are finding optimum parameters for combination of a couple of indicators. Not one indicator but multiple and you are combining the results. Trouble is that the way you combine them causes that your system generates ZERO TRADES which is clearly shows on your screenshot. General advice is start with SIMPLE thing that you can understand, then add pieces one by one, not everything at once. And it has nothing to do with Optimization. The "system" is simply wrong. Your Buy Statement consist of mutually contradictory parts.

To get better understanding of what is happening in your code and how functions work, use advice given here: How do I debug my formula?

1 Like

Yes, that's what I meant
The results of optimization a group of indicators are different from optimization the results of a single indicator
Is it possible to make an optimization for several indicators in one code ?

thank you

Again: you are NOT optimizing group of indicators. What your formula does is this:

 Buy  = ( MACD_line AND MACD_signal_line < MACD_zero_line AND Cross( MACD_line , MACD_signal_line ) ) OR ( RSI_OPT_INDC < Low_level_RSI ) OR ( MFI_OPT_INDC < Low_level_MFI ) 
       OR ( StochRSI_OPT_INDC < Low_level_StochRSI )  ;

you are AND/ORing conditions coming from different indicators. Trouble is that this expression is self-contradictory and apparently never met. If you don't understand ask ChatGPT what it means and it will explain to you.

You need to DEBUG this expression as I wrote before. Split it into individual parts and display in exploration.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.