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

 
r772ra:

It goes something like this, try it out.


No, you don't understand the task.

You need to pass either the variable name or the value of the variable, depending on the situation.

 

Can one variable be assigned to several values?


something like this

int N=(1;2;5;9;15;19)

 
abeiks:

Is it possible to can a single variable be assigned to to a single variable?


something like this

int N=(1;2;5;9;15;19)

And then how do I figure out which value to use?

Or did you mean to declare an array? Then int N[6] = {1, 2, 5, 9, 15, 19};

I don't use such arrays, if I'm wrong, I'll be corrected by a knowledgeable person...


 
AlexeyVik:
And then how can I figure out which value to use?

Or did you mean to declare an array? Then int N[6] = {1, 2, 5, 9, 15, 19};

I don't use such arrays, if I'm mistaken, somebody will correct me...



Thanks! I'm thinking to use this in tests as a restriction trade on certain days of the month. if(Day()==N[6]) !

 

Hello! Please help me...

How can you create a box on a graph, in which you can place a segment of the same graph, knowing the start and end times of the segment.

Thank you...

 

Hello, can you help me add a martingale advisor, so that in case of a losing trade, the next one will open with double lot compared to the previous one.

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

//| Test3.mq4 |

//| Popov Vladimir |

//| http://vk.com/id143715412 |

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

#property copyright "Popov Vladimir"

#property link "http://vk.com/id143715412"


extern double Lots = 0.1;

extern int TakeProfit = 130;

extern int StopLoss = 80;

extern int Slippage = 5;

extern string comment = "Tma bot";

extern int Magic = 123;

extern string Indi = "Indicator data";

extern string TimeFrame = "current time frame";

extern int HalfLength = 20;

extern int Price = PRICE_CLOSE;

extern double ATRMultiplier = 2.0;

extern inttern ATRPeriod = 100;

extern bool Interpolate = true;

extern inttern Indent = 5;


extern inttern KPeriod =5;

extern int DPeriod =3;

extern inttern Slowing =3;



double PriceHigh, PriceLow, SL, TP, PriceMiddle, PriceBuy, StochasticHigh, StochasticLow, PriceSell;

double HighesBuffer[];

double LowesBuffer[];

int ticket1, ticket2;


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

//| expert initialization function |

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

int init()

{


if (Digits == 3 || Digits == 5)

{

TakeProfit *= 10;

StopLoss *= 10;

Slippage *= 10;

}





return(0);

}

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

//| expert deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| expert start function |

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

int start()

{

PriceHigh = iCustom (Symbol (), 0, "Time", TimeFrame, HalfLength, Price, ATRMultiplier, ATRPeriod, Interpolate, 1, 0);

PriceLow = iCustom (Symbol (), 0, "Time", TimeFrame, HalfLength, Price, ATRMultiplier, ATRPeriod, Interpolate, 2, 0);

PriceMiddle = iCustom (Symbol (), 0, "Time", TimeFrame, HalfLength, Price, ATRMultiplier, ATRPeriod, Interpolate, 0, 0);

double lots, Lot;

if (Bid >= PriceHigh && CountSell() == 0)

{

SL = NormalizeDouble(Bid+StopLoss*Point, Digits);

TP = NormalizeDouble(Bid-TakeProfit*Point, Digits);

ticket1 = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, comment, Magic, 0, Red);

if (ticket1 > 0)

{

if(OrderSelect(ticket1, SELECT_BY_TICKET, MODE_TRADES) == true)

OrderModify(ticket1, OrderOpenPrice(), SL, TP, 0);

PriceBuy = NormalizeDouble(OrderOpenPrice() + Indent*Point, Digits);

}

ticket2 = OrderSend(Symbol(), OP_BUYSTOP, Lots, PriceBuy, Slippage, 0, 0, comment, Magic, 0, Green);

if (ticket2 > 0)

{

if (OrderSelect(ticket2, SELECT_BY_TICKET, MODE_TRADES)==true)

{

SL = NormalizeDouble(PriceBuy - StopLoss * Point, Digits);

TP = NormalizeDouble(PriceBuy + TakeProfit * Point, Digits);

OrderModify(ticket2, OrderOpenPrice(), SL, TP, 0);

}

}

}


