Forum migration - read now! - page 3

 
girrrrrrrrrrrrrrrr (double post-migration cause)
 
mntiwana:

Dearest MLADEN

no,there is no belonging mqh file any where,and now every indicator (old+new) asking for that include,this is really interesting and strange,it was compiled before and worked....let us wait till things came up in order.

regards

I have sent you the file via email.
 
mntiwana:

Dearest MLADEN

no,there is no belonging mqh file any where,and now every indicator (old+new) asking for that include,this is really interesting and strange,it was compiled before and worked....let us wait till things came up in order.

regards

This is the include file :

//+------------------------------------------------------------------+
//|                                           NeuroTrend_Include.mqh |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

/****************************  Usage  *******************************
SetInput(Input);
PropagateNet();
GetOutput(Output);
**********************************************************************/

#define LOGISTIC         0
#define TANH             1

int    gmLayers = 0;            /* number of layers in the net */
int    gmUnitsTotal = 0;    /* total number of units in the net */
int    gmConnections = 0;       /* total number of connections int the net */
int    gmGain = 1;                      /* Gain of the net*/

int    gmUnits[];                       /* number of units in each layer */
double gmOutput[];                      /* output of ith unit of nth layer*/
double gmBias[];                        /* bias of ith unit of nth layer*/
double gmWeight[];                      /* weight of jth connection of ith unit & nth layer */


/*------------------------------------------------------------------------*/

/* Allocate memory for Neural Network of geometry described by layers,
units[].   */

void GenerateNetwork(int layers_no, int units[])
{
        int l;

        gmLayers = layers_no;

        Print(ArrayResize(gmUnits, gmLayers)+" network layers:");

        for(l=0; l<gmLayers; l++)
        {       
                gmUnits[l] = units[l];  
                gmUnitsTotal += units[l];
        }

        Print(ArrayResize(gmOutput, gmUnitsTotal)+" network units");
        Print(ArrayResize(gmBias, gmUnitsTotal)+" network units");

        for(l=1; l<gmLayers; l++)
        {       
                gmConnections += gmUnits[l]*gmUnits[l-1];
        }

        Print(ArrayResize(gmWeight, gmConnections)+" network connections");

}
/*------------------------------------------------------------------------*/

/* Copies Input to the input layer of the net */

void SetInput(double inputt[])
{
        int i, u;
        u = gmUnits[0];
        for(i=0; i<u; i++)
        {
                gmOutput[i] = inputt[i];
        }
}

/*------------------------------------------------------------------------*/

/* Copies the output layer of the net to Output */

double GetOutput(int index)
{
        int l, oub;
        for(l=0; l<gmLayers-1; l++)     oub += gmUnits[l];// no. of units before output layer
        //Print(oub);
        return (gmOutput[oub+index-1]);
}

/*------------------------------------------------------------------------*/

/* Produces the network output from input.  You need to use SetInput to
insert data into the network, and GetOutput to retrieve the
result. */

void PropagateNet()
{
        int  i,j,k,l, lu =0, uu =0, lub =0, uub=0, wts = 0;
        double sum=0;

        for(l=0; l<gmLayers-1; l++)
        {
                //Print(l);
                lub = uub;
                uub=0;

                lu = gmUnits[l];      
                uu = gmUnits[l+1];      
                for(k=0; k<l+1; k++)    uub += gmUnits[k];// no. of units before upper layer

                //Print("Propagating from layer "+l +" to "+(l+1));
                //Print("lu"+lu);
                //Print("uu"+uu);
                //Print("lub"+lub);
                //Print("uub"+uub);

                for(i=0; i<uu; i++)
                {
                        //if(l==2) Print("cout: "+(uub+i));
                        sum = 0;
                        for(j=0; j<lu; j++)
                 {
                         sum += gmOutput[lub+j] * gmWeight[wts];
                         //if(l==2)Print("output: "+(lub+j-1)+" weight: "+wts);
                         //if(l==2)Print((lub+j-1)+"X"+gmWeight[wts]);
                         wts++;
                 }
                        /*for(j=lu; j>0; j--)
                 {
                 sum += gmOutput[lub+j-1] * gmWeight[wts];
                 //if(l==2)Print("output: "+(lub+j-1)+" weight: "+wts);
                 //if(l==2)Print((lub+j-1)+"X"+gmWeight[wts]);
                 wts++;
                 }*/

                        sum += gmBias[uub+i];
                        gmOutput[uub+i] = Activation(sum, TANH);

                }//for all units of a layer
        }// for all layers
}

/*-----------------------------------------------------------------------*/

double Activation(double sum, int type)
{
        double ret;

        switch(type) 

        { 
        case 0:
                ret = 1.0 / (1.0 + MathExp(-gmGain * sum));
                break;
        case 1:
                ret = (2.0 / (1.0 + MathExp(-2.0 * sum))) - 1.0;
                break;  
        default:
                Print("Undefined activation type\n");
                break;
        }

        return(ret);
}

/*------------------------------------------------------------------------*/

/* sets the network weights from the input array */

bool SetWeights(double weights[])
{
        if(ArraySize(weights) != gmConnections)
        { 
                Print("Input weights not equal to connections");
                return (0);
        }

        Print(ArrayCopy(gmWeight, weights,0,0,WHOLE_ARRAY)+" weights initialized");

        return(true);
}

/*------------------------------------------------------------------------*/

/* Copies Input to the input layer of the net */

bool SetBias(double bias[])
{
        if(ArraySize(bias) != gmUnitsTotal)
        { 
                Print("Input bias not equal to total units");
                return (0);
        }

        Print(ArrayCopy(gmBias, bias,0,0,WHOLE_ARRAY)+" bias initialized");

        return(true);
}

/*------------------------------------------------------------------------*/

int ReadNetwork(string nfile, string ofile, bool out = false)
{
        int handle = -1, ohandle = -1;
        handle = FileOpen(nfile, FILE_CSV | FILE_READ);
        if(handle < 0)
        {
                Print("Error reading network file, code:"+ GetLastError());
                return (0);
        }

        if(out)
        {
                ohandle = FileOpen(ofile, FILE_CSV|FILE_WRITE);
                if(ohandle < 0)Print("Error opening file to write, code:"+ GetLastError());
        }


        string str, substr;
        int pos = -1, units = 0, connections = 0, index = 0;
        bool bias = false, weights = false;
        bool loop = true;
        //read no of units
        while(loop)
        {
                str = FileReadString(handle);
                if(GetLastError() == 4051) break;

                if(units <= 0)
                {         
                        pos = StringFind(str,"no. of units :",0);
                        if(pos != -1)
                        {
                                units = StrToInteger(StringSubstr(str, 14,StringLen(str)));
                                str = FileReadString(handle);//read next line
                                connections = StrToInteger(StringSubstr(str, 20,StringLen(str)));
                                if((units != gmUnitsTotal) || (connections != gmConnections))
                                {
                                        Print("read units/connections not equal to network units/connections");
                                        return (0);
                                }
                        }
                }else
                {
                        if(bias == false)
                        {
                                //find bias and write to file
                                pos = StringFind(str,"| sites",0);
                                if(pos != -1)
                                {
                                        if(out && (ohandle > 0)) FileWrite(ohandle, "**********\n  BIAS\n**********");
                                        str = FileReadString(handle);
                                        index = 0;
                                        while(index < units)
                                        {
                                                str = FileReadString(handle);
                                                for(int i = 1; i < 5; i++)
                                                {
                                                        pos = StringFind(str,"|",0); 
                                                        if(pos != -1)str = StringSubstr( str, pos+1);
                                                }

                                                pos = StringFind(str,"|",0); 
                                                if(pos != -1) substr = StringSubstr( str, 0, pos);
                                                StringTrimLeft(substr);
                                                StringTrimRight(substr);
                                                gmBias[index] = StrToDouble(substr);     
                                                index++;              
                                                if(out && (ohandle > 0)) FileWrite(ohandle, substr);
                                        }//end while                           

                                        bias = true;
                                }//if pos

                        }else if(weights == false)
                        {
                                //find weights and write to file
                                pos = StringFind(str,"source:weight",0);
                                if(pos != -1)
                                {
                                        if(out && (ohandle > 0)) FileWrite(ohandle, "\n\n**********\n  WEIGHTS\n**********");
                                        str = FileReadString(handle);
                                        index = 0;
                                        while(index < connections)
                                        {
                                                str = FileReadString(handle);
                                                while(true)
                                                {
                                                        pos = StringFind(str,":",0);
                                                        if(pos == -1) break;

                                                        substr = StringSubstr(str, pos+1, 8);
                                                        StringTrimLeft(substr);
                                                        StringTrimRight(substr);
                                                        gmWeight[index] = StrToDouble(substr); 
                                                        index++;
                                                        if(out && (ohandle > 0)) FileWrite(ohandle, substr);
                                                        str = StringSubstr(str, pos+8,0);
                                                } //end while true
                                        }//end while index < connections

                                        weights = true;
                                        loop = false;
                                }//end if pos

                        }else //if not bias or weights
                        {
                                loop = false;
                        }

                }// end else if units

        } // end while loop

        if(ohandle > 0) FileClose(ohandle);
        if(handle > 0) FileClose(handle);
        return (1);
}

/*------------------------------------------------------------------------*/
 
mntiwana:

Dearest MLADEN

no,there is no belonging mqh file any where,and now every indicator (old+new) asking for that include,this is really interesting and strange,it was compiled before and worked....let us wait till things came up in order.

regards

And this is the updated indicator (it needed some changes to be compiled) :

//+------------------------------------------------------------------+
//|                                         NeuroTrend_Indicator.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 3

#property indicator_color1 Yellow
#property indicator_width1 1

#property indicator_color2 GreenYellow
#property indicator_width2 1

#property indicator_color3 Gold
#property indicator_width3 1

//includes
#include <NeuroTrend_Include.mqh>
//---- buffers
double gmNN1[];
double gmNN2[];
double gmNN3[];

extern bool alert = true;
extern bool sendMail = false;
extern string netfile = "neurotrend.net";
extern string logfile = "netlog.txt";
extern bool log = false;
extern bool barUpdate = true;
extern ENUM_TIMEFRAMES shortTimeFrame = PERIOD_M15;
extern ENUM_TIMEFRAMES longTimeFrame = PERIOD_H1;

bool gmBuy = false, gmSell = false;
int reset, gmPrevBars = 0,h1shift = 0;
double tinput[17];
double output[3];
double cEMA = 0, cRSI = 0, pRSI = 0, cStochMain = 0, pStochMain = 0, cStochSignal = 0, pStochSignal = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
    SetIndexStyle(0,DRAW_LINE,EMPTY);
    SetIndexStyle(1,DRAW_LINE,EMPTY);
    SetIndexStyle(2,DRAW_LINE,EMPTY);

    SetIndexBuffer(0,gmNN1);
    SetIndexBuffer(1,gmNN2);
    SetIndexBuffer(2,gmNN3);

    SetIndexEmptyValue(0,0.0);
    IndicatorDigits(Digits);
    SetIndexShift (0, 0);
    IndicatorShortName ("NeuroTrend");
    SetIndexLabel (0, "NeuroTrend"); 

    //create network
    int units[3] = {17, 10, 3};
    GenerateNetwork(3, units);
    ReadNetwork(netfile, logfile, log);
   
    return(0);  
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
    return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
    if(Bars < 1500) return (0);
    if(barUpdate && (gmPrevBars == Bars)) return (0);
    int limit;
    int counted_bars=IndicatorCounted();
    //---- check for possible errors
    if(counted_bars<0) return(-1);
    //---- the last counted bar will be recounted
    if(counted_bars>0) counted_bars--;
    limit=Bars-counted_bars;


    while(limit >= 0)
    {

        cEMA = iMA(NULL,shortTimeFrame,5,0,MODE_EMA,PRICE_CLOSE,limit);
        cRSI = iRSI(NULL,shortTimeFrame,9,PRICE_CLOSE,limit);
        pRSI = iRSI(NULL,shortTimeFrame,9,PRICE_CLOSE,limit+1);
        cStochMain = iStochastic(NULL,shortTimeFrame,5,3,3,MODE_EMA,0,MODE_MAIN,limit);
        pStochMain = iStochastic(NULL,shortTimeFrame,5,3,3,MODE_EMA,0,MODE_MAIN,limit+1);
        cStochSignal = iStochastic(NULL,shortTimeFrame,5,3,3,MODE_EMA,0,MODE_SIGNAL,limit);
        pStochSignal = iStochastic(NULL,shortTimeFrame,5,3,3,MODE_EMA,0,MODE_SIGNAL,limit+1);

        tinput[0] = gmThreshold((cEMA - iMA(NULL,shortTimeFrame,5,0,MODE_EMA,PRICE_CLOSE,limit+1))/(Point*10));
        tinput[1] = gmThreshold((iMA(NULL,shortTimeFrame,5,0,MODE_EMA,PRICE_CLOSE,limit+1)-iMA(NULL,shortTimeFrame,5,0,MODE_EMA,PRICE_CLOSE,limit+2))/(Point*10));
        tinput[2] = gmThreshold((iMA(NULL,shortTimeFrame,5,0,MODE_EMA,PRICE_CLOSE,limit+2)-iMA(NULL,shortTimeFrame,5,0,MODE_EMA,PRICE_CLOSE,limit+3))/(Point*10));
        tinput[3] = gmThreshold(cRSI /100);
        tinput[4] = gmThreshold(pRSI /100);
        tinput[5] = gmThreshold((iWPR(NULL,shortTimeFrame,14,limit)+100)/100);
        tinput[6] = gmThreshold((iWPR(NULL,shortTimeFrame,14,limit+1)+100)/100);
        tinput[7] = gmThreshold(iMACD(NULL,shortTimeFrame,12,26,9,PRICE_CLOSE,MODE_MAIN,limit)*100);
        tinput[8] = gmThreshold(iMACD(NULL,shortTimeFrame,12,26,9,PRICE_CLOSE,MODE_MAIN,limit+1)*100);
        tinput[9] = gmThreshold(iMACD(NULL,shortTimeFrame,12,26,9,PRICE_CLOSE,MODE_SIGNAL,limit)*100);
        tinput[10] = gmThreshold(iMACD(NULL,shortTimeFrame,12,26,9,PRICE_CLOSE,MODE_SIGNAL,limit+1)*100);
        tinput[11] = gmThreshold(cStochMain /100);
        tinput[12] = gmThreshold(pStochMain /100);
        tinput[13] = gmThreshold(cStochSignal /100);
        tinput[14] = gmThreshold(pStochSignal /100);
        h1shift = iBarShift(NULL,longTimeFrame,iTime(NULL,shortTimeFrame,limit),true);
        tinput[15] = gmThreshold((iMA(NULL,longTimeFrame,5,0,MODE_EMA,PRICE_CLOSE,h1shift)-iMA(NULL,longTimeFrame,5,0,MODE_EMA,PRICE_CLOSE,h1shift+1))/(Point*10));
        tinput[16] = gmThreshold((iMA(NULL,longTimeFrame,5,0,MODE_EMA,PRICE_CLOSE,h1shift+1)-iMA(NULL,longTimeFrame,5,0,MODE_EMA,PRICE_CLOSE,h1shift+2))/(Point*10));

        SetInput(tinput);
        PropagateNet();   

        gmNN1[limit] = GetOutput(1)*Point*10+ cEMA;
        gmNN2[limit] = GetOutput(2)*Point*10+gmNN1[limit];
        gmNN3[limit] = GetOutput(3)*Point*10+gmNN2[limit];
        //Print(GetOutput(1)+" "+GetOutput(2)+" "+GetOutput(3));

        if((limit < 2))
        {
            if((gmBuy == false) && (gmNN3[limit] > gmNN2[limit]) && (gmNN2[limit] > gmNN1[limit]) && (gmNN1[limit] > cEMA))
            {
                if((cRSI >= pRSI) && (cRSI > 45) && (cRSI < 50) && (cStochMain > cStochSignal) && (cStochMain >= pStochMain) && (cStochMain > 20) && (cStochMain < 80) && (cStochSignal >= pStochSignal) && (cStochSignal > 20) && (cStochSignal < 80))
                {
                    if(sendMail && (IsDemo() == FALSE)) SendMail("BUY SIGNAL", DoubleToStr(Ask,5));
                    if(alert) Alert("BUY SIGNAL");
                    gmBuy = true;
                    gmSell = false;
                }
            }


            if((gmSell == false) && (gmNN3[limit] < gmNN2[limit]) && (gmNN2[limit] < gmNN1[limit]) && (gmNN1[limit] < cEMA))
            {
                if((cRSI <= pRSI) && (cRSI > 50) && (cRSI < 55) && (cStochMain < cStochSignal) && (cStochMain <= pStochMain) && (cStochMain > 20) && (cStochMain < 80) && (cStochSignal <= pStochSignal) && (cStochSignal > 20) && (cStochSignal < 80))
                {
                    if(sendMail && (IsDemo() == FALSE)) SendMail("SELL SIGNAL", DoubleToStr(Bid,5));
                    if(alert) Alert("SELL SIGNAL");
                    gmSell = true;
                    gmBuy = false;
                }
            }

        }

        limit--;
    }//end while loop


    gmPrevBars = Bars;  

    return(0);
}

