You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Open position every new candle.
First we define a new bar.
If this is a new bar - open a BUY position with a minimum volume.
Full code:
Bars after the last iMA crossing
Task: there are two iMA indicators. Need to find: how many bars have passed since the last crossing.
Algorithm: if this is the first run - use the first form of the CopyBuffer function
copy 100 elements and search for the intersection. We print the number of the bar and the opening time of the bar with the intersection
Next time we use the third form
iMACD value on chart
An example of how to create a handle to the MACD indicator. An example of how to get the MACD indicator values on the last three bars. Remember the main rule: you need to create an indicator handle once (the best option is to create a handle in OnInit).
Full code:
Result:
An example of get values from the iStochastic indicator
Code: iStochastic get value.mq5
Do not forget the rules: create the indicator handle ONCE in OnInit, use CopyBuffer to get the data.
Result:
Example Type of candle (we use MqlRates)
Hi Vladimir, thank you for your great effort, I have learned a lot from you MQL5 and I want to help you with the (PositionClosePartial) function and this code please look at it .. as it sometimes succeeds in closing a part and sometimes it fails and closes all deals in its use in hedging :
Hi Vladimir, thank you for your great effort, I have learned a lot from you MQL5 and I want to help you with the (PositionClosePartial) function and this code please look at it .. as it sometimes succeeds in closing a part and sometimes it fails and closes all deals in its use in hedging :
Error:
if you caught a transaction of a type 'DEAL_ENTRY_OUT', then there is ALREADY no position.
It is necessary to change the logic.
Note: I searched a lot in the MQL5 library
I have not found using PositionClosePartial and I hope you add this functionality to the library
... best wishes
thank you very much
Note: I searched a lot in the MQL5 library
I have not found using PositionClosePartial and I hope you add this functionality to the library
... best wishes
When I need to close part of a position (on a hedge account) I use CTrade.PositionClosePartial