How to code? - page 188

 

int start()

{

int total,ord,i;

string symbol;

total = OrdersTotal();

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

{

OrderSelect(i,SELECT_BY_POS);

if(OrderSymbol() = Symbol())ord++;

}

if(ord>0) return (0); //Abort! A Position For This Pair is Already Open

//the rest of my program code

}

I've found in reality, I've had to use pauses for a couple seconds in the code due to brokers not instantly opening positions.

 

Want to open 1 POSITION in a direction but No more even if position hits TP.

Checking for open position won't work obviously.

Example-

I don't want another 'BUY' to execute if i had a buy open and it hit the TP. I want it to wait until the MA's cross down and open a SELL with a TP and repeat the whole thing over again.

There's probably an easy way to do this buy my brain is fried or something

THANK YOU

 

Thanks for the info...

SPACECHIMP:
int start()

{

int total,ord,i;

string symbol;

total = OrdersTotal();

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

{

OrderSelect(i,SELECT_BY_POS);

if(OrderSymbol() = Symbol())ord++;

}

if(ord>0) return (0); //Abort! A Position For This Pair is Already Open

//the rest of my program code

}

I've found in reality, I've had to use pauses for a couple seconds in the code due to brokers not instantly opening positions.

Thank you for taking your time to show me this code! I don't think my screen shots were sufficient to explain the logic of what I'm trying to achieve. Here's the explanation in witting...and just as an example I am using a "Buy" scenario. Eventually I would like it to do both "Buy" and "Sell"

Scenario 1: If your buy trade goes with you...--Trade 1, T/P at 70 pips

--Trade 2, 30 pips appart from trade 1, T/P at 70 pips

--Trade 3, 30 pips away from trade 2, T/P at 70 pips

** 210 pips total

Scenario 2: If your buy trade goes against you...put in a trade every 60 pips for three trades and wait for the market to pull back in your direction--trade 1 bad...enter new contingency buy trade at -60 pips from the price of trade 1.

--trade 2 bad...enter new contingency buy trade at -60 pips from the price of trade 2.

--trade 3 bad...enter no more trades

--wait for reversal signs...parabolic dot = bottom...if looks like its moving in our direction then enter a 4th buy

--wait 30 more positive pips then enter 5th buy trade...continue to enter buy trades (6, 7, 8 trade) until it reaches the level that the 3rd contingency trade was at....then wait for the original first 1, and follow the steps of scenario 1.

Is it possible to get the code for this logic? I would be greatly appreciative!!!

 
SPACECHIMP:
Want to open 1 POSITION in a direction but No more even if position hits TP.

Checking for open position won't work obviously.

Example-

I don't want another 'BUY' to execute if i had a buy open and it hit the TP. I want it to wait until the MA's cross down and open a SELL with a TP and repeat the whole thing over again.

There's probably an easy way to do this buy my brain is fried or something

THANK YOU

You need to check your order history to see if an order just closed on the current bar for profit.

Hope that helps.

Lux

 

RSI filter pete

Hello everyone...

i tried to create a simple ea for this indy (rsi filter pete) but after compile, when i launch a backtest nothing happen

i want only

1-buy on green or light green

2-and sell on red or light red

So i ask to some kindly people to help me on this

Thanks in advance

 

MM for EA plz

i want add this condition to my ea

if loss in curent day = 100 ---> close al position, dont take any OP until tomorow

if loss in curent day may take any OP

anybody can help ???

this my EA

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

/*

EA Dengan sinyal dari signal ma

*/

extern double Lots = 0.01;

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

//| |

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

int start()

{

double a1, //ma 10 tf 4h

a2, //ma 10 tf 1h

a3, //ma 10 tf 15m

a4, //ma 10 tf 5m

j, //yesterday low price

k, //yesterday high price

b1, //ma 30 tf 4h

b2, //ma 30 tf 1h

b3, //ma 30 tf 15m

b4; //ma 30 tf 5m

int cnt, ticket, total;

if(Bars<100)

{

Print("bars less than 100");

return(0);

}

// to simplify the coding and speed up access

// data are put into internal variables

a1 = iMA(NULL,240,10,0,MODE_EMA,PRICE_CLOSE,0);

a2 = iMA(NULL,60,10,0,MODE_EMA,PRICE_CLOSE,0);

a3 = iMA(NULL,15,10,0,MODE_EMA,PRICE_CLOSE,0);

a4 = iMA(NULL,5,10,0,MODE_EMA,PRICE_CLOSE,0);

b1 = iMA(NULL,240,30,0,MODE_EMA,PRICE_CLOSE,0);

b2 = iMA(NULL,60,30,0,MODE_EMA,PRICE_CLOSE,0);

b3 = iMA(NULL,15,30,0,MODE_EMA,PRICE_CLOSE,0);

b4 = iMA(NULL,5,30,0,MODE_EMA,PRICE_CLOSE,0);

j = iLow(NULL,60,2);

k = iHigh(NULL,60,2);

total=OrdersTotal();

if(total<1)

{

// no opened orders identified

if(AccountFreeMargin()<(1000*Lots))

{

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

// check for long position (BUY) possibility

if(a1>b1&&

a2>b2&&

a3>b3&&

a4>b4+10*Point)

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"macd sample",16384,0,Green);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

}

// check for short position (SELL) possibility

if(a1<b1&&

a2<b2&&

a3<b3&&

a4<b4-10*Point)

{

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"macd sample",16384,0,Red);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL order : ",GetLastError());

return(0);

}

return(0);

}

// it is important to enter the market correctly,

// but it is more important to exit it correctly...

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && // check for opened position

OrderSymbol()==Symbol()) // check for symbol

{

if(OrderType()==OP_BUY) // long position is opened

{

// should it be closed?

if(Bid>OrderOpenPrice()+100*Point)//if profit > 100

{

OrderModify(OrderTicket(),OrderOpenPrice(),j,0,0,Green);

return(0);

}

if(Bid<OrderOpenPrice()-150*Point)//stop loss

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position

return(0); // exit

}

}

else // go to short position

{

// should it be closed?

if(Ask 100

{

OrderModify(OrderTicket(),OrderOpenPrice(),k,0,0,Green);

return(0);

}

if(Ask>OrderOpenPrice()+150*Point)//stop loss

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position

return(0); // exit

}

}

}

}

return(0);

}

// the end.

 

Hi,

I asked for something similar in another forum a few weeks ago. A kind of CLOSEALL if balance = + x amount or -x amount. I'm not a programmer, but it doesn't seem to be possible (?) because I really only got a few answers which were unclear.

Doesn't seem to be so complicated, but then again, I'm not a programmer.

Good luck,

 

is it possible to open a trading popup window by EA ?

Hello.

I would like to open a trading popup window by EA.

Is it possible ?

If possible to open it by EA, is it possible to open a trading popup window on which the number of the traded volume (the number of lot) is set to a number ordered by EA ?

 
Dax:
Hello.

I would like to open a trading popup window by EA.

Is it possible ?

If possible to open it by EA, is it possible to open a trading popup window on which the number of the traded volume (the number of lot) is set to a number ordered by EA ?

You will have to do this with a dll.

 
Ms_Mel:
Hi,

I asked for something similar in another forum a few weeks ago. A kind of CLOSEALL if balance = + x amount or -x amount. I'm not a programmer, but it doesn't seem to be possible (?) because I really only got a few answers which were unclear.

Doesn't seem to be so complicated, but then again, I'm not a programmer.

Good luck,

Search the forums for closeall EAs. There are a few here