double rsi=iRSI(Symbol(),0,RSIperiod,PRICE_CLOSE,0);
double rsi1=iRSI(Symbol(),0,RSIperiod,PRICE_CLOSE,1);
//--- open position
if(OpenSELL && OrderSell<1 && rsi<SellLevel && rsi1>SellLevel) OPSELL();
if(OpenBUY && OrderBuy<1 && rsi>BuyLevel && rsi1<BuyLevel) OPBUY();
The functions OPSELL and OPBUY are only called after checking the RSI conditions. They are not called anywhere else as far as I can see. So there is no way that an order being closed by stoploss can initiate a new order.
I note that you are using the RSI value for the current bar, by the time that the bar closes the condition may no longer be true. This means that when you look back over the chart it may appear that an order was opened when conditions were not met.
this is why im confused as it doesnt appear it should be reversing at stoploss
my modified EA does not rely on rsi nor does it use the live candle...all of that was removed and replaced in my EA
my EA relies on a function of price action between one candle and two candles back
x = 100*(1-(Close[2] / Close[1]));
once x is of a large enough magnitude, it opens an order
clearly there is more to my EA but these "closes" are the only inputs
somehow my stoplosses are reversing my position and i think its a glitch, not my program
here is the output of what is happening in my journal
notice these are all within seconds, this was the cross of a stoploss:
0 22:51:04.012 '99025322': login datacenter on Forex.com-Live 22 through New York 15 (ping: 1.78 ms) 0 22:51:04.231 '99025322': previous successful authorization performed from 73.80.73.163 0 23:39:35.472 '99025322': order buy market 0.10 EURUSDpro sl: 1.05647 tp: 1.09660 1 23:39:35.550 '99025322': order buy 0.10 EURUSDpro opening at market sl: 1.05647 tp: 1.09660 failed [Hedge is prohibited] 0 23:39:35.550 '99025322': close order #24812457 sell 0.10 EURUSDpro at 1.07642 sl: 1.09657 tp: 1.05642 at price 0.00000 0 23:39:35.691 '99025322': order #24812457 sell 0.10 EURUSDpro at 1.07642 sl: 1.09657 tp: 1.05642 closed at price 1.07660 0 23:39:36.503 '99025322': order sell market 0.10 EURUSDpro sl: 1.09660 tp: 1.05646 0 23:39:36.660 '99025322': order was opened : #24813043 sell 0.10 EURUSDpro at 1.07646 sl: 1.09660 tp: 1.05646
this line in particular leaves me curious something is going wrong
1 23:39:35.550 '99025322': order buy 0.10 EURUSDpro opening at market sl: 1.05647 tp: 1.09660 failed [Hedge is prohibited]
any ideas??
thanks
this line in particular leaves me curious something is going wrong
1 23:39:35.550 '99025322': order buy 0.10 EURUSDpro opening at market sl: 1.05647 tp: 1.09660 failed [Hedge is prohibited]
Why? It is self explanatory.
0 23:39:35.691 '99025322': order #24812457 sell 0.10 EURUSDpro at 1.07642 sl: 1.09657 tp: 1.05642 closed at price 1.07660
0 23:39:36.503 '99025322': order sell market 0.10 EURUSDpro sl: 1.09660 tp: 1.05646
0 23:39:36.660 '99025322': order was opened : #24813043 sell 0.10 EURUSDpro at 1.07646 sl: 1.09660 tp: 1.05646
It is not opening a reversal, it is opening another sell.
x = 100*(1-(Close[2] / Close[1]));
When a new trade is opened, print the value of x to check whether the condition is satisfied or not.
Why? It is self explanatory.
It is not opening a reversal, it is opening another sell.
x = 100*(1-(Close[2] / Close[1]));
When a new trade is opened, print the value of x to check whether the condition is satisfied or not.
ok but what in the EA is causing a hedge condition?
i cant tell why its opening a new sell automatically once stoploss is hit
is there a function for printing to the journal
sorry im still pretty new with mt4
Your EA is trying to open a buy when there is a sell open.
It is not opening automatically, it is opening because your conditions for a sell are satisfied.
Yes, Print()
It prints to the journal in the tester and to the Experts log on a real-time chart.
Your EA is trying to open a buy when there is a sell open.
It is not opening automatically, it is opening because your conditions for a sell are satisfied.
Yes, Print()
It prints to the journal in the tester and to the Experts log on a real-time chart.
i think i may have figured something out, i was stuck in a trade so i hadn't had chance to add the print function yet
but it occurred again last night so i reviewed the journal...
the stoploss did not activate the reversal, however a new trade was activated 20 or so minutes later, immediately on the 3:00:00 hour leading me to believe the EA is also running on the H1 not just the M5
is it even possible that i accidentally set the EA to run in two different time frames??? i did not know that was even possible
perhaps this also explains why its attempting "hedging"??jazzpur: is it even possible that i accidentally set the EA to run in two different time frames??? i did not know that was even possible perhaps this also explains why its attempting "hedging"?? |
|
|
yikes!
how do i know which aggregation chart ive activated the EA on? if every single aggregation shows this smiley face?
its kinda crappy that the charts dont visually show you unless im missing something
im not sure if im understanding the EAs workings fundamentally in mt4
i only have one chart open, trading eur/usd with EA
do you need 2 separate chart windows to run 2 instances of the same EA?
if i set the EA up to run on 5min but click into the 1hour to view a bigger picture...and then shut down my VPS connection...does that EA now trade H1 candles?
i dont understand if it stays "set in place" on 5m only, or does it view the currently showing aggregation?
jazzpur: if i set the EA up to run on 5min but click into the 1hour...does that EA now trade H1 candles?
| It does unless every call is specifically M5 |

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
greetings everyone,
im trying to modify this basic EA that a lot of people use as a foundation
for simplicity sake i will use the original EA as an example
it buys under certain rsi condition,closes and reverses direction to short on the opposite condition....switching direction back and forth
it also has takeprofit and stoploss which should exit positions completely
with backtesting, hitting the stoploss closes my open position and does not open a reversal<<<<this is what i want
however, when i test this live on my forex.com account, the stoplosses are closing my buys and opening sells thus unwantingly reversing position, why is this happening...i do not want this
the brackets are only there for risk management, not stratgey reversal
is this written in the code to do this? im trying to remove some functions but i cant figure how to stop this...