//-------------------------------------------------------------------------------------------------

double gmThreshold(double value)
{

    if(value > 0.99999) return (0.99999);

    if(value < -0.99999) return (-0.99999);

    return (value);

}

//-------------------------------------------------------------------------------------------------
 
Include file can be also downloaded from here : https://www.mql5.com/en/forum/180648/page628
 
krelian99:
I have sent you the file via email.

Krelian

thank you man,you are as fast as TSD announced and expected in near future....but i am happy,once again members red digits will be start from 1 except moderators,lol.

regards

 
mladen:
Include file can be also downloaded from here : https://www.mql5.com/en/forum/180648/page628

Dearest MLADEN

so many thanks for all two files,working well now , one question plz,in property window there are two parameters setting for (at the lower end) "short time frame" and "long time frame" ..... short time frame setting working well according to belonging time frame,where as long frame doing nothing,so this long time frame is for what and where to use,if it is inactive inside code ?

regards

 
mntiwana:

Dearest MLADEN

so many thanks for all two files,working well now , one question plz,in property window there are two parameters setting for (at the lower end) "short time frame" and "long time frame" ..... short time frame setting working well according to belonging time frame,where as long frame doing nothing,so this long time frame is for what and where to use,if it is inactive inside code ?

regards

mntiwana


That indicator is actually using two time frames. Short time frame is used by the majority of code (14 out of 16 input values) while the long time frame is used by only 2 out of 16 input values. That is why the impact of the "long time frame" is not that much obvious as the impact of the "short time frame"

 
In order t resolve some doubts : the forum issues solving will be resumed starting from tomorrow (due to holidays) and, as it is planed, the forum will resume its normal functioning very soon
 

Almost,  cant take it anymore.

My profile (correct link should be) :  https://www.forex-tsd.com/trader/Anyway

But now it is :  https://www.forex-tsd.com/trader/33nyway

 https://www.forex-tsd.com/trader/33nyway/about

 https://www.forex-tsd.com/trader/33nyway/...

 result :


 

404

Page not found

Check the URL and try again

Reason: