You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
If you have any time to post it, that would help me a lot understanding how to manage this difficulty, thanks :)
In the meantime I will start to dig into the forum about the OnCalculate function ;)
If you have any time to post it, that would help me a lot understanding how to manage this difficulty, thanks :)
In the meantime I will start to dig into the forum about the OnCalculate function ;)
Honestly, Ive just typed this and I cannot say if it is bugfree, or even compiles, but it should give you an outline of how to cascade the calculations in your EA.
Please try to figure this out on your own, if possible.
{ // Local init const int lwma_periods = 25; const int cascade_cnt = 6; double tmp_array[] double result[]; // Static init static double lwma_stage_values[]; // Operation mode const bool update = ArraySize(lwma_stage_values) == NULL; // Initial calcualtions run if(!update) { // Get required data ResetLastError(); const int datasets_count = CopyClose(Symbol(), _Period, TimeCurrent() - (TimeCurrent() % PeriodSeconds()), lwma_periods * cascade_cnt, tmp_array); if(datasets_count != lwma_periods * cascade_cnt) { printf("Error receiving data. ErrNo: %i", _LastError); return; } // Init staging values array if(ArrayResize(lwma_stage_values, cascade_cnt) != cascade_cnt) { printf("Error resizing array. ErrNo: %i", _LastError); return; } // Initial calculations run int data_ptr = NULL; for(int loop1 = 1; (loop1 < cascade_cnt) && !_StopFlag; loop1++) { // Calculate uneven cascade data_ptr = lwma_periods * loop1; if(calc_lwma(data_ptr - lwma_periods, datasets_count, tmp_array, result) < 1) { printf("Error calculating lwma. ErrNo: %i", _LastError); return; } // Intermediate loop control loop1++; // Calculate even cascade data_ptr = lwma_periods * loop1; if(calc_lwma(data_ptr - lwma_periods, datasets_count, result, tmp_array) < 1) { printf("Error calculating lwma. ErrNo: %i", _LastError); return; } // Early break, result copy if( (loop1 >= cascade_cnt) && (ArrayCopy(result, tmp_array) != ArraySize(tmp_array)) ) { printf("Error copying array. ErrNo: %i", _LastError); return; } } } // Update calculations else { ResetLastError(); const int datasets_count = CopyClose(Symbol(), _Period, TimeCurrent() - (TimeCurrent() % PeriodSeconds()), lwma_periods, tmp_array); if(datasets_count != lwma_periods) { printf("Error receiving data. ErrNo: %i", _LastError); return; } const int idx = lwma_periods - 1; for(int loop1 = NULL; (loop1 < lwma_cascade) && !_StopFlag; loop1++) { lwma_stage_values[loop1] = lwma(tmp_array, idx, lwma_periods, lwma_stage_values[loop1]); tmp_array[idx] = lwma_stage_values[loop1]; } } // Get final result const double cascaded_lwma_value = (update) ? lwma_stage_values[ArraySize(lwma_stage_values) - 1] : result[ArraySize(result) - 1]; } const int calc_lwma(const int prev_calculated, const int rates_total, const double& source[], double& result[]) { if(ArrayResize(result, ArraySize(source)) < 1) { return(-1); } for(int idx = prev_calculated; (idx < rates_total) && !_StopFlag; idx++) { result[idx] = lwma(source, idx, lwma_periods, (idx > NULL) ? result[idx - 1] : NULL); } return(ArraySize(result)); }Honestly, Ive just typed this and I cannot say if it is bugfree, or even compiles, but it should give you an outline of how to cascade the calculations in your EA.
Please try to figure this out on your own, if possible.
Many thanks Dominik, I will look this after lunch.
I'm pretty sure I will encounter a problem with the last part, as "prev_calculated" doesn't exist in my EA, but I will look more in depth at this time !
Many thanks Dominik, I will look this after lunch.
I'm pretty sure I will encounter a problem with the last part, as "prev_calculated" doesn't exist in my EA, but I will look more in depth at this time !
Dont worry about prev_calculated,as I have filled that gap....
Hello Dominik, In the meantime I tried to write and Indicator that seems to be working.
I would like to try to call it from the EA, but i was wondering, how do you select the price used ? I defined TYPICAL in the properties, but as it's not an input, how do I change it via the iCustom ?
EDIT : 2nd question : as I have never used any buffer, when callling with iCustom, how do you define the index you are looking for ? ==> FORGET about this one, there is a shift parameters ;)
Hello Dominik, In the meantime I tried to write and Indicator that seems to be working.
I would like to try to call it from the EA, but i was wondering, how do you select the price used ? I defined TYPICAL in the properties, but as it's not an input, how do I change it via the iCustom ?
EDIT : 2nd question : as I have never used any buffer, when callling with iCustom, how do you define the index you are looking for ? ==> FORGET about this one, there is a shift parameters ;)
I see how to put it as input, but how to apply it in the price[] array from OnCalculate ?
I'm sorry I have so much questions :/
I see how to put it as input, but how to apply it in the price[] array from OnCalculate ?
I'm sorry I have so much questions :/
Oh perfect, thank you very much !
I will start with this, as I understand every step of the code, but I will probably switch to the materials you provided in the near future, as soon as I understand every part of it.
Many many thanks for your time and your help Dominik !
EDIT : let's hope that this could improve my EA results, if it does I owe you one ;)Oh perfect, thank you very much !
I will start with this, as I understand every step of the code, but I will probably switch to the materials you provided in the near future, as soon as I understand every part of it.
Many many thanks for your time and your help Dominik !
EDIT : let's hope that this could improve my EA results, if it does I owe you one ;)