Save new price when "if" statemet is executed

 

Hello

I would need some help please.

How can i save the Takeprofit Level ? I dont want to put it in the "OrderSend". Because i need it for something else.


What happens here is that when the OrderSend is executed in the Comment I can see the Value allthough it lasts only until new tick.


How can I save that value ?


Also, seems that "double" doesn´t return more than 4 digits, is there another way for 5 digits ?


Thanks



/////////////////////////////////////////////


void OnTick()

{

double OpeningPrice;

double Takeprofit;

   if (OrdersTotal() ==0)

       {   

               OrderSend(Symbol(),OP_BUY,0.1,Ask,NULL,NULL,NULL);

               OpeningPrice = Ask;

               Takeprofit=OpeningPrice+100*_Point;

       }

      

      Comment ("T/P is: ",Takeprofit);

             

}

 
Kenmei Miyamura:

Please edit your post and

use the code button (Alt+S) when pasting code


I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.

 
Keith Watford:

Please edit your post and

use the code button (Alt+S) when pasting code


I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.

Hello Keith, Thanks for the answer,


Tried to edit and paste it with the commands ALT+S as you told me and doesnt paste anything...


So... Do you know how to save the value of the price when executed ?

 
  1. Kenmei Miyamura: Tried to edit and paste it with the commands ALT+S as you told me and doesnt paste anything...

    It works just fine do it again. (Go here and click on the image.) Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  2. Kenmei Miyamura: Also, seems that "double" doesn´t return more than 4 digits, is there another way for 5 digits ?

    Floating-point has an infinite number of decimals, it's your not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
              Double-precision floating-point format - Wikipedia, the free encyclopedia

    See also The == operand. - MQL4 programming forum

    If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy. You don't want 5.
              question about decima of marketinfo() - MQL4 programming forum 2016.05.18

  3. Kenmei Miyamura: What happens here is that when the OrderSend is executed in the Comment I can see the Value allthough it lasts only until new tick.

    How can I save that value ?

    OrderSend is not executed in a Comment; that is babel. What happens is
    1. The If starts.
    2. The OrderSend is executed.
    3. You update the variable Takeprofit.
    4. The if ends.
    5. You print the variable.
    6. On the next tick, the variable is zero (not using strict), the if is false and does nothing, and you print zero.

  4. Perhaps you should read the manual. MQL4 ReferenceLanguage BasicsVariablesStatic Variables and Global Variables
       How To Ask Questions The Smart Way. 2004
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

  5. Always use strict. Fixing the warnings will save you hours of debugging, but you must understand the differences.

 
William Roeder:
  1. It works just fine do it again. (Go here and click on the image.) Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  2. Floating-point has an infinite number of decimals, it's your not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
              Double-precision floating-point format - Wikipedia, the free encyclopedia

    See also The == operand. - MQL4 programming forum

    If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy. You don't want 5.
              question about decima of marketinfo() - MQL4 programming forum 2016.05.18

  3. OrderSend is not executed in a Comment; that is babel. What happens is
    1. The If starts.
    2. The OrderSend is executed.
    3. You update the variable Takeprofit.
    4. The if ends.
    5. You print the variable.
    6. On the next tick, the variable is zero (not using strict), the if is false and does nothing, and you print zero.

  4. Perhaps you should read the manual. MQL4 ReferenceLanguage BasicsVariablesStatic Variables and Global Variables
       How To Ask Questions The Smart Way. 2004
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

  5. Always use strict. Fixing the warnings will save you hours of debugging, but you must understand the differences.

Ok,

Seems more difficul than I tought :)

Thank you for youre explanations  !!

Reason: