Re: Coding Help

#1121
wojtek wrote:
Fri May 22, 2020 9:28 am
You should use the keris2112 method (from the former Forex-TSD forum) for creating MTF code.
For this purpose you need only to call the buffers using the iCustom function.
Hi Wojtek,

Thanks for your reply. I am a newbie and hardly know anything about coding. Was wondering if there was actually an indicator available which can be used to call my indicator. Appreciate all the help.


Re: Coding Help

#1122
Mrtools or any one
I have converted the Chaos indicator, which re-paints, to show a 1 Or -1 at the time of the correct occurrence but 1 shift back. The problem I have is it disappears on the second candle after it occurred.
What coding will allow me to freeze the "trend1" until the next occurrence of "trend -1" and so on.

I have tried several coding steps to lock it in until the occurrence of the next change but to no avail.
Any Help would be appreciated
Ray
Never mind I got the answer.

Re: Coding Help required for 3 Level ZZ Semafor MTF indicator

#1123
Hi,

Below is 3 Level ZZ Semafor MTF indicator. It gets compiled and works on FXCM MT4 platform. But on FXDD MT4 platform it gives me an error on compilation. I am getting error as in the attached screen shot. It gives an error on Return function saying "'return' - expressions are not allowed on a global scope" . I also commented out the Return function by placing a "//" in front of it and compiled. It got compiled but the Indicator did not work and showed nothing on the chart when I placed the indicator on chart after compilation. Please help. This is a very Imp Indicator for my strategy.

//+------------------------------------------------------------------+
//| MTF 3_Level_ZZ_Semafor.mq4 |
//+------------------------------------------------------------------+
// mtf2008forextsd ki kerris f-la

#property copyright "asystem2000"
#property link "asystem2000@yandex.ru"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 White
#property indicator_color2 White
#property indicator_color3 Aqua
#property indicator_color4 Aqua
#property indicator_color5 Yellow
#property indicator_color6 Yellow

#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 2
#property indicator_width6 2



//---- input parameters


//---- input parameters

extern int TimeFrame=0;

extern double Period1=5;
extern double Period2=13;
extern double Period3=34;
extern string Dev_Step_1="1,3";
extern string Dev_Step_2="8,5";
extern string Dev_Step_3="13,8";
extern int Symbol_1_Kod=140;//129
extern int Symbol_2_Kod=141;//130
extern int Symbol_3_Kod=142;//131

extern string note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
extern string Arrow_Codes = "140(129)=1; 141(130)=2; 142(131)=3";

//---- buffers
double FP_BuferUp[];
double FP_BuferDn[];
double NP_BuferUp[];
double NP_BuferDn[];
double HP_BuferUp[];
double HP_BuferDn[];
/*************************************************************************
PERIOD_M1 1
PERIOD_M5 5
PERIOD_M15 15
PERIOD_M30 30
PERIOD_H1 60
PERIOD_H4 240
PERIOD_D1 1440
PERIOD_W1 10080
PERIOD_MN1 43200
You must use the numeric value of the timeframe that you want to use
when you set the TimeFrame' value with the indicator inputs.
---------------------------------------
PRICE_CLOSE 0 Close price.
PRICE_OPEN 1 Open price.
PRICE_HIGH 2 High price.
PRICE_LOW 3 Low price.
PRICE_MEDIAN 4 Median price, (high+low)/2.
PRICE_TYPICAL 5 Typical price, (high+low+close)/3.
PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.
You must use the numeric value of the Applied Price that you want to use
when you set the 'applied_price' value with the indicator inputs.
**************************************************************************/

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{

//---- indicator line
// if (Period1>0)
// {
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,Symbol_1_Kod);
SetIndexBuffer(0,FP_BuferUp);
SetIndexEmptyValue(0,0.0);

SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,Symbol_1_Kod);
SetIndexBuffer(1,FP_BuferDn);
SetIndexEmptyValue(1,0.0);
// }

//---- Îáðàáàòûâàåì 2 áóôåð
// if (Period2>0)
// {
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,Symbol_2_Kod);
SetIndexBuffer(2,NP_BuferUp);
SetIndexEmptyValue(2,0.0);

SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,Symbol_2_Kod);
SetIndexBuffer(3,NP_BuferDn);
SetIndexEmptyValue(3,0.0);
// }
//---- Îáðàáàòûâàåì 3 áóôåð
// if (Period3>0)
// {
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,Symbol_3_Kod);
SetIndexBuffer(4,HP_BuferUp);
SetIndexEmptyValue(4,0.0);

SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,Symbol_3_Kod);
SetIndexBuffer(5,HP_BuferDn);
SetIndexEmptyValue(5,0.0);


//---- name for DataWindow and indicator subwindow label
switch(TimeFrame)
{
case 1 : string TimeFrameStr="M1" ; break;
case 5 : TimeFrameStr= "M5" ; break;
case 15 : TimeFrameStr= "M15"; break;
case 30 : TimeFrameStr= "M30"; break;
case 60 : TimeFrameStr= "H1" ; break;
case 240 : TimeFrameStr= "H4" ; break;
case 1440 : TimeFrameStr= "D1" ; break;
case 10080 : TimeFrameStr= "W1" ; break;
case 43200 : TimeFrameStr= "MN1"; break;
default : TimeFrameStr= "CurrTF";
}
if (TimeFrame<Period()) TimeFrame=Period();

SetIndexLabel(0,"Semafor FP_BuferUp ["+TimeFrame+"])");
SetIndexLabel(1,"Semafor FP_BuferDn ["+TimeFrame+"])");
SetIndexLabel(2,"Semafor NP_BuferUp ["+TimeFrame+"])");
SetIndexLabel(3,"Semafor NP_BuferDn ["+TimeFrame+"])");
SetIndexLabel(4,"Semafor HP_BuferUp ["+TimeFrame+"])");
SetIndexLabel(5,"Semafor HP_BuferDn ["+TimeFrame+"])");

IndicatorShortName("3L_ZZ_Semafor ["+TimeFrameStr+"]");

}
//----
return(0);

//+------------------------------------------------------------------+
//| MTF |
//+------------------------------------------------------------------+
int start()
{
datetime TimeArray[];
int i,limit,y=0,counted_bars=IndicatorCounted();

// Plot defined time frame on to current time frame
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);

limit=Bars-counted_bars;
limit=MathMax(limit,TimeFrame/Period());
// limit=MathMin(limit,MaxBarsToCount);

for(i=0,y=0;i<limit;i++)
{
// if (TimeFrame<Period()) TimeFrame=Period();
if (Time<TimeArray[y]) y++;
/***********************************************************
Add your main indicator loop below. You can reference an existing
indicator with its iName or iCustom.
Rule 1: Add extern inputs above for all neccesary values
Rule 2: Use 'TimeFrame' for the indicator time frame
Rule 3: Use 'y' for your indicator's shift value
**********************************************************/

//---- buffers

FP_BuferUp=iCustom(NULL,TimeFrame,"3_Level_ZZ_Semafor",Period1,Period2,Period3,
Dev_Step_1,Dev_Step_2,Dev_Step_3,
Symbol_1_Kod,Symbol_2_Kod,Symbol_3_Kod,0,y);
FP_BuferDn=iCustom(NULL,TimeFrame,"3_Level_ZZ_Semafor",Period1,Period2,Period3,
Dev_Step_1,Dev_Step_2,Dev_Step_3,
Symbol_1_Kod,Symbol_2_Kod,Symbol_3_Kod,1,y);
NP_BuferUp=iCustom(NULL,TimeFrame,"3_Level_ZZ_Semafor",Period1,Period2,Period3,
Dev_Step_1,Dev_Step_2,Dev_Step_3,
Symbol_1_Kod,Symbol_2_Kod,Symbol_3_Kod,2,y);
NP_BuferDn=iCustom(NULL,TimeFrame,"3_Level_ZZ_Semafor",Period1,Period2,Period3,
Dev_Step_1,Dev_Step_2,Dev_Step_3,
Symbol_1_Kod,Symbol_2_Kod,Symbol_3_Kod,3,y);
HP_BuferUp=iCustom(NULL,TimeFrame,"3_Level_ZZ_Semafor",Period1,Period2,Period3,
Dev_Step_1,Dev_Step_2,Dev_Step_3,
Symbol_1_Kod,Symbol_2_Kod,Symbol_3_Kod,4,y);
HP_BuferDn=iCustom(NULL,TimeFrame,"3_Level_ZZ_Semafor",Period1,Period2,Period3,
Dev_Step_1,Dev_Step_2,Dev_Step_3,
Symbol_1_Kod,Symbol_2_Kod,Symbol_3_Kod,5,y);

}

