OnCalculate() is used for indicators not strategy.
MA14 = iMA(_Symbol,_Period,14,0,MODE_SMA,PRICE_CLOSE);is called into EA but more detailed in articles section of Mql5.com like 'Step by Step Guide to writing an Expert Advisor in MQl5 for Beginners ' in
Hi
I'm trying out some simple strategies however I'm struggeling to understand how to produce calculations to use in trade conditions.
Anyway if you're able answer this that should be resolved:
I'm trying to get this simple calculation/indicator into a strategy where I can use it to create a condition for a trading strategy, here is the indicator:
In my attempt I though adding int OnCalculate() would work however I can't make it return values to use in void OnTick():
there is likely a very easy fix but I've been researching and testing for a while and new problems just keep occuring so if you have any answers that would be amazing!!!
the only way to do it is by:
1) Creating a MQLRates array (like: MqlRates rates[]; )
2) copying the values of such timeframe to that array (this will provide you with an array identical to the array which is passed via OnCalculate() [but there is no OnCalculate on Experts, so you have to create it your own, on some specific new array, by using an Array of TYPE: MqlRates )
3) copy the indicator function wich makes the calculations, and change it to use the MqlRates array you just created
4) call the indicator function inside the Expert under either function Timer() or via OnTick() function
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
I'm trying out some simple strategies however I'm struggeling to understand how to produce calculations to use in trade conditions.
Anyway if you're able answer this that should be resolved:
I'm trying to get this simple calculation/indicator into a strategy where I can use it to create a condition for a trading strategy, here is the indicator:
In my attempt I though adding int OnCalculate() would work however I can't make it return values to use in void OnTick():
there is likely a very easy fix but I've been researching and testing for a while and new problems just keep occuring so if you have any answers that would be amazing!!!