[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 279

 
snail09:
Throw the algorithm, in words, because it's a bit unclear...

Approximately as follows:

//determine the total number of trading days.

OrderSelect(0,SELECT_BY_POS,MODE_HISTORY);

Days=MathRound((TimeCurrent()-OrderOpenTime())/(3600*24) + 1);

then for the given period, calculate profit/days = %/day

I need to calculate weekend days for this entire period and exclude from the calculation:

profit/(days-off)

 

forexnew:

Approximately as follows:

//determine the total number of trading days.

OrderSelect(0,SELECT_BY_POS,MODE_HISTORY);

Days=MathRound((TimeCurrent()-OrderOpenTime())/(3600*24) + 1);

then for the given period, calculate profit/days = %/day

I need to calculate weekend days for this entire period and exclude from the calculation:

profit/(days-off)



Check that you have the necessary history for the period and calculate your "profit/days". Just don't use calendar (constants in your formula) and that's it. Only trading days go into the history(there are also public holidays). Bind yourself to the daily bars, for example.

If you specifically want to use a calendar (Gregorian or Julian, for example). What's the trick, there's a new bar, there's a new song?

 
forexnew:

Approximately as follows:

//determine the total number of trading days.

OrderSelect(0,SELECT_BY_POS,MODE_HISTORY);

Days=MathRound((TimeCurrent()-OrderOpenTime())/(3600*24) + 1);

then for the given period, calculate profit/days = %/day

I need to calculate weekend days for this entire period and exclude from the calculation:

profit/(days-off)



You can calculate the number of daily bars since the test start date.

You can count the number of daily bars with more than 20 hour bars (to exclude part days off) . You can track a new day as if a new bar appeared, and so on (like read the entire history of trades and calculate unique dates).

 
splxgf:

You can count the number of daily bars since the start date of the test.

You can count the number of daily bars with more than 20 hour bars (to exclude incomplete weekends) . You can track a new day as a new bar appears, and so on (like reading the entire history of trades and counting unique dates).

In any case"(3600*24) + 1)" is not an adequate construction, we should start from the number of bars.
 
snail09:

Check if you have the necessary history for the period and count your "profit/days". Just don't use calendar ones (constants in your formula) and that's it. Only trading days go into the history (there are also public holidays). Bind yourself to the daily bars, for example.

If you specifically want to use a calendar (Gregorian or Julian, for example). What's the trick, there's a new bar, there's a new song?

I have done it this way:

OrderSelect(0,SELECT_BY_POS,MODE_HISTORY);
Days=MathRound((TimeCurrent()-OrderOpenTime())/(3600*24));
for(i=0; i<Days; i++)
{
if(TimeDayOfWeek(CurTime()-i*24*3600)==6 || TimeDayOfWeek(CurTime()-i*24*3600)==7) Days3++;
}
Days-=Days3;

 
forexnew:

I did this:

OrderSelect(0,SELECT_BY_POS,MODE_HISTORY);
Days=MathRound((TimeCurrent()-OrderOpenTime())/(3600*24));
for(i=0; i<Days; i++)
{
if(TimeDayOfWeek(CurTime()-i*24*3600)==6 || TimeDayOfWeek(CurTime()-i*24*3600)==7) Days3++;
}
Days-=Days3;

no, with this orderselect you select orders in the history (ONE time), then go only one (the last one). Isn't anything confusing?

Do an order search in the loop, and apply your conditions to each order.

// Search all the orders in the loop

for(int i=0;i<=OrdersTotal();i++)

{

if(OrderSelect(i,SELECT_BY_POS, MODE_HISTORY))

{

// If the symbol and the magic number match, the order is ours

if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)

{

// Check here.

}

}

}

 
snail09:

No, with this orderselect you select orders in the history (ONE time), then go only to one (the last one). Isn't anything confusing?

Go through the orders in the loop, and apply your own conditions to each order.

// Search all the orders in the loop

for(int i=0;i<=OrdersTotal();i++)

{

if(OrderSelect(i,SELECT_BY_POS, MODE_HISTORY))

{

// If the symbol and the magic number match, the order is ours

if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)

{

// Check here.

}

}

}

Why do I need warrants? I just need to identify one-off days of the week that are not trading, i.e. Saturday and Sunday subtracted from the total number of days.
 

Well, of course I got it wrong:

TimeDayOfWeek(CurTime()-i*24*3600)==7

instead of 7 it should be 0.

Checked, on accounts that are over a week old. It seems to show correctly.

 

How is the iMA calculated?


avatar
90
Eugene1 20.10.2011 16:34

Is there anywhere I can find how iMA function is calculated (or is it classified)?

Especially I am interested in MODE_LWMA.

I want to look and tweak to my liking, but something google sources did not get

 
forexnew:

Well, of course I got it wrong:

TimeDayOfWeek(CurTime()-i*24*3600)==7

instead of 7 it should be 0.

Checked, on accounts that are over a week old. It seems to show correctly.

Well, don't, so don't. If your expert is not in control of his orders, so what is he doing anyway? ...Trading in a tester?
Reason: