Coding help - page 281

 
mladen:
stevenpun You say buy have 0.1 lot + 0.2 lot and the sell should be 0.4 lots. Would you mind clarifying it?

Hello mladen , sorry for late reply .

Because have sick for few days .

I have make a picture

For example when the buy have 2 open order (0.1 Lot + 0.2 Lot ) , but suddenly the train have change to sell .

The ea will open a sell by 0.1 Lot , but i want it open for 0.4 Lot .

Is that possible to modify it ?

Files:
lot_explain.jpg  121 kb
 
hermes:
Hello once again,

I tried using the above with a comment but it was displaying the Max only. Can you help with maybe two functions . One displaying the immediate lineprice above Bid and the second the line below Bid . Thank you.

Here's the code.

//+------------------------------------------------------------------+

//| SimpleGrid.mq4+

//+------------------------------------------------------------------+

#include

#include

#property strict

// exported variables

extern string GridStartingPrice = " Start Price to Place Lines ";

extern double GSP = 0.0;

extern int GR = 5;

extern double GridStep = 5;

extern color CGL = Gold;

extern color BGL = Green;

extern color SGL = Red;

extern bool ClearAllObjects = False;

// local variables

double PipValue=1; // this variable is here to support 5-digit brokers

bool Terminated = false;

string LF = "\n"; // use this in custom or utility blocks where you need line feeds

int NDigits = 4; // used mostly for NormalizeDouble in Flex type blocks

int ObjCount = 0; // count of all objects created on the chart, allows creation of objects with unique names

int current = 0;

int init()

{

NDigits = Digits;

if (false) ObjectsDeleteAll(); // clear the chart

Comment(""); // clear the chart

return(0);

}

// Expert start

int start()

{

if (Bars < 10)

{

Comment("Not enough bars");

return (0);

}

if (Terminated == true)

{

Comment("EA Terminated.");

return (0);

}

OnEveryTick7();

return (0);

}

void OnEveryTick7()

{

PipValue = 1;

if (NDigits == 3 || NDigits == 5) PipValue = 10;

CentreGridLine();

}

void CentreGridLine()

{ if (ObjectFind("CGL") == (-1) )

{

{

string objName = "CGL" ;

ObjectCreate(objName, OBJ_HLINE, 0, Time[0],GSP);

ObjectSet(objName, OBJPROP_PRICE1, GSP);

ObjectSet(objName, OBJPROP_COLOR,CGL);

}

TradeLine();

UprBnd();

LwrBnd();

}

}

void TradeLine()

{

int i;

double GridStep1= (GridStep*2);

double BGSP= (GSP+((GridStep/2)*PipValue*Point)) ;

double SGSP= (GSP-((GridStep/2)*PipValue*Point));

double BBGSP= (BGSP-((GridStep*(GR))*PipValue*Point)) ;

double SSGSP= (SGSP+((GridStep*(GR))*PipValue*Point));

{

for(i=0; i<GR;i++)

{

SGL("Sell"+i,BBGSP+GridStep1*i*PipValue*Point);

}

}

{

for(i=0; i<GR;i++)

{

BGL("Buy"+i,SSGSP-GridStep1*i*PipValue*Point);

}

}

}

void BGL(string objName, double price)

{

ObjectCreate(objName, OBJ_HLINE, 0, 0, price);

ObjectSet(objName, OBJPROP_STYLE, STYLE_SOLID);

ObjectSet(objName, OBJPROP_WIDTH, 1);

ObjectSet(objName, OBJPROP_COLOR, BGL);

}

void SGL(string objName, double price)

{

ObjectCreate(objName, OBJ_HLINE, 0, 0, price);

ObjectSet(objName, OBJPROP_STYLE, STYLE_SOLID);

ObjectSet(objName, OBJPROP_WIDTH, 1);

ObjectSet(objName, OBJPROP_COLOR, SGL);

}

void UprBnd()

{ if (ObjectFind("UPRBND") == (-1) )

{

double BGSP= (GSP+((GridStep/2)*PipValue*Point)) ;

double price= (BGSP+((GridStep*(GR))*PipValue*Point)) ;

string objName = "UPRBND" ;

ObjectCreate(objName, OBJ_HLINE, 0, Time[0], price );

ObjectSet(objName, OBJPROP_PRICE1,price);

ObjectSet(objName, OBJPROP_COLOR, DodgerBlue);

ObjectSet(objName, OBJPROP_WIDTH,3);

}

}

void LwrBnd()

{ if (ObjectFind("LWRBND") == (-1) )

{

double SGSP= (GSP-((GridStep/2)*PipValue*Point));

double price= (SGSP-((GridStep*(GR))*PipValue*Point));

string objName = "LWRBND" ;

ObjectCreate(objName, OBJ_HLINE, 0, Time[0], price );

ObjectSet(objName, OBJPROP_PRICE1,price);

ObjectSet(objName, OBJPROP_COLOR, Tomato);

ObjectSet(objName, OBJPROP_WIDTH, 3);

}

}

int deinit()

{

if (ClearAllObjects) ObjectsDeleteAll();

return (0);

}

//+------------------------------------------------------------------+

Hermes

Can you attach the mq4 file?

 
mladen:
Hermes Can you attach the mq4 file?

Here it is. Thanks

Files:
simpleg.mq4  4 kb
 

Hi,

i need help with an Ea i have made, it is related on 2 Moving average and 2 different timeframes to filter trend, i would like to add an RSI indicator in order to filter the trades, setup for example RSI period 8 level 50, if higher than RSI level 50 at crossing we open only sell market order, if lower than RSI level 50 at crossing we open only buy market orders. I attach the Ea, at first was realted to keltnerchannels, but now i want only to be used as Ma1 and Ma2.

Can some body help me with this changes?

Thank you

Files:
 
hermes:
Here it is. Thanks

Hermes

Try this out : simpleg_1.mq4

Files:
simpleg_1.mq4  6 kb
 
daniel1983:
Hi,

i need help with an Ea i have made, it is related on 2 Moving average and 2 different timeframes to filter trend, i would like to add an RSI indicator in order to filter the trades, setup for example RSI period 8 level 50, if higher than RSI level 50 at crossing we open only sell market order, if lower than RSI level 50 at crossing we open only buy market orders. I attach the Ea, at first was realted to keltnerchannels, but now i want only to be used as Ma1 and Ma2.

Can some body help me with this changes?

Thank you

daniel1983

It is almost sure that you will never get crosses of mas and rsis at the same time (meaning - you will almost never get signals). Try it out : make a simple indicator that does what you describe and you shall see how rare those conditions happen at the same time

 
mladen:
daniel1983 It is almost sure that you will never get crosses of mas and rsis at the same time (meaning - you will almost never get signals). Try it out : make a simple indicator that does what you describe and you shall see how rare those conditions happen at the same time

Hi Mladen,

I Mean

- at any level between 0 and 50 only sell

- at any level between 50 and 100 only buy,

not at this same intersection point, crossing can be at any level (43, 41, 18, 25) for buy market orders, confirming with higher time frame trend. I have tested this and about 80% of orders opened looks like with this filter will not open in the opposite direction.

Right now the Ea opens buy order when the crossing is beginning a down trend, with this filter in 80% of the cases it will filter this crossing without entering the order at this point. where those Ma crosses.

In this Ea i have input highertimeframe, but i have made test with better results using lower time frame for filtering trend.

I attach a picture of an example of a test configurated:

For EURUSD

In this case i am using EMA 2 and EMA 67, and RSI (8) timeframe 1min and Hitimeframe 5min, in this case you have a buy market order that is unprofitable, this buy market order happens at the crossing of EMa's but with RSI at a level below 50.

THen you have a sell market order that opens at the crossings but with RSI below 50, and this order is the correct market order i want to filter from all the signals.

Is it possible to do this?

Thank you

Daniel

Files:
rsi_filter.png  32 kb
 
mladen:
Hermes Try this out : simpleg_1.mq4

Hello Mladen,

Its finally working using this . Thank You

void LoopBS()

{

double max =(ObjectGet("UPRBND",OBJPROP_PRICE1));

double min =(ObjectGet("LWRBND",OBJPROP_PRICE1));

for (int i =ObjectsTotal()-1; i>=0; i--)

{

string name = ObjectName(i);

if (StringSubstr(name,0,3)=="Buy")

{

double BS=ObjectGet(name,OBJPROP_PRICE1);

if ((Ask<BS) && (BSmin))

{

max = ObjectGet(name,OBJPROP_PRICE1);

{

Comment(DoubleToStr(BS,Digits)," ");

}

}

}

}

}

 

Inaccurate signals

Inaccurate signals

Dear,craftsmen! Could you signal better to do. M1, M5, M15

Files:
.......png  31 kb
 
DMNIK:
Inaccurate signals Dear,craftsmen! Could you signal better to do. M1, M5, M15

It is simply showing is the last 3 closes are greater or smaller than the last 3 opens. Nothing to improve in that

Reason: