How to code? - page 249

 

How to code?

Hi all

I have a very simple E A based on E MA cross, the profit is a big negative. I would like to reverse the setting code. Anyone can help or tell me, where should I begin?

1. Should I look at the magic number ? What is the magic number function?

How to calculate this number ? or other.....

Thanks !

 
codersguru:
Do you mean how to save to CSV file?

Check this:

Tools - .csv reader

Hi codersguru, any chance of an answer to my post?

 

increase and biddick

Here is a place and a post that might help Problem with Export to csv script - MQL4 forum . Disregard the "problem" part : it works OK. Attaching the expert that nerukomaposted there (so no need for cut and paste) It already export moving average, atr and cci and it is easy to see what needs to be done in order to export any custom indicator

regards

Mladen

 

Nevermind........

 

one order per bar if conditions met

Hello traders,

I have a code that open orders only on Bar open (i.e. 5M chart)

All orders are executed at time i.e. 11.20, 11.25, 11.30 etc.

Maybe anyone of You know how to code to open 1 order per bar when conditions met (i.e. RSI touches 70, sell), but not only on time 11.20, 11.25 ?

My code:

datetime Time0=0;

void start()

{

if((Time0!=Time[0])&& RSI>70) OrderSend(..,OP_SELL,..) Time0=Time[0];

}

Looking forward for Your answers, Thanks

Regards,

suirad

 

Who can code a EA??

Hi,

I trade a very profitable indicator, and I want code the indicator in a EA.

I trade in 15m Timeframe

The EA must trade like the image that I attach.

Thanks all.

Files:
 
mladen:
increase and biddick

Here is a place and a post that might help Problem with Export to csv script - MQL4 forum . Disregard the "problem" part : it works OK. Attaching the expert that nerukomaposted there (so no need for cut and paste) It already export moving average, atr and cci and it is easy to see what needs to be done in order to export any custom indicator

regards

Mladen

Hey mladen I was trying to get an answer on my EA question on the previous page, not the csv question

 

Misunderstood

_______________________________

The first issue in the code you attached there is that there is only order for buying (from this post : https://www.mql5.com/en/forum/173219/page165 this part of code that should open new orders)

// expert open position value

if((AddP()&&Add_Positions&&OP<=MaxOrders)||(OP==0& &!Add_Positions)){

if(OS==1){if(TP==0)TPI=0;else TPI=Bid-TP*Point;if(SL==0)SLI=0;else SLI=Bid+SL*Point;OS=0;return(0);}

if(OB==1){if(TP==0)TPI=0;else TPI=Ask+TP*Point;if(SL==0)SLI=0;else SLI=Ask-SL*Point;{TK=OrderSend(Symbol(),OP_BUY,MML,Ask,Sli p,SLI,TPI,OrSt,Magic,0,Blue);OB=0;return(0);}}

for(j=0;j<OrdersTotal();j++){if(OrderSelect(j,SELE CT_BY_POS,MODE_TRADES)){if(OrderSymbol()==Symbol() &&((OrderMagicNumber()==Magic)||Magic==0)){TrP();} }}return(0);}[/php]So the part for opening sells should be revised (my guess (honoring the logic of the code) is that it should be something like this

// expert open position value

if((AddP()&&Add_Positions&&OP<=MaxOrders)||(OP==0& &!Add_Positions)){

if(OS==1){if(TP==0)TPI=0;else TPI=Bid-TP*Point;if(SL==0)SLI=0;else SLI=Bid+SL*Point; {TK=OrderSend(Symbol(),OP_SELL,MML,Ask,Sli p,SLI,TPI,OrSt,Magic,0,Blue);OS=0;return(0);}}

if(OB==1){if(TP==0)TPI=0;else TPI=Ask+TP*Point;if(SL==0)SLI=0;else SLI=Ask-SL*Point; {TK=OrderSend(Symbol(),OP_BUY ,MML,Ask,Sli p,SLI,TPI,OrSt,Magic,0,Blue);OB=0;return(0);}}

for(j=0;j<OrdersTotal();j++){if(OrderSelect(j,SELE CT_BY_POS,MODE_TRADES)){if(OrderSymbol()==Symbol() &&((OrderMagicNumber()==Magic)||Magic==0)){TrP();} }}return(0);}

As of not closing :

Add an external bool parameter that can be called NoCloses. Then modify the code right before the closing block to be like this :

[php]if (NoCloses) { CB=0; CS=0; } // this will prevent orders closing

for(cnt=0;cnt<OrdersTotal();cnt++){OrderSelect(cnt ,SELECT_BY_POS,MODE_TRADES);

if(OrderType()==OP_BUY&&OrderSymbol()==Symbol()&&( (OrderMagicNumber()==Magic)||Magic==0))

{if(CB==1){OrderClose(OrderTicket(),OrderLots(),Bi d,Slip,Aqua);temp = Bid;return(0);}}

if(OrderType()==OP_SELL&&OrderSymbol()==Symbol()&& ((OrderMagicNumber()==Magic)||Magic==0)){

if(CS==1){OrderClose(OrderTicket(),OrderLots(),Ask ,Slip,Gold);temp = Bid;return(0);}}}double SLI=0,TPI=0;int TK=0;

That way you can easily control the closing from parameters (it would be switchable)

increase:
Hey mladen I was trying to get an answer on my EA question on the previous page, not the csv question
 

Print the price of the last open trade

Hi,

how is possible to print the price of the last open trade ?

Thanks

bb

Netmastro

 

How to code.

Superwoodiecci is the indicator i m currently use, but i want this indicator more effectively on my trading trading session. can someone help me to code, the idea very simple but probably difficult to code it.

CCI always show bar for every candle, and the bar we can see climbing or down. every bar close have their own bar reading examples 100, 95, -40, -60.

every bar have a different reading sometimes same reading due to price have a momentum or price going flat.

the idea is simple, can someone code the indicator that have information about the current bar running & close, then next bar appear & show the information.

examples,

during the price move, current price climbing, reading bar is 90, information beside the CCI show arrow up, until the bar close reading still 90 & information still show up arrow, then next bar appear the reading is 80 means we have curve at the cci bar, in this time the arrow show down, due to reading is smaller than previous bar. and until the bar close the reading still smaller maybe 78, 75, and information beside show down arrow.

let say the down movement on next next bar then bar reading currently 5, arrow still show down due to previous bar smaller, smaller, smaller bar reading. current bar reading is 5, and bar close, then next bar appear and the reading is 10, which mean bar reading bigger than previous, and the information beside show arrow up, until bar close reading still bigger than previous, arrow still show up.

continue from the above, bar close at 10, next bar appear smaller than previous, reading bar 5, the info beside show arrow down until the reading for next bar bigger than previous.

if the reading of next bar same from the current bar or the different reading about 2 or 3 with the current bar do nothing, means if arrow show up, and remain to show up until the reading move than 2 or 3 between previous and current bar reading.

i think the idea very2 simple but to make it probably difficult, if someone can help me to code this idea, your help are really appreciate.

kindly refer the attach for the example of the indicator and information beside the indicator. please allow the indicator to set the period, just additional info.

thanks

compobey.

Files:
arrow_down.jpg  17 kb
arrow_up.jpg  15 kb
Reason: