[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 419

 

Forexman77:
How can I get the program to give the EMA level as a price? Suppose EMA1 with period (1), EMA2 with period (0), EMA1 equals 1.3321, while EMA2 for the current period is 1.3200. The result of the expression (EMA1 to EMA2) must be 0.0121. When you run the script, the alert shows zero, while we need "0.0121". How to solve this problem?

double delta = iMA(NULL,0,1,0,MODE_EMA,PRICE_CLOSE,0) - iMA(NULL,0,0,0,MODE_EMA,PRICE_CLOSE,0);

if (delta == 0.0121) Alert("Delta=0.0121"); 
 
Forexman77:
How to make the program output the EMA level as the price? Suppose EMA1 with period (1), EMA2 with period (0), EMA1 equals 1.3321, EMA2 for the current period 1.3200. The result of the expression (EMA1 to EMA2) must be 0.0121. When I run the script, the alert shows zero, while I need "0.0121". How to solve this problem?

Is it possible to see the script itself? - Presumably you either have the wrong data type, e.g. interger instead of double (so it rounds to zero), or something else which causes zero: it's hard to understand without the code.

By the way, if you check what you have written before with the script, the error can be either in the script itself (presumably written just to check your indicator), or in the code of the indicator itself.

 
TarasBY:
If you have correctly filtered your orders, which I suggested you do, and if you include commission and swaps in your calculations, then everything works correctly.


You must have given a very complicated path.

it's not working for me.


I stupidly inserted the following into your sample:

ld_Profit = fGet_ProfitLastCloseOrd (12);    
Print (ld_Profit);

It gives out some number, but it's a far cry from reality.

Could you please SHOW me where I need to enter the number 12 to make it work. Because I don't know about "filtering orders" at all....

 
lottamer:


You must have given a very complicated way.

it's not working for me.


I stupidly inserted the following into your sample:

It gives out some number, but it's a far cry from reality.

Could you please SHOW me where I need to enter the number 12 to make it work. Because I don't know about "order filtering" at all....

I have made all intermediate calculations on chart to have a better control of function working.

It only remains for you to write the code.

You have two ways: either to understand it yourself (by examples - I have given you a working script), or find someone who will do it for you.

P.S. If you suddenly want to understand it, you can start from here.

 
Chiripaha:

Is it possible to see the script itself? - Presumably you either have the wrong data type, e.g. interger instead of double (so it rounds to zero), or something else which causes zero: it's hard to understand without the code.

By the way, if you script what you have written before, the error can be either in the script itself (presumably written to test your indicator) or in the code of the indicator itself.


You're right, I removed EMA from int to double and everything is as it should be.
 
TarasBY:

For full control of the function all intermediate calculations are shown on the chart.

All that's left is for you to write the code.

There are two ways: either you can figure it out yourself (using examples - I gave you a working script), or you can find someone to do it for you.

P.S. If you suddenly want to figure it out, you can start from here.


Thank you, I will definitely try to figure it out
 
Forexman77:
How can I make the program output the EMA level as a price? Suppose EMA1 with period (1), EMA2 with period (0), EMA1 is 1.3321 and EMA2 is 1.3200 for the current period. The result of the expression (EMA1 to EMA2) must be 0.0121. When I run the script, the alert shows zero, while I need "0.0121". How to solve this problem?

Use variables of type double instead of int in calculations;

use NormalizeDouble(number1-number2, the desired accuracy) when calculating the result of the expression;

use DoubleToStr(the result obtained, the desired accuracy) to display the result on the screen (in the journal);

There's nothing else to suggest without your code...

 
Forexman77:
You're right, I removed the EMA from int to double and everything is as it should be.

Here, we've already found it... Anyway, note that to avoid hidden errors and inaccuracies, use normalization when comparing and calculating data of type double
 
Chiripaha:

Bottom line: Of course, you could, for the sake of interest, ask you to describe the conditions in more detail, since you have only provided a general description: when were the robot orders set (in advance or not; manual around the same time as the robot or not, etc.). But anyway, even in this case you will only have to deal with your broker, because he has his own thread which probably queues up the trades. Suppose, if the manual pending order was placed first, then the time of its execution will be different (including the queue of other clients), so the price may be different. If the robot has placed the orders within the period of formed signals, then the arrival of orders in the queue is not evident - hence the possible bias in the execution price. Also, it may be affected by the size of positions that you don't write anything about... etc...

But... Anyway, this can only be clarified with a broker (DC). And I assume he will find a bunch of reasons I didn't mention. - And the advice was right: the log in your hands and to the broker, unless of course you still think your pending orders have moved. But just do not confuse 2 different concepts: a Pending Order and a Deal on this Pending Order. The Limit order is an instruction to enter the market at any nearest price with declared volume. And the Deal - is the price at which it was possible to execute your order for the declared volume of money (lot). - And the prices of these orders are likely to be different (especially on the fast market, which is what you were given the link to). For limit orders, the price of the order and the price of execution are equal (by definition).

And the fact that the demo and the real broker do not differ from each other is good! - That shows that the broker doesn't fake trades to attract clients (from your words). - There is no discrepancy to be seen in this case.


Thank you for such a detailed reply, everything becomes clear. If we use the Instant Execution system, will this problem be solved?

What about the conditions I have not mentioned:

The robot placed orders earlier than the manually placed ones, but they were modified before the news.

The volume of trades was the same, distances about the same

in general the conditions were almost exactly the same.

 
TarasBY:
The current day begins at the beginning of the current D1 bar (iTime (NULL, PERIOD_D1, 0)), but you are not looking for easy ways?! :)))


here's the problem.

Everything works, but only ONE time. I.e. if I set the period (iTime (NULL, PERIOD_D1, 0)) of a day, it does not work on the next day.

wrote a test code to test

GetProfitFromDateInCurrency (Symbol(), -1, -1, iTime (NULL, PERIOD_M1, 0));  

if  (GetProfitFromDateInCurrency()<1 && GetProfitFromDateInCurrency()>-1)
    { My_buy ();  My_close(); }
поставил период МИНУТКИ, так чтобы за минуту слить доллар на спреде и остановиться, ДО НАЧАЛА ВТОРОЙ МИНУТЫ. И он льет и останавливается. А вот почему на второй минуте он не открывает сделок?