Coding help - page 18

 

Getting Error in EA Help Needed

Getting 1 Trade Only

I need all trade which is generated in icustom ARROW

but

extern string Symbol_1 = "EURUSD";

int magic=9503;

return(0);

int deinit()

{

return(0);

}

datetime newbar;

int start()

{

if(newbar==Time[0])return(0); //

else newbar=Time[0];

double ArrowUp = iCustom(NULL,0,"NBO-System_v1",2,1,10000,2,1);

double ArrowDown = iCustom(NULL,0,"NBO-System_v1",2,1,10000,3,1);//PERIOD_M5

if (ArrowDown >0 && ArrowDown!=2147483647 && OrdersTotal()==0)//!= EMPTY_VALUE )

{

OrderSend(Symbol_1,OP_BUY,0.1, MarketInfo(Symbol_1,MODE_ASK), 2, NULL, NULL, "RapidFire", magic, NULL, FireBrick);

}

if (ArrowUp >0 && ArrowUp!=2147483647 && OrdersTotal()==0)

{

OrderSend(Symbol_1,OP_SELL,0.1, MarketInfo(Symbol_1,MODE_BID), 2, NULL, NULL, "RapidFire", magic, NULL,LimeGreen );

}

return(0);

}

Files:
ea.png  22 kb
 
 
In your EA this condition

OrdersTotal()==0

is preventing opening more than 1 order at a time.If you want to open more than 1 remove that condition but you have to add code to avoid opening multiple orders at the same bar (otherwise you will end with zillion opened orders). You can use a function that would look something like this :

int countOpenedOnACurrentBar()

{

int openedAtBar = 0;

datetime startTime = Time[0];

datetime endTime = Time[0]+Period()*60;

for(int i=0; i < OrdersTotal(); i++)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) break;

if(OrderMagicNumber() != MagicNumber) continue;

if(OrderSymbol() != Symbol()) continue;

if(OrderOpenTime()=endTime) continue;

openedAtBar++;

break;

}

return(openedAtBar);

}

[/PHP]

and then your full condition (for buy) would be like this :

[PHP]if (ArrowDown >0 && ArrowDown!=2147483647 && countOpenedOnACurrentBar()==0)

Iit would prevent opening multiple orders on a same bar (this code does not check the type of the order already opened at a current bar, if you wish to check that too, you have to add some more conditions

vegadigitalco:
Getting 1 Trade Only

I need all trade which is generated in icustom ARROW

but

extern string Symbol_1 = "EURUSD";

int magic=9503;

return(0);

int deinit()

{

return(0);

}

datetime newbar;

int start()

{

if(newbar==Time[0])return(0); //

else newbar=Time[0];

double ArrowUp = iCustom(NULL,0,"NBO-System_v1",2,1,10000,2,1);

double ArrowDown = iCustom(NULL,0,"NBO-System_v1",2,1,10000,3,1);//PERIOD_M5

if (ArrowDown >0 && ArrowDown!=2147483647 && OrdersTotal()==0)//!= EMPTY_VALUE )

{

OrderSend(Symbol_1,OP_BUY,0.1, MarketInfo(Symbol_1,MODE_ASK), 2, NULL, NULL, "RapidFire", magic, NULL, FireBrick);

}

if (ArrowUp >0 && ArrowUp!=2147483647 && OrdersTotal()==0)

{

OrderSend(Symbol_1,OP_SELL,0.1, MarketInfo(Symbol_1,MODE_BID), 2, NULL, NULL, "RapidFire", magic, NULL,LimeGreen );

}

return(0);

}
 

Very Very ThanX for HELPPPPPPPPPPPP

Very Very ThanX for HELPPPPPPPPPPPP

Very Very ThanX for HELPPPPPPPPPPPPP

Very Very ThanX for HELPPPPPPPPPPPP

Very Very ThanX for HELPPPPPPPPPPPPP

mladen:
In your EA this condition

OrdersTotal()==0

is preventing opening more than 1 order at a time.If you want to open more than 1 remove that condition but you have to add code to avoid opening multiple orders at the same bar (otherwise you will end with zillion opened orders). You can use a function that would look something like this :
int countOpenedOnACurrentBar()

{

int openedAtBar = 0;

datetime startTime = Time[0];

datetime endTime = Time[0]+Period()*60;

for(int i=0; i < OrdersTotal(); i++)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) break;

if(OrderMagicNumber() != MagicNumber) continue;

if(OrderSymbol() != Symbol()) continue;

if(OrderOpenTime()=endTime) continue;

openedAtBar++;

break;

}

return(openedAtBar);

}

[/PHP]

and then your full condition (for buy) would be like this :

[PHP]if (ArrowDown >0 && ArrowDown!=2147483647 && countOpenedOnACurrentBar()==0)
Iit would prevent opening multiple orders on a same bar (this code does not check the type of the order already opened at a current bar, if you wish to check that too, you have to add some more conditions
Files:
 

the balance is back-test, live-demo-testing or real-money-trading-balance

EA never cross my mind as semi-automatic entries is good and cool enough (semi mean extra hurdle when you place an order, like fly-by-wire, the computer can rule your entries invalid)

but the ticks-ease is like an fire-ring in video game, there is only few spots in the ring at any one time, that you can put yourself into, other will burn you up quite easily --- this is not the market condition during last 5 to 10 months though, things getting easier

wanna to read those code in the EA above - but those coding is beyond my comprehension limit

 

need alert in above coded trade

Hello mladen,

thanks for your Unique support for me

1more thing, how can i add alert code on buy or sell generated in above code u have suggested.

in live market it dosnt close buy or sell, its just creating new trade.

ThanX in Advance

 

...

Try something like this (this is an example for buy only)
if (ArrowDown >0 && ArrowDown!=2147483647 &&countOpenedOnACurrentBar()==0)

{

OrderSend(Symbol_1,OP_BUY,0.1, MarketInfo(Symbol_1,MODE_ASK), 2, NULL, NULL, "RapidFire", magic, NULL, FireBrick);

if (!IsTesting()) Alert(Symbol_1+" BUY ordere opened at "+TimeToStr(TimeLocal(),TIME_DATE|TIME_SECONDS));

}

vegadigitalco:
Hello mladen,

thanks for your Unique support for me

1more thing, how can i add alert code on buy or sell generated in above code u have suggested.

in live market it dosnt close buy or sell, its just creating new trade.

ThanX in Advance
 

Mind sharing you ea here?I really like how the ea takes the trade.

 

Hello, mLaden,

ThanX again for ur great help:)

only 1 problem remain

in live market it dosnt close previous buy or sell Position, its just creating new trade. ???

ThanX in ADV

mladen:
Try something like this (this is an example for buy only)
if (ArrowDown >0 && ArrowDown!=2147483647 &&countOpenedOnACurrentBar()==0)

{

OrderSend(Symbol_1,OP_BUY,0.1, MarketInfo(Symbol_1,MODE_ASK), 2, NULL, NULL, "RapidFire", magic, NULL, FireBrick);

if (!IsTesting()) Alert(Symbol_1+" BUY ordere opened at "+TimeToStr(TimeLocal(),TIME_DATE|TIME_SECONDS));

}

 

...

vegadigitalco

You have to add closing logic in your EA for that. Either use take profit and stop loss, or use explicit OrderClose() based on some exit rules for that.

vegadigitalco:
Hello, mLaden,

ThanX again for ur great help:)

only 1 problem remain

in live market it dosnt close previous buy or sell Position, its just creating new trade. ???

ThanX in ADV