Menu
Brokers
MT4 Forex Brokers
MT5 Forex brokers
PayPal Brokers
Skrill Brokers
Oil Trading Brokers
Gold Trading Brokers
Web Browser Platform
Brokers with CFD Trading
ECN Brokers
Bitcoin FX Brokers
PAMM Forex Brokers
With Cent Accounts
With High Leverage
Cryptocurrency Brokers
Forums
All threads
New threads
New posts
Trending
Search forums
What's new
New threads
New posts
Latest activity
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Reply to thread
Forums
Trading Platforms
MetaTrader Expert Advisors
News Trader
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
[QUOTE="KINGSLEY CHIDIADI, post: 136160, member: 50802"] Ok I seem to have solved the issue. still using my basic knowledge of maths, english and logic this is the original code ......... // Check what position is currently open GetPositionStates(); // Adjust SL and TP of the current position if ((HaveLongPosition) || (HaveShortPosition)) ControlPosition(); else { TimeSpan difference = Time.Subtract(news_time).Negate(); [B][COLOR=#ff0000] if ((difference <= TimeSpan.FromSeconds(60)) && (difference > TimeSpan.FromMilliseconds(0)))[/COLOR][/B] { // Randomize entry. if (Rnd) { Random r = new Random(); if (r.Next() % 2 == 1) fBuy(); else fSell(); } else if ((Buy) && (Sell)) { fBuy(); fSell(); } else if (Buy) fBuy(); else if (Sell) fSell(); } } } .......... Now the problem with this code was marked in red and bolded. what that string would have probably meant is that as soon as the time is less than 60 seconds, then a position(s) should be established with the relative type of trailing stop selected. So this does not give allowance for opening trades in a time frame that is less than 60 seconds. Assuming one wants to open a position(s) say 10secs to the news. This will limit everyone to the 60 seconds window and it won't respect whatever seconds before you have set and if it is less 60 seconds, it will automatically open a trade(s) now this is the edited code with the "possible" correction in blue. ......... // Check what position is currently open GetPositionStates(); // Adjust SL and TP of the current position if ((HaveLongPosition) || (HaveShortPosition)) ControlPosition(); else { TimeSpan difference = Time.Subtract(news_time).Negate(); [B][COLOR=#0000ff] if ((difference <= TimeSpan.FromSeconds(SecondsBefore)) && (difference > TimeSpan.FromSeconds(1)))[/COLOR][/B] { // Randomize entry. if (Rnd) { Random r = new Random(); if (r.Next() % 2 == 1) fBuy(); else fSell(); } else if ((Buy) && (Sell)) { fBuy(); fSell(); } else if (Buy) fBuy(); else if (Sell) fSell(); } } } .......... This "possible" correction sets the algo to respect the preferred SecondsBefore of the user... basically what this means is that as soon as the time is lesser than the SecondsBefore and it is not 1 second to the news, then the positions can be opened... After adjustment of the code, everything seems to respect whatever SecondsBefore I set just my two tots.... [/QUOTE]
Insert quotes…
Verification
Post reply
Top
Bottom
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…