Evaluate Last Order

MQL5 Experten

Spezifikation

I need a function writing to evaluate the last order placed after it has reached it's take profit or stop loss, writing the profit/loss to a global variable and also return a Boolean value of 0/1 depending on a profit or loss being generated. My orders always run to stop limits or take profits.

This sounds easy enough, although I have hit a stumbling block with HistorySelect and cannot go any further, the problem is as follows - I have a structure on tick that looks a little like this:

 

void OnTick()
  {
   if(PositionsTotal() >= 1)
      {

      }
   else
      {
         RefreshCharts();
         CalculateProfitAndLoss();
         OpenOrder();
      }
  }

 

Now the problem is, that my OpenOrder() function may fail and the OnTick() function will loop again when the market refreshes and as a result, the CaculateProfitLoss() function), sees the previous unsuccessful trade and reports a zero profit/loss, which isn't correct.

The solution is probably glaringly obvious, but I cannot work it out and want to get on with the technical analysis side of things. 

Let me know what you think. I would have written a full specification, but with no inputs and only two outputs, it didn't seem worth it. 

Only stipulation is that code is heavily documented. 

  

Additional note (added 06/Sep/13): I just want to ensure that people have read the above thoroughly and understand that simple code such as that listed below does not achieve the desired results as I have a lot of failed trades opening, a situation I am attempting to resolve with a new function. Example of what doesn't work: 

 last_deal=HistoryDealGetTicket((int)deals-1);

Bewerbungen

1
Entwickler 1
Bewertung
(1235)
Projekte
2820
80%
Schlichtung
156
22% / 43%
Frist nicht eingehalten
488
17%
Frei
2
Entwickler 2
Bewertung
(82)
Projekte
150
29%
Schlichtung
9
44% / 11%
Frist nicht eingehalten
46
31%
Frei
3
Entwickler 3
Bewertung
(62)
Projekte
140
46%
Schlichtung
19
42% / 16%
Frist nicht eingehalten
32
23%
Frei
4
Entwickler 4
Bewertung
Projekte
2
50%
Schlichtung
0
Frist nicht eingehalten
0
Frei
5
Entwickler 5
Bewertung
(18)
Projekte
37
43%
Schlichtung
6
17% / 50%
Frist nicht eingehalten
17
46%
Frei
6
Entwickler 6
Bewertung
(63)
Projekte
80
28%
Schlichtung
17
12% / 76%
Frist nicht eingehalten
48
60%
Frei
7
Entwickler 7
Bewertung
(466)
Projekte
697
56%
Schlichtung
43
30% / 33%
Frist nicht eingehalten
113
16%
Arbeitet
8
Entwickler 8
Bewertung
(71)
Projekte
254
53%
Schlichtung
16
50% / 38%
Frist nicht eingehalten
83
33%
Frei
9
Entwickler 9
Bewertung
(215)
Projekte
302
79%
Schlichtung
4
25% / 0%
Frist nicht eingehalten
62
21%
Frei
Ähnliche Aufträge
I want to convert a small script from mql5 to pinescript of tradingview. The final script must work fine in tradingview, i will test it first if its ok i pay the developper. Script wil be send to developper in private because i cant post it here. If you have question you can ask me. Tnaks
MT4 EA Trade one zigzags 100 - 150 USD
I am looking for a programmer to do EA trader. If you can understand what I want from the video i do and you can do it, contact me because you will be able to do what I want. https://drive.google.com/file/d/1wbHxbUQQqCkdpr0-pHfIh2b288LzYTV2/view?usp=sharing
I need A Ea For Parabolic SAR With Default Settings And That Ea Including Take Profit And Stoploss Levels. Take profit : 50 points Stop loss : 50 points I have been seen that ea in Mql5 Market I tested it but that ea stop loss and take profits not activated that's why I came here I need a demo for testing process if you gave demo 1st and I will set you as a person to create a ea
Modifying an expert advisor written in mql5 and adding new indicators to it. The result must work both on strategy testing and on live, with no compilation errors and no warnings
see trade open on every tick seconde ok forex pair us us30 if is current running at 40170.00 so open 2 trade buy stop and sell stop both in every tick pending order of buy stop will 40171.00 and sell stop pending order will be 40169.00 buy stop will open at 40171.00 and tp will be 40173.00 and SL will be 40169.50 ok if buy stop hit sell stop order automatically will be close now if sell stop order open at 40169.00 so
Hi, I have an indicator from my friend, I want to copy it to MT5 can you do that for me. Here is the link
I'm seeking assistance in developing a sophisticated trading robot with the following features: Core strategy: Harmonic pattern recognition Supply and demand analysis Fibonacci zigzag for trade optimization Additional components: News filter Dashboard for easy monitoring Customizable settings: Lot size Trailing stop Trading session parameters Maximum number of orders Option to use market or limit orders Resources
1. Add Feature For (SPREAD) Normal trading Hours Spread or User set trading Hours Spread True or false Set to true or False When set to true EA will only create or develop a trade if spread is in this window allowing it to and EA will follow a window in which it can trade based on spread so if spread is to high and outside of this window it will not create a trade It
Hi, I have an indicator from my friend, I want to copy it to MT5 can you do that for me. Here is the link
Hi, I have a working MQ4 EA (With a few warnings but works fine), I need the warnings cleared and converted to MQ5. But I would also like a few improvements first. Firstly: Fix warnings in MT4 code (return value of 'OrderSelect'/'OrderModify' should be checked). Add following features: Magic number modifiable variable (It's currently hard coded) Is it possible to have a stop loss dollar amount instead of lots if

Projektdetails

Budget
10 - 100 USD
Für die Entwickler
9 - 90 USD
Ausführungsfristen
von 1 bis 14 Tag(e)