//-------------------------------------------------- BuySignal buySignalStage1 = close<lower buySignalStage2 = buySignalStage1[1] and close>close[1] and close>lower buySignalStage3 = buySignalStage2[2] and close[1]<close[2] and low[1]>low[3]
You have to understand what Trading View means. Then translate it to MT4. In MT4 there is no "close" or "lower"
etc.
In TV close means the current bid/current close price. close[1] means previous. buySignalStage1[1] means that variable value as it was on the previous candle. You must know MT4.
bool buySignalStage1 = myClose1<myBBLow1;
This is bogus; not Close[0] < iBands(… 0) buySignalStage1[1] would then be Close[1] < iBands(… 1)
Do not post code that will not compile. Show us your attempt (using the CODE button)
and state the nature of your problem.
No free help
2017.04.21
Or pay someone. Top of every page is the link Freelance.
Hiring to write script
- General - MQL5 programming forum
2018.05.12
You have to understand what Trading View means. Then translate it to MT4. In MT4 there is no "close" or
"lower" etc.
In TV close means the current bid/current close price. close[1] means previous. buySignalStage1[1] means that variable value as it was on the previous candle. You must know MT4.
This is bogus; not Close[0] < iBands(… 0) buySignalStage1[1] would then be Close[1] < iBands(… 1)
Do not post code that will not compile. Show us your attempt (using the CODE button)
and state the nature of your problem.
No free help
2017.04.21
Or pay someone. Top of every page is the link Freelance.
Hiring to write
script - General - MQL5 programming forum
2018.05.12
OK to clarify. What i'm looking for is how to I check I my buySignal1 was true on previous
bar. In TV I can use [1] to get that. Buy in MT4 I get the error.
I think I need to send my buySignal1 to an Array so it logs all those
values or i'm I wrong? this might be called buffering values as in indicators? Or is there a simple way like in TV.
buySignalStage1 = close<lower <-> close_current<lower_current buySignalStage2 = buySignalStage1[1] and close>close[1] and close>lower <-> close_1_bar_ago<lower_1_bar_ago && close_current>close_1_bar_ago && close_current>lower_current buySignalStage3 = buySignalStage2[2] and close[1]<close[2] and low[1]>low[3] <-> the buySignalStage2's formula 2 bars ago && close_1_bar_ago < close_2_bar_ago && low_1_bar_ago>low_3_bar_ago
buySignalStage2 formula applied 2 bars ago would be something like this :
close_1+2_bar_ago<lower_1+2_bar_ago && close_current+2>close_1+2_bar_ago && close_current+2>lower_current+2
... so with your code ...
bool buySignalStage1 = iClose(Symbol(),PERIOD_CURRENT,0)<iBands(Symbol(),PERIOD_CURRENT,iBands_period,iBand_deviation,0,PRICE_CLOSE,MODE_LOWER,0); <--- it's current bar bool buySignalStage2 = myClose1<myBBLow1 && iClose(Symbol(),PERIOD_CURRENT,0)>myClose1 && iClose(Symbol(),PERIOD_CURRENT,0)> iLow(Symbol(),PERIOD_CURRENT,0);
with :
myClose1<myBBLow1 = buySignalStage1 1 bar ago
etc etc ...
You could indeed save the value at each new bar in an array, but it's not recommended

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi.
I've been coding on tradingview now i'm trying to convert a simple code to an EA.
the trading view part i'm trying to copy is:
but when trying to use [1] on a variable i'm getting:
'[' - array required
I've also tried offsetting every function like this in mt4 but it dosn't give me the same resault as on tradingview:
Here buySignalStage3 never gets true:
so my question is how do I check if my bool function was true on the previous bar?