Re: Coding Help

401
Hi, mladen
May I check with you about the array indexing direction of user defined function, from the indicator StepMA pdf nmc 3.1416 + arrows.mq4, there is iStepMa user defined function with 2 dimensional array workStep[r][_smax], workStep[r][_smin], May I know if the array workStep indexing is timeseries or not?
Thanks!
double workStep[][3];
#define _smin 0
#define _smax 1
#define _trend 2

double iStepMa(double sensitivity, double stepSize, double stepMulti, double phigh, double plow, double pprice, int r)
{
if (ArrayRange(workStep,0)!=Bars) ArrayResize(workStep,Bars);
if (sensitivity == 0) sensitivity = 0.0001; r = Bars-r-1;
if (stepSize == 0) stepSize = 0.0001;
double result;
double size = sensitivity*stepSize;

//
//
//
//
//

if (r==0)
{
workStep[r][_smax] = phigh+2.0*size*stepMulti;
workStep[r][_smin] = plow -2.0*size*stepMulti;
workStep[r][_trend] = 1;
return(pprice);
}

//
//
//
//
//

workStep[r][_smax] = phigh+2.0*size*stepMulti;
workStep[r][_smin] = plow -2.0*size*stepMulti;
workStep[r][_trend] = workStep[r-1][_trend];
if (pprice>workStep[r-1][_smax]) workStep[r][_trend] = 1;
if (pprice<workStep[r-1][_smin]) workStep[r][_trend] = -1;
if (workStep[r][_trend] == 1) { if (workStep[r][_smin] < workStep[r-1][_smin]) workStep[r][_smin]=workStep[r-1][_smin]; result = workStep[r][_smin]+size*stepMulti; }
if (workStep[r][_trend] == -1) { if (workStep[r][_smax] > workStep[r-1][_smax]) workStep[r][_smax]=workStep[r-1][_smax]; result = workStep[r][_smax]-size*stepMulti; }
trend[Bars-r-1] = workStep[r][_trend];

return(result);
}


Re: Coding Help

402
mrtools wrote: Mon Jun 19, 2017 8:18 am Ray this would be the median(mean) indicator version.
Mrtools & mladen
This indicator v4.13 provides different results then my other renko converters, it shows mean but calculates 100%. Any chance of adding the max bars to the "RenkoNew format" indicator.
see attached; top left - evolution EA, bottom left - renko mean new format, top right renko 4.13

Re: Coding Help

404
GERVASE wrote: Mon Jun 19, 2017 10:50 am Hi, mladen
May I check with you about the array indexing direction of user defined function, from the indicator StepMA pdf nmc 3.1416 + arrows.mq4, there is iStepMa user defined function with 2 dimensional array workStep[r][_smax], workStep[r][_smin], May I know if the array workStep indexing is timeseries or not?
Thanks!
double workStep[][3];
#define _smin 0
#define _smax 1
#define _trend 2

double iStepMa(double sensitivity, double stepSize, double stepMulti, double phigh, double plow, double pprice, int r)
{
if (ArrayRange(workStep,0)!=Bars) ArrayResize(workStep,Bars);
if (sensitivity == 0) sensitivity = 0.0001; r = Bars-r-1;
if (stepSize == 0) stepSize = 0.0001;
double result;
double size = sensitivity*stepSize;

//
//
//
//
//

if (r==0)
{
workStep[r][_smax] = phigh+2.0*size*stepMulti;
workStep[r][_smin] = plow -2.0*size*stepMulti;
workStep[r][_trend] = 1;
return(pprice);
}

//
//
//
//
//

workStep[r][_smax] = phigh+2.0*size*stepMulti;
workStep[r][_smin] = plow -2.0*size*stepMulti;
workStep[r][_trend] = workStep[r-1][_trend];
if (pprice>workStep[r-1][_smax]) workStep[r][_trend] = 1;
if (pprice<workStep[r-1][_smin]) workStep[r][_trend] = -1;
if (workStep[r][_trend] == 1) { if (workStep[r][_smin] < workStep[r-1][_smin]) workStep[r][_smin]=workStep[r-1][_smin]; result = workStep[r][_smin]+size*stepMulti; }
if (workStep[r][_trend] == -1) { if (workStep[r][_smax] > workStep[r-1][_smax]) workStep[r][_smax]=workStep[r-1][_smax]; result = workStep[r][_smax]-size*stepMulti; }
trend[Bars-r-1] = workStep[r][_trend];

return(result);
}
Hi, Mladen
Attached the file, please help, I have use the ArrayGetSeries function to check the workStep array, result shows it is not timeseries, not I am not the result is true or not. it make me quite confuse, please correct me!

Thanks!

regards
gervase

Re: Coding Help

405
GERVASE wrote: Mon Jun 19, 2017 8:17 pm Hi, Mladen
Attached the file, please help, I have use the ArrayGetSeries function to check the workStep array, result shows it is not timeseries, not I am not the result is true or not. it make me quite confuse, please correct me!

Thanks!

regards
gervase
It is not a time series
It is a "regular" two dimensional array


Re: Coding Help

407
Hi coders, the open order 'expiration' on below EA...pls help...

//+------------------------------------------------------------------+
//| Break Out [Previous Candle] High Low EA.mq4 |
//+------------------------------------------------------------------+
#property copyright "Ricky Syam"
#property description "Empower Your Heart. Think Positively"
#property description "Empower Your Life. Give Generously"

//---- input parameters
extern double TP = 10;
extern double SL = 10;
extern double RangePoint = 0;
extern double LotSize = 0.1;
extern int MagicNumber = 123456789;
extern bool DelOpposite = false;

#define slip 2
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
double stoplevel = MarketInfo(Symbol(),MODE_STOPLEVEL)*point();
double tik = iVolume(NULL,0,0);
int exp = TimeCurrent() + (Period()*59);
double buyPrice, sellPrice;

if(High[1]-Ask < stoplevel) buyPrice = Ask + RangePoint*point();
else buyPrice = High[1];

if(Bid-Low[1] < stoplevel) sellPrice = Bid - RangePoint*point();
else sellPrice = Low[1];


if(OrdersTotal() == 0)
{
if(tik <= 2)
{
openOrder(Symbol(), OP_BUYSTOP,LotSize,buyPrice,buyPrice-SL*point(), buyPrice+TP*point(),"_Buy_",MagicNumber,exp,Navy);
openOrder(Symbol(), OP_SELLSTOP,LotSize,sellPrice,sellPrice+SL*point(), sellPrice-TP*point(),"_Sell_",MagicNumber,exp,Crimson);
}
}

if(OrdersTotal () == 2)
{
for (int i=0;i<OrdersTotal();i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
if (OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderMagicNumber()==MagicNumber)
{
if(DelOpposite) delPending(OP_SELLSTOP,MagicNumber);
}

if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderMagicNumber()==MagicNumber)
{
if(DelOpposite) delPending(OP_BUYSTOP,MagicNumber);
}
}

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

void openOrder(string simbol, int trade, double lotsize, double price, double sl, double tp,string pesan, int magic, int exp, color warna)
{
int tiket=OrderSend(simbol,trade,lotsize,price,slip,sl,tp,pesan,magic,exp,warna);
if(tiket>0)
{
if(OrderSelect(tiket,SELECT_BY_TICKET,MODE_TRADES)) OrderPrint();
}
else Print("Cannot send order because of : ",GetLastError());
}

void delPending(int trade, int MagicNumber1)
{
for(int i=0;i<OrdersTotal();i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true)
if (OrderType()==trade && OrderMagicNumber()==MagicNumber)
if (OrderDelete(OrderTicket(),CLR_NONE))continue;
}
}

double point()
{
double p;
if(Digits==5 || Digits==3) p = Point*10;
else p = Point;

return(p);
}

Re: Coding Help

408
katana wrote: Wed Jun 21, 2017 12:37 am Hi coders, the open order 'expiration' on below EA...pls help...

//+------------------------------------------------------------------+
//| Break Out [Previous Candle] High Low EA.mq4 |
//+------------------------------------------------------------------+
#property copyright "Ricky Syam"
#property description "Empower Your Heart. Think Positively"
#property description "Empower Your Life. Give Generously"

//---- input parameters
extern double TP = 10;
extern double SL = 10;
extern double RangePoint = 0;
extern double LotSize = 0.1;
extern int MagicNumber = 123456789;
extern bool DelOpposite = false;

#define slip 2
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
double stoplevel = MarketInfo(Symbol(),MODE_STOPLEVEL)*point();
double tik = iVolume(NULL,0,0);
int exp = TimeCurrent() + (Period()*59);
double buyPrice, sellPrice;

if(High[1]-Ask < stoplevel) buyPrice = Ask + RangePoint*point();
else buyPrice = High[1];

if(Bid-Low[1] < stoplevel) sellPrice = Bid - RangePoint*point();
else sellPrice = Low[1];


if(OrdersTotal() == 0)
{
if(tik <= 2)
{
openOrder(Symbol(), OP_BUYSTOP,LotSize,buyPrice,buyPrice-SL*point(), buyPrice+TP*point(),"_Buy_",MagicNumber,exp,Navy);
openOrder(Symbol(), OP_SELLSTOP,LotSize,sellPrice,sellPrice+SL*point(), sellPrice-TP*point(),"_Sell_",MagicNumber,exp,Crimson);
}
}

if(OrdersTotal () == 2)
{
for (int i=0;i<OrdersTotal();i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
if (OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderMagicNumber()==MagicNumber)
{
if(DelOpposite) delPending(OP_SELLSTOP,MagicNumber);
}

if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderMagicNumber()==MagicNumber)
{
if(DelOpposite) delPending(OP_BUYSTOP,MagicNumber);
}
}

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

void openOrder(string simbol, int trade, double lotsize, double price, double sl, double tp,string pesan, int magic, int exp, color warna)
{
int tiket=OrderSend(simbol,trade,lotsize,price,slip,sl,tp,pesan,magic,exp,warna);
if(tiket>0)
{
if(OrderSelect(tiket,SELECT_BY_TICKET,MODE_TRADES)) OrderPrint();
}
else Print("Cannot send order because of : ",GetLastError());
}

void delPending(int trade, int MagicNumber1)
{
for(int i=0;i<OrdersTotal();i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true)
if (OrderType()==trade && OrderMagicNumber()==MagicNumber)
if (OrderDelete(OrderTicket(),CLR_NONE))continue;
}
}

double point()
{
double p;
if(Digits==5 || Digits==3) p = Point*10;
else p = Point;

return(p);
}
Simply pass expiration time to openOrder() function

Re: Coding Help

410
I am trying to set up an export to csv file polling for the following data: (based on my broker platform time)

Yesterday's High
Yesterday's Low
Yesterday's Close
Today's Open.

May I ask exactly what code should I be using to obtain these? I get mixed results, even when I use(say) PERIOD_D1,i+1 so the result is effectively 24 bars back (if I use a H1 chart to mount the exported to csv indicator). Close to giving up so thought I'd ask here.

Any help greatly appreciated.

TAI


Who is online

Users browsing this forum: No registered users and 4 guests