Sounds like you're using too many Global/Static variables and over-complicating it.
if( SaveTime == 0 && signal() != 0 ){ SaveTime=TimeCurrent(); } if( SaveTime != 0 && SaveTime+30_Second < TimeCurrent() ){ SaveTime=0; } //Note: TimeCurrent because you're working in Seconds for Expiration. //Note: SaveTime should be of Stored Type Variable. //Note: Not sure if it'll solve your problem, just my 2Cents.
ok..:)
Let me explain : I want to limit trading time. Same way as its used when StartTime is PRE-SET BY USER, and EndTime is just StartTime + some seconds. But in my example StartTime is not pre-seted by user - instead its generated by event = signal = MA cross.
I hope thats clear now?
P.S. Thank you Ubzen for your 2cents i will gladly play arround with ur approach now. Will update on results.
Cheers
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
Hi again,
I still have difficulties in coding this. Maybe someone could advise me please.
So far I made signal() checked on every bar open.
Now, as signal SHOULD appear only once in a while(on MA cross). Signal is 1or2. else is 3.
NOTE : once i delete ,,else signal =3;,, EA process will work , but timer not. As it will remeber only 1 or 2 outputs. But with output 3 EA dont work at all, but timer seems to work closely to success.
Therefore I want to save time of new bar openning once MA just crossed:
The idea is to look for signal per bar open. Find it - save its time, set time to expiry trading under such signal. Trade per tick(look for entry price per tick). Look for another signal. and so on.
I think I should use Time[] not TimeCurrent(). And search in array Time[] for openning and closing times i need for ,,TradeAllowed,,
Im just confiused now.