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

 
nuan:

The charter means that it closes the order in the same second, not in 30 minutes.


I have put in the code as in your example


The robot does not close for other reasons, i.e. it does not close on stop or on profit.


1 2011.07.29 00:00 buy 1 0.01 1.4328 1.3328 1.5328 0.00 1000.00
2 2011.07.29 00:01 close 1 0.01 1.4327 1.3328 1.5328 -0.10 999.90
3 2011.07.29 00:01 buy 2 0.01 1.4329 1.3329 1.5329 0.00 999.90
4 2011.07.29 00:01 close 2 0.01 1.4326 1.3329 1.5329 -0.30 999.60
5 2011.07.29 00:01 buy 3 0.01 1.4328 1.3328 1.5328 0.00 999.60
6 2011.07.29 00:03 close 3 0.01 1.4327 1.3328 1.5328 -0.10 999.50
7 2011.07.29 00:03 buy 4 0.01 1.4329 1.3329 1.5329 0.00 999.50
8 2011.07.29 00:03 close 4 0.01 1.4329 1.3329 1.5329 0.00 999.50


Put it all at the very end of the start() function. Your operations should come before it.

datetime TimeM30=iTime(NULL,30,0);
    if(TimeM30==prevtime) return(0); 
    prevtime = TimeM30;   
    CloseAllPosTime();
 
nuan:
Replace in start() with this option:
 datetime CloseTime;
//=====================
 int start(){

   if(TimeCurrent()-CloseTime > 30*60){CloseAllPos();CloseTime=TimeCurrent();}//Можно поставить в любом месте функции старт.
  return(0);
 }
//====================
 
forexnew:

I get it.

What if you consider opening an account with $0 as a start, and the 1st top-up as a top-up. Is it possible to determine programmatically all refills (including the first one) that were made to the account?


:-Р

You're rowing in the wrong direction... :-)))

There is a function

double AccountBalance( ) 

with its help you define the state of your account balance by closed trades at some moment of time.

Then - let's assume that you have entered the market - floating deficit on your account with open positions, and then you deposit funds into your account... Here we should determine the amount of split (if there is one) to correct the volume (upwards) of opened positions in order to keep the initial "tolerance" to drawdown/profit, say, in percentage points of the capital, from which the volume of "initial" market positions (before split) was calculated. What is the solution to this issue?

 
CloseTime 
Нужно задавать этот параметр? если да то как?
 
nuan:


Don't. It is an "intermediate" time variable, always equal to the last closing time.

The operating time is set in seconds. In your case it is 30*60.
You can replace 30 with some variable, say, exstern int closetime = 30.
Then the time will look like this: closetime*60.

 
charter:


Don't. It is an "intermediate" time variable, always equal to the last closing time.

The operating time is set in seconds. In your case it is 30*60.
You can replace 30 with some variable, say, exstern int closetime = 30.
Then the time will look like this: closetime*60.

Just tried the same, is at the end of the body start.... I don't understand why it's like this. Is there any other option?
 
Roman.:


:-Р

You're rowing in the wrong direction... :-)))

There is a function

with its help you determine the state of balance of your trading account for closed trades at some point in time.

Then - let's assume that you have entered the market - floating deficit on your account with open positions, and then you deposit funds into your account... Here we should determine the amount of split (if there is one) to correct the volume (upwards) of opened positions in order to keep the initial "tolerance" to drawdown/profit, say, in percentage points of capital, from which the volume of "initial" market positions (before split) was calculated. What is the solution to this issue?


If you initially determined the ratio of the StartBalance (starting balance) to StarLots (starting lot) according to the specified risks, then the equity value should be determined:

if(AccountEquity()<StartBalance) Top-up = (AccountBalance()+(StartBalance-AccountEquity()))*New Lot/StarLots

This is excluding AccountCredit(). If I understand you correctly, of course.

 
nuan:
Just tried the same thing, is at the end of the body start.... I don't understand why this is the case. Maybe there's another option?
Look for an error in something else.
Both options should work.
 
thanks a lot!
 

Hello, everyone. I have a question for you. I need to find the nearest maximum and minimum. But that they should be within + - 10 points of Open[0];

I have it like this now:

for (int i=1;i<100;i++)

if (High[i+1]<High[i] && High[i]>High[i-1] break;

it finds the closest maximum,

If I add the comparison High[i]>(Open[0]+0.0010) and High[i]<(Open[0]+0.0020) this is what it looks like

if (High[i+1]<High[i] && High[i]>High[i-1] && High[i]>(Open[0]+0.0010) && High[i]<(Open[0]+0.0020) break;

The program fetches the wrong maximum.What's the problem?

I haven't tried the minimum yet.

Reason: