Custom Code Conversion MT4 to MT5
-
I have just converted an MT4 project to MT5 using the convertor and all fine apart from some custom code I have to set button states after pressed in the tester.
I've used it in the MT4 version of an EA I'm building and it works perfectly.
Just converted my creation to MT5 and I get a compile error on all these blocks.What would be the MT5 version of this code?
ObjectSet(LoadedObjectName(),OBJPROP_STATE,0);The code is from this thread but think it's buried so deep people didnt see my question.

https://fxdreema.com/forum/topic/9883/working-buttons-in-strategytester
Any help much appreciated. -
@btrader This question is for real programmers (not em, sorry). Could you please upload the compilation errors?
-
Same error for each of the buttons.

-
@btrader Undeclared identifier is normally when a variable is expected, not sure why it would do this. You could try not using the custom code and redrawing the button, not sure if works but worth a try.
-
if he converted it, he is probably new, and just copied all the blocks from another project...and disregarded the need to just save and edit. i.e. he didn't transfer over the variables and constants?
just a guess.
-
Id make sure you have the 2 purple(blue?) variables listed.
ObjectSet & LoadedObjectNameBoth will have a default value of 0.
-
@tipsywisdom On MT4 a variable isn't needed.
-
i found recently that mt5 buttons work without fucking with anything...
-
@tipsywisdom That code makes the buttons work in the tester. It's a conversion from an MT4 EA built in FXDreema using the convertor to MT5. You didnt read the bloody post I posted did you. Suspect you are new

-
@btrader said in Custom Code Conversion MT4 to MT5:
@tipsywisdom That code makes the buttons work in the tester. It's a conversion from an MT4 EA built in FXDreema using the convertor to MT5. You didnt read the bloody post I posted did you. Suspect you are new

in MT5 you dont need to use any code to make buttons work, thats where I'm lost....I tested closing all trades with a OnChart button, in a backtest with MT5 and it didn't require code to work.
I'm not new, love the smartass reply though
haha... you'll have to forgive me! You caught me though....I'm just used to people saying and making the same mistakes over and over....like copying someone else's blocks into their own project and asking why it doesn't work. Or converting entire EA's from MT4 to MT5 without reading or browsing forum for themselves to find that you still must manually convert blocks. -
did you figure out a solution to this yet? I'm having the same problem.
-
@cptjaw said in Custom Code Conversion MT4 to MT5:
did you figure out a solution to this yet? I'm having the same problem.
Nevermind use this code instead: ObjectSetInteger(0, "sell", OBJPROP_STATE, 0);
Change sell to the name of your button. keep quotation.