- KristijanO: can someone please give me some advice on what to do?
Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
-
TP=Ask+(TakeProfit*MyPoint);
You buy at the Ask and sell at the Bid.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.
-
-
int start() // Special function start() { ⋮ } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnDeinit(const int reason){} //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { }
You should stop using the old event handlers and IndicatorCounted() and start using new event handlers. You can not use both.
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 2016.05.11
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone,
im building my first EA, it uses a custom indicator that is a two lines cross indicator, i have also made the EA so it calculates the StopLoss and TakeProfit level using the ATR multiplier, the problem that i am having is that the EA does't take trades, it shows no errors in the journal or in the metaeditor. Here is the code, can someone please give me some advice on what to do?