[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 617

 
Can you please tell me how to know the lot of the last closed position? For example: the last position closed with a takeaway and we want to increase the lot of the next position.
 
Vadimkin:
Can you please tell me how to declare an indicator superimposed on another indicator (e.g. MA on RSI) in an EA?
only calculate explicitly, e.g. using iMAOnArray() or by my own algorithm.
 
david2:
Can you please tell me how to know the lot of the last closed position? For example: the last position closed with a takeaway and we want to increase the lot of the next position.
int oht = OrdersHistoryTotal();
double last_lot;
OrderSelect(oht-1,SELECT_BY_POS,MODE_HISTORY);
if(NormalizeDouble(OrderClosePrice()-OrderTakeProfit(),Digits)==0) //ордер закрыт по тейкпрофиту
{
   last_lot = OrderLots();
   // ура
}
 
alsu:

Thank you very much, but it is not clear why the brackets are oht-1 and not oht.
 
david2:
Thank you very much, but it is not clear why the brackets are oht-1 and not oht.

the first element of the array has the number 0, the last one has the size-1
 
alsu:

the first element of the array has the number 0, the last size-1
I see.
 
alsu:
only calculate explicitly, e.g. using iMAOnArray() or my own algorithm.

Thank you, I will give it a try.

I have tried a different approach. I created a simple custom MA indicator from RSI. Now I need to formulate conditions for Expert Advisor to open positions by it.

For example:

if (RedLine1>BlueLine1&&RedLine2<BluLine2) OP_BUY

if (RedLine1<BlueLine1&&RedLine2>BluLine2) OP_SELL

But I don't know how to declare them. That is:

double RedLine1 = iCustom(Symbol(), 0, "MARSI", ?, ?, ......, 1);

Could you please look at it. Or someone please take a look at it.

Files:
marsi.mq4  2 kb
 
Vinin:


iHigh(NULL, PERIOD_D1,1) - yesterday's high

iLow(NULL, PERIOD_D1,1) - yesterday's minimum

iOpen(NULL, PERIOD_D1,1) - yesterday's opening

iClose(NULL, PERIOD_D1,1) - yesterday's close

Is it possible to set iHai, iLo, iOpen, and iClose for a specific date, which can be changed in the indicator settings?

extern int data = 08/03/2011

iOpen(NULL, 08/03/2011,1) - what is the opening?

 
Vadimkin:

Thank you, I will give it a try.

I tried a different approach. I created a simple custom MA indicator from RSI. Now I need to formulate conditions for Expert Advisor to open positions with it.

For example:

if (RedLine1>BlueLine1&&RedLine2<BluLine2) OP_BUY

if (RedLine1<BlueLine1&&RedLine2>BluLine2) OP_SELL

But I don't know how to declare them. That is:

double RedLine1 = iCustom(Symbol(), 0, "MARSI", ?, ?, ......, 1);

I wonder if you could have a look at it. Or someone please take a look at it.


In your case there are no external parameters, so you don't need to write anything instead of questions:

double RedLine1 = iCustom(0, 0, "MARSI", line index, bar number);

More specifically,

double RedLine1 = iCustom(0, 0, "MARSI", 0, 1); - red at 1 bar

double RedLine2 = iCustom(0, 0, "MARSI", 0, 2); - red on 2 bar

double BlueLine1 = iCustom(0, 0, "MARSI", 1, 1); - blue on 1 bar

double BlueLine2 = iCustom(0, 0, "MARSI", 1, 2); - Blue on bar 2
 
alsu:

In your case there are no external parameters, so you don't need to write anything instead of questions:

double RedLine1 = iCustom(0, 0, "MARSI", line index, bar number);

Be more specific,

double RedLine1 = iCustom(0, 0, "MARSI", 0, 1); - red at 1 bar

double RedLine2 = iCustom(0, 0, "MARSI", 0, 2); - red on 2 bar

double BlueLine1 = iCustom(0, 0, "MARSI", 1, 1); - blue on 1 bar

double BlueLine2 = iCustom(0, 0, "MARSI", 1, 2); - Blue on bar 2


Thank you very much.
Reason: