Optimized the parameter on specific date

Hi Experts,

I would like to customize the parameters to find out crossover signal on specific date. For example, I am looking for the parameters which given cross signal of MACD and Signal line on 1/7/2021 or Sell on 1/8/2021.
Sorry, if this topic is available some where in the forum since I tried to search but couldn't find out.
It may be silly but I was starting with "optimize".

Please help.
Thank you in advance

mfast = Optimize( "MACD Fast", 12, 8, 16, 1 );
mslow = Optimize("MACD Slow", 26, 17, 30, 1 );
sigavg = Optimize( "Signal average", 9, 2, 20, 1 );


Buy = Cross( MACD( mfast, mslow ) , Signal( mfast, mslow, sigavg ) );
Sell = Cross( Signal( mfast, mslow, sigavg ), MACD( mfast, mslow ) );

If it's only 2 dates, the fastest way to do this is to plot the graph with a symbol on the desired dates, then plot the indicators and move manually the parameters until you get a signal on the date. The more variables used the easier will be.

Thank you for your response, but for the manually it is facing with problem if I expert to get the same parameter for both Buy and Sell signal on the two specific days.
From what I am thinking, great Amibroker must be have the solutions something like loop or other to solve out my issue.

Well, then you will have to get the indicator value in each trade, given that all trades were made with the same parameter. Have you searched for that in the forum ?

As informed earlier, I tried to search but couldn't find out.

Thanks.

mfast = Optimize( "MACD Fast", 12, 1, 16, 1 );
mslow = Optimize("MACD Slow", 26, 1, 30, 1 );
sigavg = Optimize( "Signal average", 9, 2, 20, 1 );

dt = DateTime();

ma_cd = MACD( mfast, mslow );
sig = Signal( mfast, mslow, sigavg );

Buy = Cross(ma_cd, sig) AND DateTimeDiff(dt,_DT("2021-07-01")) == 0;
Sell = Cross(sig, ma_cd) AND DateTimeDiff(dt,_DT("2021-08-01")) == 0;
Short = Cover = 0;

Exclude = mfast > mslow;
1 Like

Thank @fxshrat for your response, your suggestion helped me to figure out to catch the date of buy and sell. I will try to do the rest of works to get the parameters.

Hi @fxshrat,

Instead of optimize I am trying to get the value of pd1 and pd2 via exploration as :

dt = DateTime();

for (pd1 = 1; pd1 <=50; pd1 ++){
for (pd2 = 1; pd2 <=50; pd2 ++){

Buy  = Cross (MA(C,pd1),MA(C,pd2)) AND DateTimeDiff(dt,_DT("2021-07-01")) == 0;
Sell = Cross(MA(C,pd2),MA(C,pd1))  AND DateTimeDiff(dt,_DT("2021-08-01")) == 0;

}
}
Filter = Buy AND Sell;

......

then I don't know how to continue to get the value of pd1 and pd2 display in the exploration table.

Please to help.
Many thank

Exploration is not backtest/optimization.


If you want to do output of equity array per optimization variables then you might look here.
So first run optimization then run exploration.

1 Like

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