You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thanks Ralph but I would be missing the swap , and I want to include the swap profit/loss in the close of the orders decision
But the first loop accumulates both profit and swap, doesn't it?
I was thinking that the Equity figure is the one to compare against what 5 pips would mean for the open lots.... and you then don't need to actually compute the break-even price.
Hi Ralph
I have 3 variables
OrdLots ; in lots and represent the open lots but this will skip the swap
Equity ; this is the total profit loss and this one will include the swap
MinPro ; this is my take profit which is 5 pips + the breakeven point
I can't use OrdLots to find the profit/loss in pips as this will skip the swap
I can't use Equity to find the profit/loss in pips because for that I need to know how much lots,are used but my calculation for the lots skip the swap
Somehow I need to use a function of both OrdLots and Equity to know how many pips are opened
There might be something ready in MT4 that relate the account balance or account equity but I didn't find any
The solution you proposed with thanks will find the profit/loss in pips without considering swap, but I have already put a function for that ... I want to exit at 5 pips above the breakeven with the swap
Compare Times and do loop
Hi Everybody.
I`m very inexperienced with the Mql4 language. I want to compare the openordertime with a Int var and if it meats a certain amount of time and the orders are still open I want to increase the amount of open orders allowed so that I can try to reach a Breakeven situation or Maybe a profit situation and then close all open orders at the same time and set the max orders back to its originally allowed max. Can some one help me or show me code on another post that already does something like this.
I`m using this code but it seems as if it does not work.
// If orders is open for a long time close the orders and try to break even
void TimeProtection()
{
int totalorders = OrdersTotal();
for(int i=totalorders-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
if ( OrderSymbol()==Symbol() )
{
prTime = OrderOpenTime();
prTime = prTime * CallTime;
if (prTime >= TimeCurrent())
{
MaxAllowable_Trades = MaxAllowable_Trades + 3;
flag = 1;
break;
}
}
}
return;
}
I really would like your help on this.
Thanks
Hi Ralph
I have 3 variables
OrdLots ; in lots and represent the open lots but this will skip the swap
Equity ; this is the total profit loss and this one will include the swap
MinPro ; this is my take profit which is 5 pips + the breakeven point
I can't use OrdLots to find the profit/loss in pips as this will skip the swap
I can't use Equity to find the profit/loss in pips because for that I need to know how much lots,are used but my calculation for the lots skip the swap
Somehow I need to use a function of both OrdLots and Equity to know how many pips are opened
There might be something ready in MT4 that relate the account balance or account equity but I didn't find any
The solution you proposed with thanks will find the profit/loss in pips without considering swap, but I have already put a function for that ... I want to exit at 5 pips above the breakeven with the swapAh... maybe I understand... So if you also accumulate profit without swap into EquityNoSwap in the first loop, then you could use that rather than Equity in my "if" statement. (?) Because then the test would be "is there 5 pips profit relative the breakeven+swap price?" which actually is the same as "is there 5 pips profit ignoring the swap?" (or maybe I still don't understand)
Basically "profits+swap" is relative "breakeven", and thus "profits" is relative "breakeven+swap", and "profits" is distributed over "OrdLots". All in all you still don't need to determine an actual pips price for "breakeven".
Best EA coding idea
I start this tread for getting some help here.I am learnig to code for the indicator attached .however it did not work out.Could anybody help? It is a very reliable indicator and if somebody could make a EA for it .it is almost a holy grail.tia.
Basic priciple is:
1.open Sell position when red arrow appear,
2open buy position when white arrow appear and automaticly close all th esell position/positions.
3.apply for any timeframe .
4.no stop loss,
5.add order function.
Loking forward to response!
//+------------------------------------------------------------------+
//| IINWMARROWS.mq4 |
//| Based on EMA_CROSS.mq4 |
//| Copyright ?2006, MetaQuotes Software Corp. |
//| Forex Trading Software: Forex Trading Platform MetaTrader 4 |
//| Last little modified by Iin Zulkarnain |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
//----
double CrossUp[];
double CrossDown[];
extern int FasterMode=3; //0=sma, 1=ema, 2=smma, 3=lwma
extern int FasterMA= 3;
extern int SlowerMode=3; //0=sma, 1=ema, 2=smma, 3=lwma
extern int SlowerMA= 3;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit, i, counter;
double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, fasterMAafter, slowerMAafter;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
//----
limit=Bars-counted_bars;
for(i=0; i<=limit; i++)
{
counter=i;
Range=0;
AvgRange=0;
for(counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;
fasterMAnow=iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i);
fasterMAprevious=iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i+1);
fasterMAafter=iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i-1);
//----
slowerMAnow=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i);
slowerMAprevious=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i+1);
slowerMAafter=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i-1);
if ((fasterMAnow > slowerMAnow) && (fasterMAprevious slowerMAafter))
{
CrossUp=Low - Range*0.5;
}
else if ((fasterMAnow slowerMAprevious) && (fasterMAafter < slowerMAafter))
{
CrossDown=High + Range*0.5;
}
}
return(0);
}
//+------------------------------------------------------------------+this thread for learning how to code properly,I am learning to code for
To the great and brave coders
can any one add max positions for this EA
or let it to run one position only ?
thanks in advance
Post Deleted
off topic question
İs it possible to data sniff from unopen source programme?
They have the poor programming language(similar to Metastock but poorer, no ''previous'' function allowed).They only allow their own indicators and they have the data monopoly(by the law).İt is not possible to write a DLL extension to get my indicators running in real time enviroment.I have heard something like ''port listening function in excell'' but I have no idea what it is.
All the programmers respond much appreciated.
Open order for a different pair
Hi,
is there any way to open an order for a different currency pair.
For example, the EA is running in a EURUSD chart, but I want to open an order for USDJPY.
Is this possible.
Thanks in advance
OrderSend("USDJPY",OP_BUY,0.1,MarketInfo("USDJPY",MODE_ASK),10,0,0,"Com",0,0,CLR_NONE);