Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1154

 
Андрей Касторский:
.. Whoever needs help to write an EA, you can email me. I will help

help take the price from zero bar, here is the discussion

https://www.mql5.com/ru/forum/160683/page237#comment_5350688

 
Alexey Viktorov:

A flimsy example gives rise to a flimsy answer. To understand, you have to understand what the percentages are measured against.

Got it.

I'll try to be clearer.

My code is originally written in the following way:

extern double StopLoss =0;

extern double TakeProfit =0;

extern double SL_PERCENT = 0.02;

extern double TP_PERCENT = 0.03;

extern double TRALL_PERCENT = 0.01;

extern double Lots =0.5;


Ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,NormalizeDouble(OrderOpenPrice+(OrderOpenPrice + StopLoss)/100*SL_PERCENT,Digits),NormalizeDouble(OrderOpenPrice-(OrderOpenPrice - TakeProfit)/100*TP_PERCENT,Digits),",Magic,0,Red);

StopLoss is triggered but not by 0.02% but by 0.43%, which is incorrect. I don't know about TakeProfit as I've never tried it before, but it seems to be incorrect too.

I have some suggestions that the code is not correct.

One more thing, maybe it is important. My orders are opened for all of my depo for 3-4 pairs. Sometimes by five.


Also I want to change such parameters as StopLoss, Takeprofit, TrailingStop in percent, not in points.

For example,

1) Takeprofit=OrderOnProfit+%TP_PERCENT

2) Stoploss=OrderOnPrice-%SL_PERCENT

I.e.

ticket=OrderSend(Symbol(),OP_BUY,1,Ask,0,%,%,",Magic,0,clrGreen);


I don't know how to modify it further for trailing purposes.

I took a sample from the tutorial, but I am obviously doing something wrong.

3.) TrailingStop=Bid-%TRALL_PERCENT

case 0: // Buy order

if (NormalizeDouble(OrderOpenPrice-SL*Point,Digits)*SL_PERCENT/100<=(OrderOpenPrice-Ask) // If below

NormalizeDouble(Bid-(Bid-TS)/100*TRAL_PERCENT,Digits)

|| NormalizeDouble(SL,Digits)==0)

{

SL=Bid-TS*Point; //then modify it

string Text="Buy "; // Text for Buy

Modify=true; // assigned to modify.

}


I really hope I was able to explain.

Thank you.

 

How to correctly implement the opening of a deal ( OrderSend) strictly at the beginning of the candle - OnTimer and/or OnTick,

In order not to overload the terminal (20-30 charts open and tracked simultaneously)?

it was found out that the delay in the appearance of a new tick at the beginning of a candlestick can be up to 5-10 seconds; the gap with the previous tick is significant (negative for transaction conditions)

p.s. at the same time in the Expert Advisor it is supposed to notify about a possible deal 1-2 minutes before the deal opening, i.e. before the beginning of a candle opening.

 
maxsoft:

How to correctly implement the opening of a deal (OrderSend) strictly at the beginning of the candle - OnTimer and/or OnTick,

in order not to overload the terminal (20-30 charts open and tracked simultaneously)?

It was found out that the delay in the appearance of a new tick at the beginning of a candle can be up to 5-10 seconds with a significant gap to the previous tick (it is negative for deal conditions)

p.s. in this case, in the Expert Advisor it is supposed to preliminary inform about a possible deal 1-2 minutes before the deal opening, i.e. before the beginning of a candle opening.

You need to view all open charts in the timer to see if a new bar appears.

You have to create an array of pointers to instances of classes - one class for each timeframe of each open chart.

The class that will monitor the opening of a new bar can be found in this article.

Open the chart - add it to the array of open charts. Close the chart - delete it from the array.

In the loop in the timer you pass through an array of pointers to instances of classes and check the fact of opening of a new bar, which the class will return in case of formation of a new bar.

 
Artyom Trishkin:

You need to view all open charts in the timer to see if a new bar appears.

You have to create an array of pointers to class instances ...

How about using MQL4?

And what to do with - "...it's supposed to preliminary notify about a possible deal 1-2 minutes before the deal opening, i.e. before a candle opens...", i.e. inside a bar

 

Welcome to the topic https://www.mql5.com/ru/forum/208120#comment_5412193

Can't find a consensus.

Играем в блиц ЧТО? ГДЕ? КОГДА? 3 вопроса по 20 секунд
Играем в блиц ЧТО? ГДЕ? КОГДА? 3 вопроса по 20 секунд
  • 2017.07.07
  • www.mql5.com
Народ, подскажите пожалуйста, заморочился я тут по поводу AccountBalance() и AccountLeverage(). 1...
 

Before displaying the doubl type, I normalise it to 2 decimal places, but sometimes it doesn't work. Why? Here is a part of the code.

prof[num]=(string)NormalizeDouble((double)prof[num]+(double)profit2,2);

Type prof[] is string

And it glitches in the following way


 
Vladimir Tkach:

Before displaying the doubl type, I normalise it to 2 decimal places, but sometimes it doesn't work. Why? Here is a part of the code.

Type prof[] is string

It glitches in the following way


DoubleToString()

DoubleToString

Converts a numeric value to a text string.

stringDoubleToString(
doublevalue,//number
intdigits=8//number of decimal places
);

Parameters

value

[in] Value is a floating point value.

digits

[in] The format of the precision. If digits value is between 0 and 16, then the string representation of the number will be obtained, with the number of decimal places specified. If the digits value is between -1 and -16, then a string representation of the number in scientific format with the number of decimal places specified will be obtained. In all other cases, the string representation of the number will have 8 decimal places.

Returned value

A string containing the character representation of the number in the specified precision format.

Example:

Print("DoubleToString(120.0+M_PI) : ",DoubleToString(120.0+M_PI);
Print("DoubleToString(120.0+M_PI,16) : ",DoubleToString(120.0+M_PI,16);
Print("DoubleToString(120.0+M_PI,-16) : ",DoubleToString(120.0+M_PI,-16);
Print("DoubleToString(120.0+M_PI,-1) : ",DoubleToString(120.0+M_PI,-1));
Print("DoubleToString(120.0+M_PI,-20) : ",DoubleToString(120.0+M_PI,-20);

 

Some wondrous bug or other.

We add in the inputs:

input datetime test                                =0;

Compile. With date 1970.01.01 zero, it is not possible to set the hour to 00, 01 or 02 in the settings.
 
igorbel:

input datetime test                                =0;

Compile. With a zero date of 1970.01.01, it is not possible to set the hour to 00, 01 or 02 in the settings.

Here is an example of entering the time in the input parameters