Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1954

 

Hi

Need to know why My Order (TP) was Not Executed as Price has gone below my Set Target i.e. 0.99600 where as Price gone to 0.99517 on EURUSD.

Also, note that Bear Candle Wick is Crossing my TP Line as shown below in attached Snap.

Regards

Shahzad


MT4 Order 

 
@Shahzad Iqbal #: Need to know why My Order (TP) was Not Executed as Price has gone below my Set Target i.e. 0.99600 where as Price gone to 0.99517 on EURUSD. Also, note that Bear Candle Wick is Crossing my TP Line as shown below in attached Snap.

Your order was placed 2022.08.12 but you are looking at the price chart for 2022.07.14 which is one month earlier than your order.


 
Fernando Carreiro #:

Your order was placed 2022.08.12 but you are looking at the price chart for 2022.07.14 which is one month earlier than your order.


Thanks  Fernando Carreiro for the Explanation !!! 

Being a New Bee in FX I forgot this  :-)


MT2

 
What is I-Value? It requires me here.
Files:
 
@IgorFX Trading #What is I-Value? It requires me here.

That symbol is not an "i", it is a a vertical bar or pipe "|".

A single bar "|" has the meaning of a Bitwise OR Operation, while a double bar "||" has the meaning of a Logical OR Operation.

By the way, you may find it helpful to learn C or C++ as well because MQL is based on it and there are many more source of educational information out there for C/C++ than there are for MQL.

 

PZ Parabolic SAR EA - expert for MetaTrader 4

https://www.mql5.com/en/code/10957

I hope someone can help me on this. I ran this on tester and it worked fine but when I used it in live it keeps closing deals even when signals isnt done. Hope someone can help. Thanks!

The amount of balance I have is $200

PZ Parabolic SAR EA
PZ Parabolic SAR EA
  • www.mql5.com
This Expert Advisor trades Parabolic Sar (PSAR) trend changes and applies a fast exit strategy. The parabolic SAR is a technical indicator developed by J. Wells Wilder. Basically, if the stock is trading below the parabolic SAR you should sell. If the sto
Files:
Capture.PNG  118 kb
Capture1.PNG  100 kb
 
Paul Vergara #: Hope someone can help.
  1. Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
              Code debugging - Developing programs - MetaEditor Help
              Error Handling and Logging in MQL5 - MQL5 Articles (2015)
              Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
              Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)

  2. GetLotSize doesn't compute correctly.

    Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk (on leveraged symbols). Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.

    1. You place the stop where it needs to be — where the reason for the trade is no longer valid. E.g. trading a support bounce, the stop goes below the support.

    2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/PIP, but it takes account of the exchange rates of the pair vs. your account currency.)

    3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
                MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum (2017)
                Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum (2018)
                Lot value calculation off by a factor of 100 - MQL5 programming forum (2019)

    4. You must normalize lots properly and check against min and max.

    5. You must also check Free Margin to avoid stop out

    6. For MT5, see 'Money Fixed Risk' - MQL5 Code Base (2017)

    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.

  3. GetDecimalPip is broken for JPY
 
William Roeder #:
  1. Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
              Code debugging - Developing programs - MetaEditor Help
              Error Handling and Logging in MQL5 - MQL5 Articles (2015)
              Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
              Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)

  2. GetLotSize doesn't compute correctly.

    Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk (on leveraged symbols). Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.

    1. You place the stop where it needs to be — where the reason for the trade is no longer valid. E.g. trading a support bounce, the stop goes below the support.

    2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/PIP, but it takes account of the exchange rates of the pair vs. your account currency.)

    3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
                MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum (2017)
                Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum (2018)
                Lot value calculation off by a factor of 100 - MQL5 programming forum (2019)

    4. You must normalize lots properly and check against min and max.

    5. You must also check Free Margin to avoid stop out

    6. For MT5, see 'Money Fixed Risk' - MQL5 Code Base (2017)

    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.

  3. GetDecimalPip is broken for JPY

Hi Sorry it wasnt my code I just took it on the free EAs on the site and I dont really understand the code. But thanks a lot for this!
 
Hey,  I'm using MT4 and while switching into an Demo account, i only can see and use the Crypto symbols, i want to know that how can i see and trade in all other symbols.
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Account Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Files:
Demo_Cryp.jpg  105 kb
 
emadatar #: Hey,  I'm using MT4 and while switching into an Demo account, i only can see and use the Crypto symbols, i want to know that how can i see and trade in all other symbols.

You can only trade what your account offers. So choose a broker and a type of account that offers the symbols you want to trade.

Reason: