You need to, of course! Well, how do you apply this construction to finding the minimum? I can't figure it out by brainstorming.) And I want to learn how to declare an array. I tried it this way:
It comes out -1.
The loop goes through 34 values and the array only contains 33 cells, correct.
To find the maximum, the variable val is assigned a value of 0 (obviously less than any of the values of the indictor).
This means that to find the minimum, we must add a deliberately higher value. You can use EMPTY_VALUE constant or the indicator value directly on some bar among which the minimum is searched.
#property strict#include <Indicators\Trend.mqh>
bool ind;
CiMA MA;
externint pos=1;
externint sl=40;
externint tp=70;
datetime time;
datetime time2;
bool trade=false;
bool trade2=false;
int a,b;
intOnInit()
{
//---
MA.Create(Symbol(),PERIOD_CURRENT,10,6,MODE_EMA,PRICE_CLOSE);//создал машку//---return(INIT_SUCCEEDED);
}
voidOnTick()
{
//---if(IsNewBar()==true)//если новый бар включаемся
{
if(buy(pos)==true)//если цена выше МА продолжаем
{
if(!ExistPositions(Symbol(),-1,-1,0))//если нету открых ордеров продолжаем
{
if(GetTypeLastClosePos(Symbol(),-1)!=OP_BUY)//если тип последней закрытой позиции был не на покупку то тогда только покупаем таким образом я пред остерегаюсь от повторных входов в покупку если цена //все ещо выше МА...но почему то не работает открываются и дальше сделки на покупку если ордер закрылся выше МА....ХОТЯ НЕ ДОЛЖО ТАК КАК Я ОГРАНИЧИЛ ПО ТИПУ ПОЗИЦИИ ПОСЛЕДНЮЮ СДЕЛКУ И ОНИ ДОЛЖНЫ ТОЛЬКО // ЧЕРЕДОВАТСЯ И УЖ НИ КАК НЕ ПОВТОРЯТСЯ ПО НЕСКОЛЬКО РАЗ ПОДРЯД
{
trade=true;
}
if(trade==true)
{
OpenPosition(Symbol(),OP_BUY,0.1,Ask-sl*Point,Ask+tp*Point);
trade=false;
}
}
}
if(sell(pos)==true)
{
if(!ExistPositions(Symbol(),-1,-1,0))
{
if(GetTypeLastClosePos(Symbol(),-1)!=OP_SELL)
{
trade2=true;
}
if(trade2==true)
{
OpenPosition(Symbol(),OP_SELL,0.1,Bid+sl*Point,Bid-tp*Point);
trade=false;
}
}}
}
}
//возвращает истину если закрытие бара с указаной позицией выше МАbool buy(int pos)
{
if(iClose(Symbol(),0,pos)>MA.Main(1))
returntrue;
elsereturnfalse;
}
//+------------------------------------------------------------------+//| возвращает истину если закрытие бара с указаной позицией ниже МА//+------------------------------------------------------------------+bool sell(int pos)
{
if(iClose(Symbol(),0,pos)<MA.Main(1))
returntrue;
elsereturnfalse;
}
ALL FUNCTIONS except the two buy and sell conditions are taken from kim's branch...... please tell me where I went wrong...I need one transaction per intersection
There's not much information in the question though. There's a lot of extremes on the hour bars in the month. And by the way, extrema of what exactly?
I assumed that there are only two monthly extremes - min and max... Well, whatever, at first it was a long code, that's why I asked for help... But then it dawned on me, I managed to fit it into four lines.
You need to, of course! Well, how do you apply this construction to finding the minimum? I can't figure it out by brainstorming.)
It comes out -1.And I want to learn how to declare an array. I tried it this way:
The loop goes through 34 values and the array only contains 33 cells, correct.
And try ArrayMinimum(num_array,WHOLE_ARRAY,0);
... I also want to learn how to declare an array...
If just for training and cognitive purpose...
The period at which minimum and maximum are determined - it should be an external parameter to allow for tuning and optimization.
So, first of all, the array is declared without size:
double val[];The array declaration is done in a common section, not in a function.
In the init function, the size is set to the array:
Now in the start function we fill the array:
Finally , ArrayMaximum() and ArrayMinimum() are applied to the array.
To find the maximum, the variable val is assigned a value of 0 (obviously less than any of the values of the indictor).
This means that to find the minimum, we must add a deliberately higher value. You can use EMPTY_VALUE constant or the indicator value directly on some bar among which the minimum is searched.
Or like this:
The loop goes through 34 values, while the array contains only 33 cells, fix it.
And try ArrayMinimum(num_array,WHOLE_ARRAY,0);
Dear fellow programmers! I'm in trouble, please help me.
I've already racked my brains about this code.
Here is the whole function:
Reaches Print and this is what it outputs:
While ticket: 225299700 is an OP_SELLLIMIT order ticket.
And it modifies the stop loss of this selected order as expected. We don't see OP_BUY, though we surely have them:
What could be the problem? Why is it doing this to me? Please help me understand!
another question about the function
how to make a rectangle draw forward instead of backward, for example five bars forward at a specified price...... and not to redraw it
I've had a look. Thank you.
There's not much information in the question though. There's a lot of extremes on the hour bars in the month. And by the way, extrema of what exactly?