Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 554

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
splxgf: - Thank you very much! Everything works like clockwork!
Here is Igor Kim's breakeven code, converted "splxgf:" instead of points to percentages:
//+----------------------------------------------------------------------------+
//| Author : Kim Igor V. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Version : 23.04.2009 |
//| Description : Move stop level to lossless |
//+----------------------------------------------------------------------------+
//| Parameters: |
//| sy - instrument name ( "" - any symbol, |
//| NULL - current symbol) |
//| op - operation ( -1 - any position) |
//| mn - MagicNumber ( -1 - any magician) |
//+----------------------------------------------------------------------------+
void MovingInWL(string sy=NULL, int op=-1, int mn=-1) {
double po, pp, PercentStep,MoveStoplossLevel,StoplossLevel;
int i, k=OrdersTotal();
if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if ((OrderSymbol()==sy || sy==") && (op<0 || OrderType()==op)) {
if (mn<0 || OrderMagicNumber()==mn) {
po=MarketInfo(OrderSymbol(), MODE_POINT);
if (OrderType()==OP_BUY) {
PercentStep=(OrderTakeProfit()-OrderOpenPrice())/po/(138-23);
MoveStoplossLevel = OrderOpenPrice() + PercentStep*(76-23);
StoplossLevel = OrderOpenPrice() + PercentStep*(51-23);
if (OrderStopLoss()-OrderOpenPrice()<StoplossLevel*po) {
pp=MarketInfo(OrderSymbol(), MODE_BID);
if (pp-OrderOpenPrice()>MoveStoplossLevel*po) {
ModifyOrder(-1, OrderOpenPrice()+StoplossLevel*po, -1);
}
}
}
if (OrderType()==OP_SELL) {
PercentStep=(OrderTakeProfit()-OrderOpenPrice())/po/(138-23);
MoveStoplossLevel = OrderOpenPrice() - PercentStep*(76-23);
StoplossLevel = OrderOpenPrice() - PercentStep*(51-23)
if (OrderStopLoss()==0 || OrderOpenPrice()-OrderStopLoss()<StoplossLevel*po) {
pp=MarketInfo(OrderSymbol(), MODE_ASK);
if (OrderOpenPrice()-pp>MoveStoplossLevel*po) {
ModifyOrder(-1, OrderOpenPrice()-StoplossLevel*po, -1);
}
}
}
}
}
}
}
}
//+----------------------------------------------------------------------------+
Figures:
138 is the takeprofit in % Fibonacci.
23 is order open price in % Fibonacci
76 is % of Fibonacci grid, if price reaches this value, stop loss will be moved to 51% of Fibonacci grid.
Function from e-MovingInWL2 Expert Advisor.
{
Trailing();
double Line11=iCustom(Symbol(), 0, "TDI Red Green", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 4, 1);
double Line12=iCustom(Symbol(), 0, "TDI Red Green", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 4, 2);
double Line21=iCustom(Symbol(), 0, "TDI Red Green", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 5, 1);
if (timeprev == Time[0]) return(0);
timeprev = Time[0];
ma0=iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,1);
ma1=iMA(NULL,0,200,0,MODE_SMA,PRICE_CLOSE,1);
ma2=iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,1);
ma3=iMA(NULL,0,800,0,MODE_SMA,PRICE_CLOSE,1);
if (CountBuy()>5 && Volume[0]==1 && Ask > ma0 && Ask > ma1 && Ask > ma3)
{
if (Line11>Level1&&Line12<Level1&&Line11>Line12)
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Ask-sl*Point, Ask+tp*Point, comment, Magic, 0, Blue);
}
if (CountSell()>5 && Volume[0]==1 && Bid < ma0 && Bid < ma1 && Ask < ma3)
{
if (Line11>Level2&&Line12>Level1&&Line11>Line12)
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Ask+sl*Point,Ask-tp*Point, comment, Magic, 0, Red);
}
return(0);
}
Please help to find an error in the code with the signal to open orders by TDI Red Green indicator.
The tester does not open deals, or opens only one. It does not report any errors.
I have indicated the buffers of the indicator correctly.
I'm just learning mql4 for a few days, I'm a beginner)))
I am thankful in advance for the help!parameter N in it is variable, which means that each time it is changed, the code has to be reworked by adding (or removing) "if" conditions (under corresponding array).
Question - is it possible to use only one "if", but use variable "to" in array names (or something else)? I.e. something like ARRAY_{k}. I know that we can replace arrays with terminal variables, but it's an extreme case. Does such a solution exist for arrays?
I faced this dilemma - let's say there is a loop-for:
parameter N in it is variable, which means that each time you change it, you have to modify code by adding (or deleting) "if" conditions (under corresponding array).
Question - is it possible to use only one "if", but use variable "to" in array names (or something else)? I.e. something like ARRAY_{k}. I know that we can replace arrays with terminal variables, but this is an extreme case. Does such a solution exist for arrays?
You can if it's somehow similar:
You can if it's somehow similar:
Can you describe in words what was meant?
Can you describe in words what was meant?
Sorry, got distracted.
The array index is made part of the identifier.
Here's a simple code.
I want the program to draw a vertical line on EVERY fiftieth candle.
the program will draw a vertical line.
THE PROBLEM IS .
The program exhibits one vertical line ONLY ON THE FIRST CROWN (multiple of 50).
Thank you.
The array index is made part of the identifier.
As far as I understand your solution won't work in my case, but it gave me an idea worth checking out. Thank you!
Here's a simple code.
I want it on EVERY fiftieth candle.
the program was exposing a vertical line.
PROBLEM
The program sets one vertical line ONLY on the FIRST LINE (multiple of 50).
I want it to be the same name for every fiftieth candle.
You are trying to create several objects with the same name and this is not possible. The name has to be unique, like time:
That's first of all. Secondly, where is the loop? How will the script count the candles?
You are trying to create several objects with the same name, but you can't do that. The name of an object must be unique, for example the time:
This is first of all. Secondly, where is the loop? How would the script count candlesticks?
Thank you very much.
If you don't mind, could you write the code?
On each candle divisible by 50 - display a vertical line.
Then I'll immediately understand what's what, and remember it once and for all.
Otherwise I'll be in over my head for a long time.
Thanks again.