gringoh Posted April 18, 2011 Report Share Posted April 18, 2011 Hello, The i-ProfitTracker indicator gives different information’s about profit (in point, $, %, for today, the week)… Here the link to download it: http://www.forexfactory.com/showpost.php?p=3813782 What I would like to do for example is to call the iprofit indicator from another indicator in order to have only the current profit value in point displayed on my chart (to return the value “tu” for example). I think it is possible by using the icustom function but I am not a genius in mq4. Help would be much appreciated. Thank you in advance, Regards, Gringoh Quote Link to comment Share on other sites More sharing options...
josephR Posted April 18, 2011 Report Share Posted April 18, 2011 (edited) My understanding is that you can only access values that are "returned" to mq4 via one of the indicator buffers. The index of the buffer you are interested in is specified in the "Mode" parameter of the iCustom call. Otherwise, the values are local to the indi and I dont think there is any way of getting to them thru the iCustom call, or any other way for that matter (****). A decompile of the iProfitTracker reveals that no indicator buffers are used, so all calculated values are local to the indi. That said, you can modify the indi, add one or more indicator buffer(s), and write the value you are interested in to the buffer whenever it is calculated. Given that you are writing a new indi, I trust you should have no problem doing that. ****: As @Hacker correctly mentions below, the other way of passing variables between indis is thru the use of global variables! Edited April 18, 2011 by josephR gringoh 1 Quote Link to comment Share on other sites More sharing options...
Hacker1713006064 Posted April 18, 2011 Report Share Posted April 18, 2011 (edited) Im a real fan of passing values between modules using the GlobalVariables You do this using GlobalVariableCheck GlobalVariableSet GlobalVariableDel Commands... Inside one indicator you calculate/set a global variable to the value you want... And then inside the other module you check the global variable and use the returned value for you needs. Here is an example I use in an indicator to tell an ea when it OK to trade.. //use global flags to signal time to trade to ea. GlobalOkToTradeSymbolFlag="GlobalTradeFlag_"+MagicNumber; if (GlobalVariableCheck(GlobalOkToTradeSymbolFlag)) GlobalVariableDel(GlobalOkToTradeSymbolFlag); for(int cnt=1; cnt<=5; cnt++) { if (DebugLogFile) log( "Setting GlobalOkToTradeSymbolFlag - Try#: " +cnt+" "+Symbol()+ " "+ Period() ); Error = GetLastError(); GlobalVariableSet(GlobalOkToTradeSymbolFlag,0); Error = GetLastError(); if (Error>0) { GlobalSymbolTrend=99; if (DebugLogFile) log (" GlobalOkToTradeSymbolFlag Error: " + ErrorDescription(Error)); Sleep(500); } else { GlobalSymbolTrend=0; if (DebugLogFile) log (" GlobalOkToTradeSymbolFlag SetOK: " + GlobalSymbolTrend); break; } } I also record a log file on my stuff so you will see code in here for error debugging Now the EA has similiar code in it to READ the global variable an do actions based on that... Edited April 18, 2011 by Hacker gringoh 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.