if(Ask <= PriceLow && Ask <= StochasticLow && CountBuy() == 0)

{

SL = NormalizeDouble(Ask-StopLoss*Point, Digits);

TP = NormalizeDouble(Ask+TakeProfit*Point, Digits);

ticket1 = OrderSend(Symbol(), OP_BUY, Lots, Bid, Slippage, 0, 0, comment, Magic, 0, Blue);

if (ticket1 > 0)

{

if(OrderSelect(ticket1, SELECT_BY_TICKET, MODE_TRADES) == true)

OrderModify(ticket1, OrderOpenPrice(), SL, TP, 0);

PriceSell = NormalizeDouble(OrderOpenPrice() - Indent*Point, Digits);

}

ticket2 = OrderSend(Symbol(), OP_SELLSTOP, Lots, PriceSell, Slippage, 0, 0, comment, Magic, 0, Orange);

if (ticket2 > 0)

{

if (OrderSelect(ticket2, SELECT_BY_TICKET, MODE_TRADES)==true)

{

SL = NormalizeDouble(PriceSell + StopLoss * Point, Digits);

TP = NormalizeDouble(PriceSell - TakeProfit * Point, Digits);

OrderModify(ticket2, OrderOpenPrice(), SL, TP, 0);

}

}

}

if (Ask <= PriceMiddle && CountSell() > 0)

{

for(int i=OrdersTotal()-1; i >=0; i--)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true)

{

if(OrderMagicNumber() == Magic && OrderType() == OP_SELL)

OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Black);

}

}

}

if (Bid >= PriceMiddle && CountBuy() > 0)

{

for(i=OrdersTotal()-1; i >=0; i--)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true)

{

if(OrderMagicNumber() == Magic && OrderType() == OP_BUY)

OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Green);

}

}

}

return(0);

}

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


int CountBuy()

{

int count = 0;

for (int tr = OrdersTotal()-1; tr >= 0; tr --)

{

OrderSelect(tr, SELECT_BY_POS);

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)

{

if (OrderType() == OP_BUY)

count++;

}

}

return (count);

}


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


int CountSell()

{

int count = 0;

for (int tr= OrdersTotal()-1; tr >= 0; tr --)

{

OrderSelect(tr, SELECT_BY_POS);

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)

{

if (OrderType() == OP_SELL)

count++;

}

}

return (count);

}

 
Please advise - there are two custom indicators, both are histogram indicators, both are displayed in a separate window. I think there is no code for this indicator. I think there may be a template (skeleton) in which we can paste the names of indicators or their codes to get an indicator showing their division (fraction). Anybody know anything?
 
AlexeyVik:
And then how do I figure out which value to use?

Or did you mean to declare an array? Then int N[6] = {1, 2, 5, 9, 15, 19};

I don't use such arrays, if I'm mistaken about something, my friends will correct me...



int N[6] = {1, 2, 5, 9, 15, 19};

if(Day()==N[6])!

However, this suggestion did not work - array out of range. ..Testing pass stopped due to acritical error in the EA.

 
abeiks:

int N[6] = {1, 2, 5, 9, 15, 19};

if(Day()==N[6])!

However, this did not work - array out of range. ..Testing pass stopped due to a critical error in the EA.

If you read a little bit about arrays, you would understand that indexing of arrays starts with zero and goes up to dimension-1, i.e. in your case from 0 to 5.
 
AlexeyVik:
If you read a little bit about arrays, you would understand that indexing of arrays starts from zero and goes up to dimension-1, i.e. in your case from 0 to 5.


int N[5] = {1, 2, 5, 9, 15, 19} - too many initializers

Reason: