Useful features from KimIV - page 38

 
obabuev писал (а) >>
How to add int b to string Time2 minutes now or how to plus minus make it random
void start() {
  int a=MathFloor(MathRand()/32767.0*300);
  int b=-MathFloor(MathRand()/32767.0*300);
  Comment("a=",a," b=",b,"\n",
          "плюс ",TimeToStr(TimeLocal()+a, TIME_SECONDS),"\n",
          "минус ",TimeToStr(TimeLocal()+b, TIME_SECONDS));
}
 

Please advise on the existing methods to limit the number of orders:

1) how to link the number of orders to the available balance, so that there is a dynamic, for example, if available funds are less than half the balance, then the limit is triggered

2) How to limit the number of simultaneous orders to a fixed value, e.g. 10

 
KimIV писал (а) >>
Thank you Igor,
It's very simple and easy to code, like all the professionals.
Only, I never thought I'd be unable to explain it in words, let alone write the code.
What I need is for random shift to come from one oscillator but randomly in both directions.
For example, like pointer oscillating near zero (going down then up).
And this my zero, or the average value will be my set time.
How do I divide all randomness into two parts in the middle?
Will it work like this?
void start() {
int a=MathFloor(MathRand()/32767.0*300);
if (a > 150) a=-a;
Comment("a=",a,"\n",
"plus or minus ",TimeToStr(TimeLocal()+a, TIME_SECONDS) );
}
Also, I'm trying to do this thing in an indicator.
Will TimeToStr(TimeLocal()+a,TIME_SECONDS) be correct or should TimeToStr(Time[i] +a,TIME_SECONDS) or TimeToStr(iTime(NULL,0,i)+a) or ????
>>Thank you for your help.
 
obabuev писал (а) >>
I need random shift to happen from one oscillator but in both directions randomly.
It's like the oscillating hand near zero (going up and down).
And this my zero, or the average value will be my set time.
Somehow everything must be divided into two parts by chance in the middle or what?

Then it's like this:

void start() {
  int a=MathFloor(MathRand()/32767.0*300)-150;
  Comment("a=",a,"\n",
          "плюс-минус ",TimeToStr(TimeLocal()+a, TIME_SECONDS));
}
obabuev wrote (a) >>
Would TimeToStr(TimeLocal()+a,TIME_SECONDS) be correct or should TimeToStr(Time[i] +a,TIME_SECONDS) or TimeToStr(iTime(NULL,0,i)+a) or ????

How do I know what is right and what is wrong? Only you can know that. I will only explain which code means what, and you decide for yourself what you need and what is right for you.

TimeToStr(TimeLocal()+a,TIME_SECONDS)

You add a seconds to the local time in seconds and the result is converted into a string.

TimeToStr(Time[i] +a,TIME_SECONDS)

We add a seconds to the opening time of the i-th bar and the result is converted into a string.

TimeToStr(iTime(NULL,0,i)+a)
A seconds is added to the opening time of the i-th bar on the current chart in seconds and the result is converted into a line.
 
AlexDub писал (а) >>

Please advise on the existing methods to limit the number of orders:

1) how to link the number of orders to the available balance, so that there is a dynamic, for example, if available funds are less than half the balance, then the limit is triggered

2) How to limit orders number to a fixed amount, for example 10

if (AccountFreeMargin()<AccountBalance()/2.0) {
  // срабатывает ограничение
}
AlexDub wrote (a) >>
Can you please tell me which methods to use to limit orders number:
2) how to limit the number of simultaneous orders to a fixed value, e.g. 10
if (OrdersTotal()>=10) {
  // срабатывает ограничение
}
 
KimIV писал (а) >>

>> Then it's like this:

>> Thank you,
>> a monument to you.

 
obabuev писал (а) >>

You need a monument.

Not yet :))

 
Then a bronze bust at home... ;)
 

How kind everyone is! You might as well shoot yourself

 

Well, at least the bust is a good thing...

They should have put it up for two heroes of the USSR in their lifetime.

At the expense of the state... :)))

Reason: