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
Simple Advisor with Stop Loss and Take Profit
An example of a simple Expert Advisor that opens one position with the indicated Stop Loss and Take Profit.
To give a trade order to open a position with Stop Loss and Take Profit, you need to calculate these levels:
Variables declared at the global program level (in the 'header' of the adviser):
Input parameters:
OnTick:
Result:
Creating an iMA indicator handle, getting indicator values
(code: iMA Values on a Chart.mq5)
The main rule: the indicator handle needs to be received once (it is optimal to do this in the OnInit function).
Input parameters and the variable in which the indicator handle is stored:
Creating a handle (checking the result)
Getting values (I use the iGetArray generic function). Please note: for the array "array_ma" I use "ArraySetAsSeries" - in this case, in the “array_ma” array, the element with the index “0” corresponds to the rightmost bar on the chart (bar # 0)
The result of work:
Pic. 1. Get value on bar #0, #1, #2
iRSI simple advisor
(code: iRSI simple advisor)
Advisor works only on the new bar. The signal to open a position BUY: rsi on bar # 1> 'RSI Level UP'. Signal to open a SELL: rsi position on bar # 1 <'RSI Level DOWN'.
iRSI simple advisor
Advisor works only on the new bar. The signal to open a position BUY: rsi on bar # 1> 'RSI Level UP'. Signal to open a SELL: rsi position on bar # 1 <'RSI Level DOWN'.
God bless you. If u wanted the trade to be taken on the next bar after signal confirmation had be received. I.E take trade on next bar after signal was confirmed what bit of code would be added
I do not understand you.
I do not understand you.
Once rsi signal has been confirmed, the order is meant to be taken (Buy or Sell). We want to hold that buy order till the next candle forms i.e we don't take trade on the candle we got the trade confirmation at but the next candle that forms / next open price .
I do not understand: Do you advise me how to trade? Or do you want to delay signal (that is, you want to check the signal not on bar # 1, but on bar # 2)?
Once rsi signal has been confirmed, the order is meant to be taken (Buy or Sell). We want to hold that buy order till the next candle forms i.e we don't take trade on the candle we got the trade confirmation at but the next candle that forms / next open price.
Means: the bar with signal is closed and new bar opened - and we can open the trade after that (if the previous bar with signal is still existing), right?
It means: trading on close bar.
Yes, the most systems are "trading on close bar" systems.
Trading on close bar?
Means: the bar with signal is closed and new bar opened - and we can open the trade after that (if the previous bar with signal is still existing), right?
It means: trading on close bar.
Yes, the most systems are "trading on close bar" systems.
Yes that's what I mean... Once there is a signal wait till the bar closses then trigger buy. Please what code can I use to enable this?
You need to redo the code: request data not from one bar, but from two. And check the condition not on one bar - but on two.
It was (#23 ):
Will be: