Edit your post using SRC button please
jonjon:
Hi Guys,
As new in learning mql4, i have manage to throw some basic codes and get started with my EA for a little while. Unfortunately, with limited knowledge of the available functions to use, stalled on some part of the codes logic. By the way, the part that i'm having difficulties with is the scaling/pyramiding logic/part of the strategy. Any help or inputs there on how to achieve the missing part of the logic would be greatly appreciated .
This is how it should work.
1. Open an initial trade when the condition is true , -lets focus on Long position for the meantime.
Condition: H4_SMA6 > H4_SMA25 && LongCount() ==0 ...no current open long position.
2. After opening an initial long position, check the profitability of that last and currently open position (Long).
If it gained a certain amount of pips, or a certain percentage of ATR (ex. 15% of ATR )
then open another Long Position, "adjust the lotsize by dividing by 2 and adjust stoploss too to minimize risk".
this will keep on iterating referencing the last opened Long position thus opening multiple Long positions without a take profit. It will only stop on Step 3.
3. When the last of the multiple long position has been stop via StopLoss (S/L). This will trigger to close all opened long position triggered on the step2 of the
strategy and doing a Take Profit.
Below is the code i've made. Please ask if need extra info and feel free to modify, comment, add etc. to the code. Hope to find answers from you. Thanks
Hi Guys,
As new in learning mql4, i have manage to throw some basic codes and get started with my EA for a little while. Unfortunately, with limited knowledge of the available functions to use, stalled on some part of the codes logic. By the way, the part that i'm having difficulties with is the scaling/pyramiding logic/part of the strategy. Any help or inputs there on how to achieve the missing part of the logic would be greatly appreciated .
This is how it should work.
1. Open an initial trade when the condition is true , -lets focus on Long position for the meantime.
Condition: H4_SMA6 > H4_SMA25 && LongCount() ==0 ...no current open long position.
2. After opening an initial long position, check the profitability of that last and currently open position (Long).
If it gained a certain amount of pips, or a certain percentage of ATR (ex. 15% of ATR )
then open another Long Position, "adjust the lotsize by dividing by 2 and adjust stoploss too to minimize risk".
this will keep on iterating referencing the last opened Long position thus opening multiple Long positions without a take profit. It will only stop on Step 3.
3. When the last of the multiple long position has been stop via StopLoss (S/L). This will trigger to close all opened long position triggered on the step2 of the
strategy and doing a Take Profit.
Below is the code i've made. Please ask if need extra info and feel free to modify, comment, add etc. to the code. Hope to find answers from you. Thanks
![]() Play video | Please edit your post. For large amounts of code, attach it. |

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
As new in learning mql4, i have manage to throw some basic codes and get started with my EA for a little while. Unfortunately, with limited knowledge of the available functions to use, stalled on some part of the codes logic. By the way, the part that i'm having difficulties with is the scaling/pyramiding logic/part of the strategy. Any help or inputs there on how to achieve the missing part of the logic would be greatly appreciated .
This is how it should work.
1. Open an initial trade when the condition is true , -lets focus on Long position for the meantime.
Condition: H4_SMA6 > H4_SMA25 && LongCount() ==0 ...no current open long position.
2. After opening an initial long position, check the profitability of that last and currently open position (Long).
If it gained a certain amount of pips, or a certain percentage of ATR (ex. 15% of ATR )
then open another Long Position, "adjust the lotsize by dividing by 2 and adjust stoploss too to minimize risk".
this will keep on iterating referencing the last opened Long position thus opening multiple Long positions without a take profit. It will only stop on Step 3.
3. When the last of the multiple long position has been stop via StopLoss (S/L). This will trigger to close all opened long position triggered on the step2 of the
strategy and doing a Take Profit.
Below is the code i've made. Please ask if need extra info and feel free to modify, comment, add etc. to the code. Hope to find answers from you. Thanks