Phoenix Setting File Converters - page 2

 

after the lotsize is created, round up to the decimal place permitted. I'd prefer not adding any more variables to 5.7.x Phoenix if we can avoid it.

 
daraknor:
after the lotsize is created, round up to the decimal place permitted. I'd prefer not adding any more variables to 5.7.x Phoenix if we can avoid it.

I would rather not change the externals also. Instead, I can optimize it for the 5 currencies and then, leave only U_DecreaseFactor as the switch and turn the others into regular variables. I will use the pref settings to set all three values for these regular variables. These 3 variables can always be re-optimized as a third step, by making them external temporarily. First being signal, Second everything else, then these. I can also create default factors, for the other 5 currencies.

round up to the decimal place permitted.

How do you do that? lot = NormalizeDouble(lot,decimalPlaces);

 

question. I have 90% history for modeling quality and a test account set up.

but I can't get the default settings to backtest on firebird or the new setting. Any idea? i have the and allow live trading.

 
How do you do that? lot = NormalizeDouble(lot,decimalPlaces);

Use the greater value of either:

1/(10**decimalPlaces)

lot

 
daraknor:
after the lotsize is created, round up to the decimal place permitted. I'd prefer not adding any more variables to 5.7.x Phoenix if we can avoid it.

Here is the code. I see other people have coded this and I wanted to have my code remain consistent. I put the new proposed lotsize fixing code in blue. I can't see what is wrong with doing it this way.

//+------------------------------------------------------------------+

//| START MoneyManagement - Optimize lot size |

//+------------------------------------------------------------------+

double Y_MM_OptimizeLotSize()

{

if(U_MM==false) return(U_Lots);

//Dmitry_CH Modify 5.7.1 lotsize min/max and safe on more brokers

double lot =U_Lots;

int orders =HistoryTotal();

int i =0;

int trades =0;

int wins =0;

int losses =0;

int decimalPlaces=1;

if(MarketInfo(Symbol(),MODE_LOTSTEP)==1) decimalPlaces=0; //Dmitry_CH Add 5.7.1

if(U_AccIsMicro==true) decimalPlaces=2;

lot=NormalizeDouble(AccountFreeMargin()*U_MaxRisk/1000.0,decimalPlaces);

if(U_DecreaseFactor>0)

{

i =orders-1;

trades =0;

wins =0;

losses =0;

while (trades 0)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }

if(OrderSymbol()==Symbol() && OrderType()<=OP_SELL)

{

trades++;

if(OrderProfit()<0) losses++;

if(OrderProfit()>0) wins++;

}

i--;

}

if (losses==0){ lot=lot*100/100; }

if (losses==1){ lot=lot*80/100; }

if (losses==2){ lot=lot*20/100; }

if (losses>=3){ lot=U_MinLot ; }

}

// if(lot<0.1 && U_AccIsMicro==false) lot=0.1;

// if(lot<0.01 && U_AccIsMicro==true) lot=0.01;

// if(lot>99) lot=99;

if(lot<U_MinLot) { lot=U_MinLot; Print("lots switched to min ",lot); } //Dmitry_CH Add 5.7.1

if(lot>U_MaxLot) { lot=U_MaxLot; Print("lots switched to max ",lot); } //Dmitry_CH Add 5.7.1

lot = NormalizeDouble(lot,decimalPlaces);

return(lot);

}
 

I just looked over the code a second time. It looks fine.

One thing i'm trying to do to optimize my code is never divide by a constant value, always multiply by a decimal. Floating point multiplication is much faster than even integer based division, and in many cases the cast is done anyway to a float. In order to get precision on some platforms for some division, a weird set of bit shifting needs to be done to avoid irrational numbers. I don't do this right now, it is only something that can be done in C/C++/D anyway if I recall.

Instead of *80/100 you probably want to do *0.8 (removes 5-12 cycles off of the CPU)

 
daraknor:
I just looked over the code a second time. It looks fine.

One thing i'm trying to do to optimize my code is never divide by a constant value, always multiply by a decimal. Floating point multiplication is much faster than even integer based division, and in many cases the cast is done anyway to a float. In order to get precision on some platforms for some division, a weird set of bit shifting needs to be done to avoid irrational numbers. I don't do this right now, it is only something that can be done in C/C++/D anyway if I recall.

Instead of *80/100 you probably want to do *0.8 (removes 5-12 cycles off of the CPU)

I'm not sure you are looking at the latest code. Although I didn't have this *80/100 in my code I have plenty of integer division. I change integer division to decimal multiplication in 5.7.2.b and 5.7.2.w. I must say the code is much more confusing to understand the new way. I wonder how much time would be saved now in a big optimization. When I read about trades not being made because of " too much time", I know this is worth it.

 

It is something I want to focus on for Phoenix 6, not so much Phoenix 5.7 We can testing and see what the difference is between optimization sets. It will probably be very small, but sometimes you get big changes from something you thought would only be a minor difference. One of the larger performance increases in semi-compiled languages is the reduction of boxing/unboxing that occurs.

I'm going to make some structure changes in Phoenix 6 in the template I sent over, so we can quit computing each tick as quickly as possible. One thing we should probably do is profile optimization with different signals as the "primary filter" and see which one optimizes the fastest.

 
daraknor:
I'm going to make some structure changes in Phoenix 6 in the template I sent over,

By template do you mean some code. No.

If there is some code please tell me where to look? OK, I found the code.

It's a template . So how am I supposed to add it. Ok it goes in C:\Program Files\MetaTrader 4\templates.

Is it a Phoenix template or a general for all EAs?

Can I reformat it like 5.7.0? How about you reply in a private message for the last question.

How do you use a template?

 

Money Management with Multiple Expert Advisors

How can we add or subtract to the number of lots traded in an equal fashion as balance increases or decreases on a percentage basis on an Expert Advisor program like wujun1982's 5_7_2aH1 that has 6 different EAs on the same account? Right now the 5_7_2aH1 defaults to 1 Minilot on a standard Acct, .1 Minilot on a Mini Acct and with Micros set on a Mini Acct 0.03. What can be done with this many EAs trading at the same time? Can we, at least manipulate the numeric value of these trades manually to get the exact numbers we need instead of being satisfied with these static numbers mentioned above? Thanks for your help, Les

lehammondpsf@yahoo.com

Reason: