PDA

View Full Version : Learn New MQL Coding



CarGa13
03:11,
The most recent MQL 600 builds offers Object Oriented Programming (OOP) almost as some professional and more popular OOP languages such as C , C# (C Sharp) or even Java.

As its name implies, OOP brings to us the capacity to use objects representing entities with their own logic and life length, like objects in real life.

In the procedural Earth, you have separate and disparate data and functions that expose all of the implementation details and frequently tend to conceal the implementation logic or to make it hard to read.

In OOP, implementation details are hidden from the objects themselves permitting the programmer to separate the program logic from the implementation details.

As a C /C#/Java programmer with several years of experience I'm very happy to introduce you to those intriguing new concepts in the context of producing indiors or EAs.


If you are interested or even new to programming, you are at the right location and Welcome.



Contents:


#9658; https://forexintuitive.com/forex-trading-and-cfds/97943-forexchain-forex-trading-diary.html

#9658; https://forexintuitive.com/discussion-trading/97924-tax-liability-form-saxo.html

#9658; https://forexintuitive.com/discussion-trading/97921-usd-jpy.html#8203;

#9658; https://forexintuitive.com/discussion-trading/97924-tax-liability-form-saxo.html

#9658; https://forexintuitive.com/forex-trading-and-cfds/97946-puma60-journal.html

#9658; https://forexintuitive.com/forex-trading-and-cfds/97941-entries-market.html

#9658; https://forexintuitive.com/forex-trading-and-cfds/97956-ema-trading.html
.
#9658; https://forexintuitive.com/discussion-trading/97930-ouch-200-pip-stops-hurt.html
.
#9658; https://forexintuitive.com/discussion-trading/97937-forex-trading.html

#9658; https://forexintuitive.com/discussion-trading/97938-discovery.html

#9658; From Visual Modelisation using FlowCharts to complete Object Oriented EAhttps://forexintuitive.com/forex-trading-and-cfds/97954-bing-trade-journal.html

#9658; Mindi Yost Trading Assistant EAhttps://forexintuitive.com/forex-trading-and-cfds/97942-ma-fibo-=-gtgreen-pips.html

#9658; Intro to Unit Testinghttps://forexintuitive.com/discussion-trading/97927-correlation-pairs.html
.
#8226;#8226;#8226;
.

identired
14:54,
96246It looks great to me. The only other thing that I could think of at this stage is when I stated
The aim of this system is to initiate AT LEAST 6 trades (or much more, and I have had it pick up as much as 20 in rare situations) and carry those trades for 100 or more pips profitably from the initial Target. As a result of this, adding Stop Loss isn't recommended on some of those trades. But I add Profit Stops AT THE ORIGINAL target to ALL profitable trades WHEN all the open positions are profitable. Currently I shall also add a Profit target for each one the trades too.

Although, for the time being, the EA is primarily for entering the trades and the trader would control the Stops and Limits manually once the trades have been entered, I suppose I should tell you I also move the stops that were initiated at the above mentioned Bold text - as well as adding ceases (profit stops) to some residual trades once the LEAST PROFITABLE TRADE is 50 pips profitable. Now I protect 25 pips of profit on that least profitable trade and be certain every other trade has a minimum of at least 25 pips secure. But the trader can thus whatever they want at any stage with the stops - or near any/all of the trades when they are profitable. If we decide to fully automate this, we'll have to make some principles for profit protection, but I don't think it is an issue at present.

CarGa13
16:14,
91718I had a thought on this too, but it's no problem, we can put in the profit logic at a later moment.

identired
17:35,
91718after what happened - did it become more apparent to you as to transactions stop or use buy transactions was sort of important?

CarGa13
18:56,
91718
after what happened last night - did it become more apparent to you as to why the use stop trades or use buy trades only was kind of important? Euh no, enlighten me .

identired
20:17,
91718well, the emails began at 9:55pm (my regional time) when the price first crossed over the target of 14760 - with the large at 14765. That was when I entered the limit transactions that are Sell beginning at 14770. The subsequent 4 1m bars with the low on those bars of 14741. The next 1m pub (10:00pm) broke over 14760 again (this is the very first re-test to move higher) with the high on those bars in 147648 (so essentially showing a double top that can be construed as a resistance). The subsequent 4 bars moved lower again. At 10:07pm we had another bar that broke over 14760 - but this time the large was14762 (a lesser high that indies the resistance is bolstering ) and this was also the 2nd failed test of trying to move greater. The next series of bars dropped below 14760 again - but this time that the low had been 14751 (a greater low - that gave me hope that the next up move would split the resistance at 14765). At 10:18 the price again broke over 14760 and after a few seconds hit on a high this period of 147685. So, what we had was a rally attempt to move higher - I was encouraged that it would meet my Limit orders. The price fell back again to 14750 - 3rd failed attempt. At 10:34pm there was a strong up move bar that went to a high of 147674 from a low of 14751. That pub is the one where I should have entered the Cease Orders - since on the strong bar you are aware that the price will just do 2 things - 1) move firmly to the upside - or two ) move strongly to the downside. I really only had about 10 seconds prior to the move took more than NOT enough time to put 5 Sell Stop orders until the price fell back under 14765. But - I possess the EA pop and would have had sufficient time with the EA open to click Stop trades just those before the price started falling. By 11:28 (less than an hour after ) the price was down to 14665 - 100 pips in where the highest of the market stop orders would have gone .

identired
21:37,
91718 This is a screen shot of a series of gbp/nzd transactions that I simply closed from a demo account. I shut them early (before the take profit that I typically look for) because I've had enough fun for 1 night... The very best in the show closed for 112 pips, and the worst for 37 pips. However, as it happened , it did pick up all of the Sell Limit orders and each of the sell orders, so there were 10 trades. Total pips = 695 At one point I might have really put in 2 extra Sell Limit orders as the price went 20 pips higher than the pile of orders I had placed - but I wasn't paying attention and missed it. At a live account, there would most likely be a little bit of slippage hit and miss about the transaction entrances and exits - therefore the amounts wouldn't be nice and round and easy to read as in this example. ... .... Uhmm, I just realized I do not know how to join the jpeg file within this message platform - can not get it to glue in a clip board pic either... oh well, sorry you can not see it.
https://forexintuitive.com/attachments/15194146411983278198.png
https://forexintuitive.com/attachments/151941464794504472.png

identired
22:58,
91718oh... I guess it worked after all but I did not mean to article 2 of them... oh well.

CarGa13
00:19,
91718
oh... I guess it worked after all - but I did not mean to article 2 of them... oh well. Impressive.

From my side, I've the logic flowchart done. It looks good but I need to play with a little with it to see whether there aren't mistakes, then I will post it so that you can have a look at it and double check.

CarGa13
01:40,
917183 Structure (s) This is your logic, it appears fine but it's good if you double click it.

The code will follow...

https://forexintuitive.com/attachments/1519414624.png

https://forexintuitive.com/attachments/15194146511681997065.png

https://forexintuitive.com/attachments/1519414653656310118.png

CarGa13
03:00,
91718 Limit Orders only use instance:

https://forexintuitive.com/attachments/1519414656836003702.png

CarGa13
04:21,
917181 Structure (s) And Stop Orders Merely use case:


https://forexintuitive.com/attachments/1519414658166684812.png

identired
05:42,
91718I will require some time to check at this. I hope that I'm smart enough to know it!! Thank you for all your hard work up to now!! And, have a good weekend when we do not join before then.

identired
07:03,
91718There is only 1 thing I see where I believe we've had a miscommuniion - where it had been because of my own wording, and when so I can see. I'm questioning education that is R10. Whenever there are orders placed - be it because ofa) using stop orders just OR b) with both limit and stop orders, Cease orders - if qualifying to be transferred will just move in 1 direction. They will move again if they're being transferred again in the same direction once transferred. They will NOT ever move forward and then be transferred backward.

Example: If a market scenario has been initiated for a Use Sell Stops Only transaction, along with the Target price was 1.2345. The first placement of the Economy Stop Orders must include 1.2340, 1.2335, 1.2330, 1.2325, and 1.2320. IF the current price continued to go higher, and reached 1.2355 BEFORE some of the Sell Stop orders had be triggered, the all 5 could move higher by 10 pips. Once put at this new degree, they'd stay there until triggered - or would proceed again - but just higher - when the current price moved higher by another 10 pips.

In a scenario where after the 5 Market Cease Orders are put, let us state that the current price dips and activates the highest Sell Stop Order in the series - which in the situation above would be the order at 1.2340 - therefore it's become an active commerce. But , the current price rallies greater and gets up to 1.2355. The 4 remaining Sell Stop Orders will all move upward by 10 pips getting: 1.2345, 1.2340, 1.2335, and 1.2330. These orders will stay in this place until they are triggered since trades - or until the current price reaches 1.2365. As you can see - IF the price began to fall significantly at the point it'd yield two trades that would enter at the same price point of 1.2340 - but that is okay if it will. And the current price will proceed that more than two can trigger at the same price.

Stop Orders for Promotion scenarios will ONLY move UP.
Cease Orders for Buying Scenarios will ONLY move DOWN.

But anyhow , this is the only place where I believe we may have a problem - but it might be that I am just not reading the Logic Chart correctly (because I'm not astute on programming. If there was some confusion I can see where it had been due to where I composed the following:
. . .Again - in this situation, it might work out that the price could pick up one or even a number of the orders - then move again - to the point where the EA will be moving the orders before going. This may cause a situation where you have duplie or multiple orders being filled at exactly the same price point - but that is okay.)))]
That I SHOULD HAVE SAID:before THE PRICE begins going again

I hope I have not caused too many issues!!

I still can't believe you have this much in 2 days! You are my hero!

Thank you, thank you,
Mindy

identired
08:24,
91718One more consideration - only to be clear...

When Stop Orders are placed - in almost any circumstance - there will just be 5. No stop orders will be added - even in a situation where all 5 are at a negative p/l state and might have triggered as trades.

Only additional Limit Orders can be added to complete over 5.

CarGa13
09:44,
91718
There is just one thing that I see where I believe we've had a miscommuniion... No miscommuniion difficulty as I understood exactly the same. Stop orders proceed like tracking stops, they don't return to previous levels.

In my flowchart, Push TargetPrice 10 pips means we monitor next level which is 10 pips off, when that new level is reached I state Pull stop orders by 10 pips the word pull meaning to bring nearer by 10 pips. So we proceed in the direction of the price.

I used push/pull wording so it works in both scenarios sell and buy.



Another idea - just to be clear... When Stop Orders are placed - in almost any scenario - there will just be 5. No additional stop orders will be additional - in a scenario where all 5 are in a state and may have triggered as trades. Only additional Limit Orders could be added to complete more than 5. That's exactly what is in the flowchart, as soon as they are opened, we're done together with all the stop orders. That's why there's a test Stop Orders Present?

So that it is seems that I'm 100% aligned with your first wishes.

Take some time to read the chart carefully, you'll receive more used and see that it does exactly that.

identired
11:05,
91718ok - then all is great - I just was not sure. Thank you a million times, Mindy

CarGa13
12:26,
91718Hi Mindy,

There is still 1 instance (at least) we haven't yet discussed. Let's take the Market situation with stop orders simply, our initial target price is 1.2340, so we have initial orders entered at 1.2335, 1.2330, 1.2325, 1.2320, 1.2315

At this point the EA is tracking 1.2350 price in order to move up the halt orders by 10 pips after we're there, however:

Imagine if the price activates the 2 first orders (1.2335 and 1.2330) and then goes back up to 1.2340, so it transferred 10 pips north from 1.2330. Do we need to move the remaining ceases by 10 pips or wait for the move in 1.2340 to 1.2350 to achieve that?

identired
13:47,
91718No - it might continue to maintain the transfer goal still at 1.2350. So - unless the price moved above 1.2350, the first list of Economy Stop orders will remain in effect.
So, if the price went down and picked up the initial two at 1.2335, and 1.2330 - subsequently transferred up to 1.2340 (or any number between 1.2340 and 1.2349) we would have 2 trades that would have a negative p/l and 3 pending orders under. In the event the price moved up to 1.2350 - and moved the pending orders up by 10 pips to 1.2335, 1.2330 and 1,2325 - we might get a situation where we might have 2 transactions pick up at the 1.2335 and 1.2330 slots.
But, if the price moved directly up to 1.2365 after picking up the first 2 - then we would have the 3 remaining orders now at 1.2345, 1.2340, and 1.2335 (again leaving up with a duplie fill at 1.2335 if the price dropped out there.

CarGa13
15:07,
No - it would continue to keep the transfer target still at 1.2350. So - unless the price moved over 1.2350, the original collection of Sell Stop orders will remain in effect. Consequently, if the price moved down and picked up the first two at 1.2335, and 1.2330 - subsequently moved back up to 1.2340 (or some other number between 1.2340 and 1.2349) we would have two trades which could have a negative p/l and 3 pending orders under. If the price moved up to 1.2350 - and moved the pending orders upward by 10 pips to 1.2335, 1.2330 and 1,2325 - we might end up with a situation where we... Fine! This is what is in the flowchart however I wished to be sure.

I should be able to offer a very first variant of the EA, this week.

identired
16:28,
91718that will be amazing!! I am so excited about it.

CarGa13
17:49,
962331 Structure (s) Ok, found and corrected a small bug in the logic and...

Here is a first version for you to test, of course, on demo account ...

https://forexintuitive.com/discussion-trading/97926-working-financial-industry.html

Edit: Source code will be posted in a later time when declared operational and virtually bug free.

identired
19:10,
My gosh - I never dreamed we'd be at version to test this! You're AMAZING!! I shall try it tonight and let you know what happens... A zillion times thank you!!

identired
20:30,
91718Bingo!! Worked like a charm... Picked up 1 Limit Order - then 1 Cease order - then 1 limit Order - then the remaining stop orders... PERFECT! I added a stop on all when the lowest trade was 5 pips profitable... and each of them stopped out within seconds thereafter.

identired
21:51,
91718 https://forexintuitive.com/attachments/15194145881999466264.png

identired
23:12,
91718I'm so excited... I am gonna go find another one... This is FUN!!! BrokeTrader - you are shortly going to have to change your name!

CarGa13
00:33,
91718
I'm so excited... I'm gonna go find another one... This is FUN!!! BrokeTrader - you are shortly going to have to change your title! Great ! Thank you.

It'd be helpful to check all the situations so we can shut this first 1. XX launch:

1 Economy Scenario. 1.1 Limit Orders only. =gt; Verified, OK 1.2 Cease Orders only. =gt; Verified, OK 1.3 Limit Stop orders. =gt; Verified, OK 2 Buy Scenario. 2.1 Limit Orders only. 2.2 Cease Orders only. 2.3 Limit Stop orders. =gt; Verified, OK
So based on your previous article, we can state that the 1.3 is confirmed and OK.

Edit: Updated based on articles #208 and #209
Edit 2: Updated according to articles #218

identired
01:54,
91718yes - that I shall test each as opportunity presents.

identired
03:14,
91718Sell Scenario - Stop Orders Only - works (chosen'em up - then proceeded greater than all and DID NOT add more - which is right!!

identired
04:35,
91718Sell Scenario - Limit Orders Only - WORKS - placed 5 inserted one to the stack's peak - that's correct!

CarGa13
05:56,
91718Updated post #206 far so good.

identired
07:17,
91718I've been up all night hoping to find some buy situations . All 3 cases of buys have entered their orders.

The buy scenario, both limit and Stop orders, opened it has limit orders and thus far has not been low enough to initiate the first Limit order so hasn't yet added the stop orders.

The buy scenario, Cease orders only, placed the 5 Cease orders and has pioneered 3 of these as transactions - but didn't proceed far enough to transfer any of those orders so that I do not know whether that works.

The buy scenario, Limit orders only, placed 5 orders but then moved and didn't as initiate any of these into open positions.

So, what I do not know yet for the Buy scenarios is whether the orders will proceed correctly or if it will add additional Limit orders.

But so far this is VERY very good, and I've had even more affirmation that the sell scenarios are working beautifully.

identired
08:37,
91718I don't have a last answer as to the Buy situation situations as the market prices on the pairs I have tested hasn't cooperated. But one thing I have noticed is that as soon as you add the EA to some chart - DO OT CHANGE THE TIME FRAME OF THE CHART as for some reason it changes the target amounts. Do not know why - as long as we know this it won't be an issue - but I needed to let everyone know about it.

As an update - on the pairs I did trade last night, I had 5 or 4 series of trades open - and I was adding stops on them as soon as the profitable trade from the series was profitable - then attempting to maneuver the stops to improve profit as was possible - but I shut so far 549 pips so far. Not a bad night in my view!! So, my conclusion is that BrokeTrader is a genius!

CarGa13
09:58,
917181 Structure (s)
I don't have a last answer as to the Buy situation situations as the market prices on the pairs I've examined has not cooperated. But one thing that I have discovered is that once you put in the EA to a chart - DO OT CHANGE THE TIME FRAME OF THE CHART because for some reason the goal amounts change. Don't understand why - and as long as this is known by us it will not be an issue - but I needed to let everybody know about it. As an update - on the pairs that I did trade last night, I had 4 or 5 string of trades open - and I was adding stops on them as soon as the... Well, I did not think of this time period change attribute, so I've done some adjustments to a new version you will discover below.You can freely change the time period on your chart, this won't change the EA parameters. You can also, and without unloading/reloading the EA, alter its parameters or by clicking on the chart and picking Expert Advisors gt; Properties. The functioning parameters were displayed in white (because I use a black chart background), but now you have the ability to chose any font color through the parameter Text Colour Oh, thank you but If I had been a genius, I would have shot with me from this lamp the formulation to make those pips you talk about The thought was yours, I only translated it into code.

Here is the new version, let us hope that you will have the ability to test the buy scenario shortly.

https://forexintuitive.com/forex-trading-and-cfds/97951-sris-journal.html

identired
11:19,
91718BT - I have a few things since it had been prior to this change. I think I will leave it be until those items close out. I shall switch to the new edition. Seem WONDERFUL and I can't wait to test them. Can there be a way that we (you and I) could have a personal conversation? I really don't know - however I'd be happy to provide you with my email or contact number. Allow Me to know... Mindy

CarGa13
12:40,
91718
BT - I have a few things working in the EA as it was prior to the shift. I think I will leave it be until those things close out. Then I will switch to the new version. The changes you mention seem WONDERFUL and I can not wait to test them. Is there a way we (you and I) could have a private conversation? I don't know much about how these message boards work - but I'd be happy to give you my email or phone number. Let me understand... Mindy I could send you a private message but actually I cannot. You have to alter your profile preferences to allow getting messages.

identired
14:00,
91718OK - I think I changed the Atmosphere... m

CarGa13
15:21,
91718
OK - I believe I changed the setting... m Yes, message delivered.

And for your test, you are right. Keep your current evaluations going and take the new EA just after those evaluations are terminated. I haven't changed anything at the logic made those cosmetic changes I talked earlier.

identired
16:42,
91718OK - The Buy situation with Use both Stop and Limit Orders is currently WORKING fine - transferred the Stop orders, added limit orders and did not create stop orders - check this one off the list.

CarGa13
18:03,
91718
OK - The Buy situation with Use both Limit and Stop Orders is WORKING fine - transferred the Cease orders, added more limit orders and failed to create extra stop orders - check this one from the list. Done still in place #206 (It's great that I still can edit it).

identired
19:24,
91718Maybe copy and paste it down to some newer message before it gets off...

identired
20:44,
Buy scenario - Stop Orders only - works. Verify that one off...

Still no answer on Buy situation - Limit orders only.

CarGa13
22:05,
96233So here is the new standing:

1 Economy Scenario. 1.1 Limit Orders only. =gt; Verified, OK 1.2 Stop Orders only. =gt; Verified, OK 1.3 Limit Stop orders. Gt; Verified, OK 2 Buy Scenario. 2.1 Limit Orders only. =gt; Verified, OK 2.2 Stop Orders only. =gt; Verified, OK 2.3 Limit Stop orders. =gt; Verified, OK...

Edit: Updated according to article 223

identired
23:26,
91718Finally... I can say with assurance that the Buy Scenario - Limit Trades Only - WORKS fine. Check that puppy off the list!

You understand - what would really be nice would be to have some type of audible when a situation initiates it's first order so that it would call my focus back to it. Also maybe an audible when all open transactions at a string become profitable... Don't know how much work that would be, I'm just dreaming about perfection - and that is just a suggestion - not a request.

CarGa13
00:47,
91718
Finally... I can say with assurance that the Buy Scenario - Limit Trades Just - WORKS fine. Check that puppy! You know - what would be nice is to have some type of audible when a situation initiates it's first order so that it would call my focus back. Also perhaps an audible when all open trades in a string become profitable... Don't know how much work that could be, I'm just dreaming of perfection - and that is just a proposal - not a petition. Oh that's fine, post upgraded.

And all works as expected, it is not an issue adding some cool capabilities.
Next version coming soon...

maneger
02:07,
91718Great thread congratulations!
Do you know a quicker way to debug MQL code apart from using the print or comment functions.
I understand about using the debugview tool but I was wondering in the event that you happen to be using something better for a more organized approach to testing and debugging.
thanks!

CarGa13
03:28,
91718
Great thread you have here, congratulations! Would you know a way to debug apart from using the print, MQL code or comment functions. I understand about using the debugview tool also but I was wondering in the event you happen to be using something better to get a more organized approach to testing and debugging. thanks! Hello tradista,

No, that I actually use exactly the same. I also printout on the display when you can I step into the code and some variables such as a watch window does in a debugger when I need but you need to get connected for that.

Alternatively, there's another tool you may also consider which is writing https://en.wikipedia.org/wiki/Unit_testing, they allow to confirm that every bit of code does what it is supposed to do and greater than that, the allow you to confirm that you don't create regression when modifying such code. This may be a next article on this particular thread's topic.

CarGa13
04:49,
91718
Hey ! As you have been active helping with her expert, I'd posted a query about an issue on stackoverflow. It sounds nobody there has any thoughts. This is a situation that is really odd. Basically, I have completed my indior, and the indior can't locate the function in the dll. I have verified, using an app called the Dependency Walker, the function name hasn't been mangled. In short, I can't find any reason why the function name can not be found by the indior. If you're interested in... From what I see, there's absolutely no announcement of the function but only it's body.

Try this on your dll origin:

Inserted Code // Declaration extern C MT4_EXPFUNC bool __stdcall LiveChart( bla, bla, bla ); // Definition MT4_EXPFUNC bool __stdcall LiveChart( bla, bla, bla ) Observatory astronomer; reunite astronomer.OnCalculateLive( bla, bla, bla );

CarGa13
06:10,
91718Hi MehZhure,

Sometimes some lines of code are better than a thousand words. Could you post a little instance of your C and C# code which makes your Ninjatrader to wreck, so I could replie locally?

It is long time I haven't played with C#/C therefore it's difficult to respond as is.

CarGa13
07:30,
96233Instead of passing the values back, where your DLL will write it is possible to modify the first ones or offer a ref to an empty struct.

I think this should solve your problem.

Here is the C# code, not Ninja but Visual Studio:

Inserted Code using System; using System.Collections.Generic; utilizing System.Linq; using System.Text; using System.Runtime.InteropServices; namespace DLLTest #91;StructLayout(LayoutKind.Sequential)#93; public struct TestStruct public int x, y; class GetDLL GetDLL() ~GetDLL() #91;DllImport(DLL.dll, CallingConvention = CallingConvention.StdCall, EntryPoint = TestFunk)#93; public static extern TestStruct TestFunk( ref TestStruct x, ref TestStruct y ); class App static TestStruct#91;#93; testy = new TestStruct#91;two 93;; static void Main(string#91;#93; args) testy#91;0#93;. X testy#91;0#93;. Y = 2; testy#91;1#93;. X testy#91;1#93;. Y = 9; GetDLL.TestFunk( ref Tip #91;0#93;, ref Tip #91;1#93; ); Console.WriteLine( X0: Tip #91;0#93;. X.ToString() Y0: Tip #91;0#93;. Y.ToString()); Console.WriteLine( X1: Tip #91;1#93;. X.ToString() Y1: Tip #91;1#93;. Y.ToString());
Here is the C code:

Inserted Code #define WIN32_LEAN_AND_MEAN #include lt;windows.hgt; #include lt;stdlib.hgt; #include lt;stdio.hgt; BOOL APIENTRY DllMain( HMODULE, DWORD, LPVOID ) return TRUE; struct TestStruct int x, y; ; extern C __declspec(dllexport) void __stdcall TestFunk( void *x, void *y ) TestStruct* ptX = (TestStruct*)x; TestStruct* ptY = (TestStruct*)y; ptXx = 1; ptXy = 1; ptYx = 1; ptYy = 1;

CarGa13
08:51,
96233
Nope. I tried it and got the following error message. quote Sorry, I forgot to remove the TestStruct return kind from the C# declaration.

Correct for this:

Inserted Code... course GetDLL GetDLL() ~GetDLL() #91;DllImport(DLL.dll, CallingConvention = CallingConvention.StdCall, EntryPoint = TestFunk)Number 93; public static extern void TestFunk( ref TestStruct x, ref TestStruct y ); ...

CarGa13
10:12,
Woohoo! Success! Thank you! Now, I am going to need to examine this and see if I can figure out how to use it to some 100,000 element struct array. It doesn't matter wether you've got 1 or 1 million elements, you are just passing a reference to the c function, nothing more.

CarGa13
11:33,
quoteThis is, of course, based on the knowledge that information created within a purpose is ruined after that function returns. Not necessarily.

You have to be aware there are two kinds of memory where data or objects can reside. The Stack and the Heap.

The Stack, is the one you are talking about. It's memory that stores temporary variables created by means of a purpose and once the function exits, all of the memory for those variables is freed:

Instance:

Inserted Code struct TestStruct int x, y; ; TestStruct* TestFunk() TestStruct A; // This resides on the stack. A.x = 1; A.y = 2; return ;
This code compiles but is completely wrong as we return the address of a construction that will be discharged when exiting the function.
It's intriguing to note that modern compilers provide you a warning about this. This is what Visual Studio says:
warning C4172: returning address of local variable or temporary

Then you have the Heap memory at which you can alloe data/objects that have to be obtained explicitly. The memory is alloed by calling the new operator or some of the alloc (malloc,calloc) purposes of the standard library.

This is the right code:

Inserted Code struct TestStruct int x, y; ; TestStruct* TestFunk() TestStruct* pA = new TestStruct; // This resides on the heap. PAx = 1; pAy = 2; return pA;
Here the information pointed to by pA is not freed when exiting the call. It's the obligation of the code getting the pointer later to that memory. This time the compiler is happy and does not create any warning.

CarGa13
12:53,
Well, you are learning.

You can also declare the function with the right type from start and use the indexing operator ([]) rather than incrementing the pointer.
A fantastic idea is also to pass the amount of elements in your array, which means you don't get the job done blindly about the C side.

C# code

Inserted Code namespace DLLTest #91;StructLayout(LayoutKind.Sequential)#93; people struct TestStruct public int x, y; course GetDLL GetDLL() ~GetDLL() #91;DllImport(DLL.dll, CallingConvention = CallingConvention.StdCall, EntryPoint = TestFunk)#93; public static extern TestStruct TestFunk( ref TestStruct x, int arraysize ); class Program static TestStruct#91;#93; testy = new TestStruct#91;293;; static void Main(string#91;#93; args) testy#91;0#93;. X = 10; testy#91;0#93;. Y testy#91;1#93;. X = 20; testy#91;1#93;. Y = 9; GetDLL.TestFunk( ref testy#91;0#93;, 2 ); // ref to first element in the array. Console.WriteLine( X0: testy#91;0#93;. X.ToString() Y0: testy#91;0#93;. Y.ToString()); Console.WriteLine( X1: testy#91;1#93;. X.ToString() Y1: testy#91;1#93;. Y.ToString());
C Code:


Inserted Code #define WIN32_LEAN_AND_MEAN #include lt;windows.hgt; #include lt;stdlib.hgt; #include lt;stdio.hgt; BOOL APIENTRY DllMain( HMODULE, DWORD, LPVOID ) return TRUE; struct TestStruct int x, y; ; extern C __declspec(dllexport) void __stdcall TestFunk( TestStruct* pts, int arraysize ) for( int I=0; ilt;arraysize; I ) pts#91;I#93;. X = 20;

PapaDave1
14:14,
Utilizing MetaTrader 4's MetaEditor, can I use courses from MetaTrader 5? Looking thru the MQL5 Reference aid, there is a Standard Library of courses that does now appear in the MQL4 Reference. Can I use the MQL5 Standard Library classes through my MT4 Editor?

For example where would be the header include files for the MQL5 Trade Courses, state SymbolInfo.mqh? I don't have them

CarGa13
15:35,
Utilizing MetaTrader 4's MetaEditor, can I use classes from MetaTrader 5? Looking thru the MQL5 Reference help, a Standard Library is of classes that does now show up at the MQL4 Reference. Can I utilize the MQL5 Standard Library classes via my MT4 Editor? For example where are the header say SymbolInfo.mqh? I really don't have them in my MQL4 Include folder structure??? Hi idiamond,

I think that the MQL5 library will be used within MQL5, which is why you don't find those classes in the MQL4 environment.

PapaDave1
16:56,
quote Hi, I believe the MQL5 library is to be utilized within MQL5, which is why you don't find those courses in the MQL4 atmosphere. Yeah researching further it appears that the Trade courses from MQL5 are incompatible with MQL4. Thanks brokertrader.

Mike23
18:17,
Broketrade, I really enjoy the work you are doing in the forum, I have learnt a lot from reading this thread. Keep up the fantastic work.

CarGa13
19:37,
1 Attachment(s) Thank you jedds, I still have any chapters to add, maybe in September when I have time...

And for those interested, attached is the midiyost EA source code as described starting at post #155

https://forexintuitive.com/forex-trading-and-cfds/97955-30-15-journal.html

identired
20:58,
I only want to say THANKS again to BrokeTrader for this WONDERFUL EA! For my trading style, it's become the ideal solution to help me in maximizing profits in my entry signals. I hope that everyone else is enjoying success from it as well.

Fonsi20
22:19,
Man... broketrader, the man! Thank you for this 13 pages
I'm considering design of grider (really I have it but in function badcode style coding ) in OOP. We can try to consider it here together. In case you have interest of course.
MindyEA makes a grid in one direction, grider create the grid of pending orders in two directions at exactly the exact same time
My thoughts for starting:

GridClass
one chart can have 1. . N grids. Or may be one grid for EURUSD, you for USDTRY, etc..
It may have more than 1 type of grid setup (one in one case ):
1. Like MindyEA with some measures from some level
2. Fibonacci amounts
3. A few other formulas that generates levels array

LevelClass
Serve to store 1. . N Orders inside it.
Each concrete Level linked to concrete Grid (can be grid have to know it's amounts for some reason...)

OrderClass
Deliver market or pending orders.
Linked to Level.

Inserted Code course Grid protected: string gridSymbol; // EURUSD,USDTRY, etc.. Public: Grid(string symbol) gridSymbol = symbol; string getSymbol() return symbol; bool buildGrid() //some algo code for construction amounts in grid ;
Inserted Code course Level protected: Grid* linkedGrid; double price; Order* orders#91;#93;; people: Level(Grid* grid, double levelPrice) linkedGrid = grid; price = NormalizeDouble( levelPrice, Digits ); Grid* getGrid() yield linkedGrid; bool addOrder(Order* order) // code for adding orders // may be like CList arrays ;
Inserted Code class Order protected: int m_TicketNumber; int m_MagicNumber; dual m_OpenPrice; dual m_Lots; Order( int magicnumber ) m_MagicNumber = magicnumber; m_TicketNumber = -1; ;
Am I correct with my code/thoughts?
How can we perform dynamic configuration of this Grid::buildGrid()?
MQL since I know did not have outstanding functions (may be someone did not know, it is like in JavaScript, you can place function for a parameter or return a function in function) So what can we do together with MQL4 in that circumstance? The very first thing that comes to mind, create buildGrid() as an abstract function (virtual in MQL words if I right) and create GridFibonacci course, GridStepped course and any additional grid configurations with this scheme that implements concrete algorithm. Is that ok?

Also, may be you thought about it already. I'm presuming that in some circumstances this would be good to create some Observer pattern for MQL Expert. By way of example, some order is shut by SL or TP and Observers get informed about it to do some things. It is real with replicating the functions in courses (as I understand), but may be there is better way?

Thanks once more

P.S.. If you interested we can try to execute principal OOP patterns for community. If we could envision situations for them

sofiasanchez22
23:40,
Hi BT - Much like your thread. I've got one small issue. How do you return an array from a method? The code below throws a compile error'invalid range access' for int Days[](). I'm proficient in C# not C . Thanks. Bill

Inserted Code class DataManager { private: int _times #91;#93;, _price#91;#93;, _and #91;#93;, _minus#91;#93;; public: DataManager(){}; emptiness AddArrays(int times #91;#93;, int price#91;#93;, int and #91;#93;, int minus#91;#93;-RRB-; int Date(int index); int Price(int index); int Plus(int index); int Minus(int index); int Days#91;#93;-LRB-) yield _times; };

CarGa13
01:00,
Hello MrTwister, billmac,

Sorry for responding late, I have been quite busy with other matters...

MrTwister, I will not elaborate in your proposal since I really don't have time now for it, sorry, I hope that you understand.

Billmac, I presume you have found an answer about your selection problem but I will respond anyway as this may be handy for other people to know.

There are two solutions to your problem. First is passing a reference to an external array and copy the information to that array.
Illuion:

Inserted Code void Days( int arr#91;#93; ) arr#91;0#93; = _times #91;0#93;;
The next solution, as not too many know, you cannot return reference or pointers to native types in MQL, but it's possible to take action to user defined types like classes. By doing so, you manipulate always the same array rather than copying it each time you call the'Days' method.

Meaning you need to create a class that encapsulates the selection, declare an object of the class in your DataManager class and then return a pointer to that object.

Illuion:

Inserted Code // Encapsulation class class IntArray public: int Data#91;#93;; ; class DataManager private:... IntArray m_Days; public:... IntArray* Days() yield m_Days; ;
Utilization:

Inserted Code DataManager DM; IntArray* pDays = DM.Days(); pDays.DataNumber 91;0#93; = 0;
BR/BT

CarGa13
02:21,
Hello All,

At some point, composing professional or complex progr will necessitate to bring some infrastructure to programmatically test a maximum of pieces of code in your program. In OOP, the majority of the time these pieces are only object methods and in the test jargon, these pieces are referred as units (units of source code) that may be separately tested to verify that they meet their intent. Hence the title of Unit Testing.

In the next posts I will go through the creation of a Unit Testing EA which I will use to check several parts of the Mindy EA for illuion functions only.

That I will try to illue the next points/advantages of device testing as well as the proposed solution:Writing a separate EA allows to maintain the original almost untouched, only some #ifxxx markers will be needed in our first EA without needing a bit of the major source code. Of course, These markers will have no effect in its own standalone implementation.
. We'll conduct our evaluation in the initialization code of our tester EA which means that we won't require any tick to conduct it.
. Useful to debug/execute step-by-step code which helps greatly to understand everything your EA is doing.
Of course, not every line in your EA will be suitable for tests, you will find things that depend for example on the environment which only can't be examined as is. But you'd be surprised by the quantity of code that may eventually be tested as long as the developer had the device testing in his mind at the time that he writes his code.


To be continued...

CarGa13
03:42,
Lets proceed with our tester EA step.

1) Download the MindyEA 1.01, copy it in your Experts folder and compile it.
.
2) Produce a new EA using the MetaEditor wizard, name it MindyEATester and maintain all default options.
.
3) Erase everything in the new created EA and also add the following line of code:

Inserted Code #include MindyEA-1.01. Mq4
Maybe that looks strange if you aren't used to this but it is perfectly legal to include an whole EA into another EA.

Try to compile MindyEATester today, it should compile without any issue.

Now that we have our new MindyEATester EA we'll include the OnInit method which will serve as entry point for our tests.

Of course, when we will do it, it will be in conflict with the OnInit function present in MindyEA-1.01. mq4 file.

So we have somehow to avoid having two OnInit roles in our expert EA. We'll see how to achieve this in the next article...

CarGa13
05:03,
This brings us to the notion of Conditional Compilation

Conditional compilation is effective at pre-processing moment. Pre-processing instructions are the ones which are followed by the'#' character such as the #include statement for example which is familiar to all people.

Pre-processing point is executed by the compiler right before the compilation itself significance that all #xxxxx statements are processed and read at that point.

To achieve our conditional compilation, we'll utilize the #ifxxx statements, the #ifndef statement more precisely.
The'if' prefix means that we're in front of a conditional pre-processing statement. Be aware that these #if statements should be terminated by an #endif statement.

This provides the potential for excluding or including blocks of code but how?

Here is an example:

Inserted Code #ifdef ABCD // some code here #endif #ifndef ABCD // some code here #endif
In such fast examples I illue that the #ifdef and #ifndef statements that mean if defined and if not defined accompanied by a variable. This factor can just be defined from the #define statement as shown below:

Inserted Code #define ABCD
So, the way to not compile the OnInit function that's present in the MindyEA-1.01. Mq4 within our tester EA is to surround it with a #ifndef statement such as this:

Inserted Code #ifndef UNIT_TESTS int OnInit() ... void OnDeinit(const int reason) ... #endif
Note I also have included the OnDeinit function. This is because after the OnInit will probably be excluded, we don't want OnDeinit destroying objects that were not created.
Again, this has no impact whatsoever on the MindyEA-1.01. Mq4 itself since the UNIT_TESTS factor is not defined in it, these functions will be compiled just like before.

And define the variable in the tester EA such as this:

Inserted Code #define UNIT_TESTS

Here is the new code of our tester EA:

Inserted Code #define UNIT_TESTS #include MindyEA-1.01. Mq4 int OnInit() return INIT_FAILED;
Now we have two EAs that are almost the same but that have distinct OnInit functions, isn't that cool?

The tester EA (MindyEATester) is now prepared to utilize any tested EA (MindyEA-1.01. Mq4) object for any test purpose.

CarGa13
06:23,
Time to write our tester course.

It's main task will be to examine EA methods for almost any desirable object and we will write a dedied technique for each specific test. We'll also count the number of tests we all perform and just how many of them have failed.

This course will also have a public method called'Test' that is going to be the only one being needed to be called in order to perform all our evaluations.

This is the unit tester course:

Inserted Code course UnitTester int m_TestCount; int m_FailedTests; people: UnitTester() m_TestCount = 0; m_FailedTests = 0; void Test() MessageBox( StringFormat(%d Tests done,%d Failed., m_TestCount, m_FailedTests), Unit Tests ); ;
and the Way the Evaluation method is called in the OnInit function:

Inserted Code int OnInit() UnitTester UT; UT.Test(); return INIT_FAILED;

CarGa13
07:44,
And now's the time to include tests to our tester unit class.

We'll concentrate on the Price class and particularly if the Push method works correctly in both buy and sell scenarios. I wrote that method to transfer a target price where new limit orders should be entered.

For buy orders, when pushed by x pips, the new price worth has to be lower by x pips than preceding price. For sell orders, when pushed by y pips, the new price worth has to be greater by y pips than preceding price.

So it's intriguing to test this Push method for both buy and sell scenarios and assess whether the price moves so to what we anticipate. Let us write a TestPricePushBuy() method and a TestPricePushSell() method.

The two of these will instantiate a Price object with any desirable price for evaluation, they'll push that price by any worth in pips and then check the consequent price corresponds to that which we could easily compute. Here is how this translates into code,

TestPricePushBuy method:

Inserted Code void TestPricePushBuy() Price P( BUY, 1.0020 ); P.Push( 16 ); if( P.Value() ! = 1.0004 ) // Test failed. Update statistics and return // Test succeeded, update data
Here's what this litle evaluation method will:

1. We create a Price object that will function for our evaluation functions. The situation is BUY and the initial price is 1.0020.
2. We call that the Push method of the Price object to push the price by 16 pips, this will lower the price contained in the Price item by 16 pips.
3. We do our evaluation. We confirm the Price is different than 1.0004 to declare the test has failed.

In order to update our statistics and make our evaluation code a bit more readable, I'll declare a macro which does everything in a single line. Here it is:

Inserted Code #define SAVE_RESULT(val) m_TestCount ; if(! (val))m_FailedTests ;return;
And lastly here is the way our closing TestPricePushBuy method resembles with a bit of comment to record the evaluation:

Inserted Code // pushing the price in a BUY scenario lowers its value. Void TestPricePushBuy() Price P( BUY, 1.0020 ); P.Push( 16 ); SAVE_RESULT( P.Value() == 1.0004 );
And here is your TestPricePushSell method:

Inserted Code // pushing the price in a SELL scenario lowers its value. Void TestPricePushSell() Price P( SELL, 1.0020 ); P.Push( 16 ); SAVE_RESULT( P.Value() == 1.0036 )
Finally we call these methods in the Evaluation procedure and we are done.
Beneath, the complete MindyEATester code source:


Inserted Code /* gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt ;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;g t;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt; gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt ;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;g t;gt;gt;gt;gt; Mindyyost Tester EA Copyright (c) 2015,, Switzerland. HISTORY: 1.00 / / / 10.11.2015 Tests EA Publish lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt ;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;l t;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt; lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt ;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;l t;lt;lt;lt;lt;*/ #define UNIT_TESTS #include MindyEA-1.01. Mq4 / / ************************************************** **************************************** Global macro definitions ************************************************** ****************************************/ #define SAVE_RESULT(val) m_TestCount ; if(! (val))m_FailedTests ;return; / / ************************************************** **************************************** Tester Class ************************************************** ****************************************/ class UnitTester int m_TestCount; int m_FailedTests; public: UnitTester() m_TestCount = 0; m_FailedTests = 0; // pushing the price in a BUY scenario lowers its value. Void TestPricePushBuy() Price P( BUY, 1.0020 ); P.Push( 16 ); SAVE_RESULT( P.Value() == 1.0004 ); // pushing the price in a SELL scenario lowers its value. Void TestPricePushSell() Price P( SELL, 1.0020 ); P.Push( 16 ); SAVE_RESULT( P.Value() == 1.0036 ) void Test() TestPricePushBuy(); TestPricePushSell(); MessageBox( StringFormat(%d Tests performed,%d Failed., m_TestCount, m_FailedTests), Unit Tests ); ; int OnInit() UnitTester UT; UT.Test(); reunite INIT_FAILED;

CarGa13
09:05,
1 Attachment(s) And that's what I get when I press on F5 (Debug Start) on the editor.



You see how simple it's implementing your own code without any tick from the server. Of course for inputting orders you will still need to be connected to a presentation server during market hours but you will be able to perform and test your code piece by piece.

This has been my introduction to unit testing.

BT.

identired
10:26,
Thank you BT for taking the time to teach us all. I believe what you posted only today is more info than we probably could have gotten from a 2 or 3 credit hour semester of programming in university. Your skills - both in doing and teaching are amazing! Thanks - m

CarlosFdez
11:47,
Issues with a Class Moving Average Cross:
Base Clase

// ************************************************** ************************************************** ***********************************
// SMA/EMA-Functions
// ************************************************** ************************************************** ***********************************
class CMTMA
{
People:
CMTMA(int timePeriod=100, ENUM_MA_METHOD maMethod=MODE_EMA,ENUM_APPLIED_PRICE applied_price=PRICE_CLOSE)
p_timePeriod=timePeriod;p_maMethod=maMethod;p_appl ied_price=applied_price;...
New Class That Ought to handle the cross of Two moving averages:

// ************************************************** ************************************************** ***********************************
// SMA/EMA-Cross-Functions
// ************************************************** ************************************************** ***********************************
class CMTMACross
{
People:
CMTMACross(int timePeriod1=2,int timePeriod2=4, ENUM_MA_METHOD maMethod1=MODE_SMA, ENUM_MA_METHOD maMethod2=MODE_SMA)
{p_timePeriod1=timePeriod1;p_maMethod1=maMethod1;p _timePeriod2=timePeriod2;p_maMethod2=maMethod2;...[QUOTE= [QUOTE= </blockquote> [QUOTE=
Just How Do I init the Span and maMethod in the constructor? [QUOTE= </td> </tr> </table>
<table class=”tborder” cellpadding=”6” cellspacing=”1” border=”0” width=”100%”> <tr> <td class=”page”> <table cellpadding=”0” cellspacing=”0” border=”0” width=”100%”> <tr valign=”bottom”> <td style=”font-size:14pt”></td> <td class=”smallfont” align=”right”>Dec 20, 2015 10:30am | Post# 264</td> </tr> </table> <hr /> Any Opportunity to alter this code for a random function? Function as pointer or parameter !
Would be fantastic!!
<div class=”frame”> <blockquote> <div class=”quotecontainer quote_”> <div class=”quoteauthor nolink”><span>Quote</span>[QUOTE= <div class=”quote quote--disliked hidden”><span class=”icon icon--dislike”></span> Disliked[QUOTE= <div class=”quote”>// ************************************************** ************************************************** ***********************************
// Debug-Function
// ************************************************** ************************************************** ***********************************
series AllValuesOfIndi(series InfoText,int actShift)
int I;series values;
values=;
for (I=0;ilt;8;I )
values=values I . : ExIndiIR.FullVal(I,actShift);
Alert(InfoText actShift values);
[/QUOTE]

Ander
13:07,
Subscribed and willing to learn from specialist

CarGa13
14:28,
Problems with a Class Moving Average Cross: Base Clase quote New Class which should manage the cross of 2 moving averages: quote How do I init the time and maMethod from the constructor? Hi reteid, could you please, rephrase your question or explain in more details as my English isn't so good and I have not realized exactly what your difficulty is. Thank you.

CarGa13
15:49,
subscribed and willing to learn from expert Hi kabir,

There's already a lot to go through at the precedent pages, if you have questions, do Not hesitate,

CarlosFdez
17:10,
The Way to use a Class A at the Course B Such as Java and make a call ?

Inserted Code class CA public: //CA() ; CA(int a) ; private: int a; ; class CB { public: //CB() ; CB(CA a) this.a=a; // Error int test() {} private: CA a(int a); }; bool test() CB x(CA);// ERROR also!

CarGa13
18:30,
the Way to use a Class A from the class B like Java and make a call of B? Class CA public: //CA() ; CA(int a) ; private: int a; ; course CB { public: //CB() ; CB(CA a) this.a=a; // Evidence int test() {} private: CA a(int a); }; bool test() CB x(CA);// ERROR too! Hi,

That's because you are assigning references to items. Bear in mind that MQL is not coffee or C so there's some constraints and among them is you could only assign items using pointers.

Please, next time indent your code so we all could read it more easily.

This is your answer:

Inserted Code course CA public: CA(int a) ; private: int A; ; course CB public: CB(CA *a) this.pA=a; int test() return 0; private: CA* pA; ; bool test() CA* a = new CA(two ); CB x(a); return ;

CarlosFdez
19:51,
Https://forexintuitive.com/attachments/15194145121854360476.png
Sorry original code has been inserted...I ll do it next time!

CarlosFdez
21:12,
Sorry original code was inserted...I ll do it next time!
https://forexintuitive.com/attachments/1519414501.png

Kin-Skywalker
22:33,
Gidday Broketrader, one hopes not. The first time wannabe indior maker, never coded anything before so this is all new for me. I've an idea I will be working on according to an indior coded to the pre 600 variants of mt4. Will be dropping in here for guie etc . I have got as far as compiling one line correctly. I assume compiling is how one saves his work. I got to flesh it out so it indies on chart, anyways,,,,,,,

Yolit
23:53,
Dear Brokertrader,
Dear Readers of the thread. I really don't know whether anybody is still online: I am just so sorry to have discovered this wonderful course so late!

I am posting anyhow for the seek of correctness, while following, one by one, the exercises. I am at the very start, place #24. There, I dread to have discovered an error in the code, that was somehow puzzling, actually.

In the OnCalculate purpose, you add both of these lines:

Inserted Code ArraySetAsSeries( MainBuffer, true ); ArraySetAsSeries( near, true );
I had been wondering if there was some strange reason, after having transferred the calculations into the class, for making them out right to left opposite since the very clean layout of this non-object-oriented variation discussed so far... and I realized that there is NO reason, along with the indior isn't correct with both of these lines. They should stay as they had been:

Inserted Code ArraySetAsSeries(MainBuffer, false); ArraySetAsSeries(close, false);
... or am I totally wrong?

On a side note, if anybody is still interested in replying, I'd have two questions:

1. The reason of this demand for the creation of the item pointer isn't clear at all to me. Is this something common at C , also it is only a workaround of some vague mql (C dialect) mechanism?

2. In the class definition and at the following declarations, why should the arguments be passed as const?

Thank you very much beforehand!

Yolit
01:14,
Dear people,

I understand that nobody is looking at this thread . However, for those who should eventually discover it in the long run, as I did, please have some debug already done.

In place #39, when placing two moving averages together, there's a mistake in the submitted MyMovingAverage.mqh file. The MyMovingAverage:Compute definition is wrong, because the change statement slips consistently in the exponential average calculation. Please take care and insert a break bewtween the SMA and the EMA cubes like this:

Inserted Code switch(m_Method){ case MODE_SMA: switch(m_AppliedPrice) case PRICE_OPEN: ComputeSma(totalrates, prevcalcd, available ); split; situation PRICE_HIGH: ComputeSma(totalrates, prevcalcd, high); split; situation PRICE_LOW: ComputeSma(totalrates, prevcalcd, low); split; situation PRICE_CLOSE: ComputeSma(totalrates, prevcalcd, close); split; split; situation MODE_EMA: switch(m_AppliedPrice) case PRICE_OPEN: ComputeEma(totalrates, prevcalcd, available ); split; situation PRICE_HIGH: ComputeEma(totalrates, prevcalcd, high); split; situation PRICE_LOW: ComputeEma(totalrates, prevcalcd, low); split; situation PRICE_CLOSE: ComputeEma(totalrates, prevcalcd, close); split;
This is for prevent to others debugging time. I hope Broketrader you do not get hurted because of this. Your work was anyway very strong and useful, sorry.

CarGa13
02:35,
Hi betterlife and sorry for replying so late...

For the ArraySetSeries question, well I believe I was making some tests and forgot to restore the appropriate code, I must dive right into the code actually to truly confirm this but simply don't have time at this moment...

Concerning some other questions...

1) Production of object pointers isn't compulsory at all, you could absolutely utilize automatic factors but the use of pointers gives you the possibility to pass them in to functions or other object methods. Thing which you cannot do if using automatic factors as you cannot pass references in MQL.

Two ) Passing argument as const implies that you prohibit the function or method of which you pass the argument to alter the source data. This can be helpful when passing pointers.

Great job for the switch statement mistake, I did not see it!

And don't worry, there's no offend at all.

Thank you !

Yolit
03:56,
Thank you very much Broketrader, and apologies for my late response also.
Your ribbon is really fine and I am going on in studying, utilizing it as functional examples while reading the Eckel's Bible of C . I am in the course of an intriguing project hoping to creating indiors modular, so you can pass the value to one into another and then into another and so on... Without using iCustom, of course, that can be pretty wasteful.

On a negative note, I also shifted all of the MyMovingAverage:Initialize method of the code in place #39 inside the constructor of MyMovingAverage itself. Folks state that the constructor was devised exactly for avoiding people to be forced of using initialization purposes... It works!

Jon
05:17,
Hi,
I want to pass an array from 1 indior document to some other indior. Can somebody pls. Guide on how to do it thru MQL code?
I utilize Globalvariable Get- Establish departure simple factors between indiors. But don't have any hint about arrays.

Due
Best Wishes,

CarGa13
06:37,
Thank you very much Broketrader, and apologies for my late reply also. Your thread is actually nice and I am going on in analyzing, utilizing it as practical examples while reading the Eckel's Bible of C . I am in the course of an intriguing project trying to creating indiors modular, so you can pass the value to one into another and then into another and so on... Without using iCustom, of course, which can be pretty inefficient. On a side note, I also altered all the MyMovingAverage:Initialize way of your code in place #39 inside the constructor... Hi betterlife,
Studying C is the way to go, good fortune and a lot of pleasure, do not hesitate if you've got questions.

Concerning the constructors, well, in reality it is dependent upon the context. For instance you could require an initialization method when you build your object just once but need to reset (reinitialize it) several times a program implementation instead of deleting it and creating a new one, you see the gap?


Hi, I want to pass a range from 1 indior document to another indior. Can somebody pls. Guide on how to do it thru MQL code? I utilize Globalvariable Get- Set for passing simple variables between indiors. But have no hint about passing arrays. Thanks Best wishes, Hi Tilltheend,
I never had to pass arrays between indiors and do not actually have a solution for you but I see two possible solutions you could explore:
1) Merge both indiors into a single, then no difficulty in sharing anything.
2) Use a C DLL to share data between them but I am not certain this will be possible.

Karras2627
07:58,
quote Hi Tilltheend, I never needed to pass arrays involving indiors and don't really have a solution for you but I see 2 possible solutions you could investigate: 1) Merge your two indiors into a single, then no difficulty in sharing anything. 2) Utilize a C DLL to share information between them but I am not sure this is possible. When the sender is an indior, a solution is to pass the factors through buffers and retrievable by the other indior through iCustom().

Jon
09:19,
quote If the sender is an indior, a solution would be to pass the variables via buffers and retrievable by another indior via iCustom(). Broketrader/....Thanks for replies....as of now I am trying to merge 2 indiors into 1; This looks less cumbersome than other options