[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 279
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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)
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?
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).
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).
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;
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.
}
}
}
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.
}
}
}
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?
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
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.