// +++++++++++++++++++++++++++++++++++++ Refresh buffers
if (TimeFrame>Period()) {
int PerINT=TimeFrame/Period()+1;
datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period());
for(i=0;i<PerINT+1;i++) {if (TimeArr>=TimeArray[0]) {
/********************************************************
Refresh buffers: buffer = buffer[0];
********************************************************/

FP_BuferUp=FP_BuferUp[0];
FP_BuferDn[i]=FP_BuferDn[0];
NP_BuferUp[i]=NP_BuferUp[0];
NP_BuferDn[i]=NP_BuferDn[0];
HP_BuferUp[i]=HP_BuferUp[0];
HP_BuferDn[i]=HP_BuferDn[0];

} } }
//+++++++++++++++++++++++++++++++++++++++++++++ Raff
return(0);
}
//+------------------------------------------------------------------+

Re: Coding Help

#1124
Hi,

Can someone please add alert to this CCI indicator. Alert to pop up when CCI crosses 200. Immediate help will be appreciated.
BK Woodie.ex4
(18.64 KiB) Downloaded 26 times

Re: Coding Help

#1125
Dear friends,

I've been a lurker on this forum for some months. This being my first post, I should preface my question by saying that I'm very much grateful for all the work that went into programming the indicators and ideas, and organizing this forum. It feels like such a productive, open, and friendly place. Huge "thank you" for all those who made this place into what it is!

I have recently started learning MQL4, which has been really fun for me. Recently I've hit a wall though, with me spending a number of days trying stuff and not being able to get it to work. So I figured I should ask the pros here ;-) Here are my two questions:

- Is there any way to have an extern variable which would take a CSV list of parameters, which string (with appropriate transformations) would be then be used in an iCustom call in the body of the invoked indicator? Essentially, I'm trying to create an indicator wrapper, which would take as parameters an indicator name, and indicator CSV list of parameters. It's preferred that this solution is run-time (rather than compile-time). My issue is that iCustom expects the parameters to be of correct datatypes, and given that this language is strongly typed, doesn't appear to have variable variable names, it doesn't seem to support runtime creation of structures with different datatypes, and it doesn't seem to support dynamic deletion and reallocation of variable names (these are some of the things that I've researched and / or tried), I don't see any way to program this other than creating a giant switch inside the code which would account for every possible permutation of every possible datatype, up to some max number of parameters. That would be some pretty massive, hacky, ugly code.

- Is there a way to copy an an entire buffer of a given length for the invoked indicator, as opposed to going through one buffer value at a time the way iCustom does? I understand that MQL5 has a way to copy an entire buffer like that (CopyBuffer function), but can I do something similar in MT4 (probably not natively, but perhaps there's a way of creating one's own function?) My issue is that I am creating wrappers around my indicators which contain additional decision-making logic. I plan to invoke those indicators from a dashboard-type top-level indicator. If I have to loop through let's say 1800 bars of a given indicator each time for the wrapper to work, and then the higher level dashboard indicator will issue 1800 iCustom calls to the wrapper (it won't just need the latest signal, but the visible chart's number of bars, as I'd need that for automated analysis purposes). Multiply that by several indicators and then by 28 pairs, and one can imagine what that would do to system resources.

I would greatly appreciate every bit of help. I am sure I don't yet know some cool and clever features of MQL4 that would allow one to do those types of things, so I would appreciate every bit of advice, code samples, indis with similar logic in them, and anything that would help crack those two dilemmas.

Thank you in advance!




  1. Similar Topics

    1. Need coding help, if possible!

      2 Replies 498 Views

      by brenofguedes, Thu Mar 12, 2020 2:05 pm in Coding Help

      2 Replies
      498 Views
    2. Ea coding very basic

      0 Replies 297 Views

      by Dutchman2433, Wed May 06, 2020 5:42 am in Express Coding & Commercial Services

      0 Replies
      297 Views

Return to “Coding Help”