[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 169

 
Vinin >> :

What does i equal?

I just wanted to show the basics - i is defined as:

   int counted_bars = IndicatorCounted(), i;
   i = Bars - counted_bars - 1;

   while( i>=0) {


i.e. starts at the highest bar and goes to zero.

If I keep the Indicator running then for 0 values of i everything starts working (draws rectangles for current

etc.), but there is nothing on the history. I thought maybe it has something to do with the definition of the array!

 
chief2000 писал(а) >>

I only wanted to show the basics - i is defined as:

i.e. it starts at the highest bar and goes to zero.

If I keep the Indicator running then for 0 values of i everything starts working (draws rectangles for current

etc.), but there is nothing on the history. I thought maybe it has something to do with the definition of the array!

Then I will have to show the full code of the indicator.

 
Vinin >> :

Then you will have to show the full code of the indicator.

Here's the code - I've removed everything that wasn't relevant to the problem:

 
#property indicator_chart_window
#property indicator_buffers 4



int    i;


// ------------------------------------------------------
extern int RSI_Periods = 14;
extern int Percent_K   = 14;

//---- buffers
// double Buffer1[];
double Buffer1[99000];

// double Current_RSI,Lowest_RSI,Highest_RSI,sum_K;
// ------------------------------------------------------




  
int init() {
   return(0);
}




// -------------------------------------------------------------------------------
int start() {

   int counted_bars = IndicatorCounted(), i;
   i = Bars - counted_bars - 1;

   while( i>=0) {

// ============================================================================================
      double Current_RSI, Lowest_RSI, Highest_RSI;


      Current_RSI    = iRSI(NULL,0, RSI_Periods,PRICE_TYPICAL, i);
      Highest_RSI    = Current_RSI;
      Lowest_RSI     = Current_RSI;

      for(int x= i+1; x<= Percent_K+ i+1; x++){
         Lowest_RSI  = MathMin( Lowest_RSI, iRSI(NULL,0, RSI_Periods,PRICE_TYPICAL, x));
         Highest_RSI = MathMax( Highest_RSI,iRSI(NULL,0, RSI_Periods,PRICE_TYPICAL, x));
      }


      Buffer1[ i]     = (( Current_RSI- Lowest_RSI) / ( Highest_RSI- Lowest_RSI)) * 100;
// ============================================================================================



   Comment(
      "\n",
      "\n",
      "\n",
      "\n",
      "\n", "Current_RSI = "  , Current_RSI,
      "\n", "Highest_RSI = "  , Highest_RSI,
      "\n", "Lowest_RSI = "  , Lowest_RSI,
      "\n", "Percent_K = "  , Percent_K,
      "\n", "((Current_RSI-Lowest_RSI) / (Highest_RSI-Lowest_RSI)) * 100 = "  , (( Current_RSI- Lowest_RSI) / ( Highest_RSI- Lowest_RSI)) * 100,
      "\n", "iRSI(NULL,0,RSI_Periods,PRICE_TYPICAL,i) = "  , iRSI(NULL,0, RSI_Periods,PRICE_TYPICAL, i),
      "\n", "i = "  , i,
//      "\n", "Percent_K = "  , Percent_K,
//      "\n", "Percent_K = "  , Percent_K,
      "\n",
      "\n",
      "\n", "Buffer1[i+30] = ", Buffer1[ i+30],
      "\n", "Buffer1[i+12] = ", Buffer1[ i+12],
      "\n", "Buffer1[i+1] = ", Buffer1[ i+1],
      "\n", "Buffer1[i] = "  , Buffer1[ i],
      "\n",
      "\n"
   );


      i--;
   }


   return(0);
}
 

Where to start writing void ManagePositions() by knowledgeable conditions

There are arrays
for (tf = 0; tf < 5; tf++)
{
......
int TF[tf] - time frame {5,15,30,60,240}
int signal[tf] - "1" - buy
- "2" - close buy
- "-1" - sell
- "-2" - close sell
int mn_b[tf] - magic_number_buy different for all time frame
int mn_s[tf] - magic_number_sell different for all time frame
}

It should
open
on time frame 5.15 open in one direction up to three orders
- 1 MM order = 1 MONEY
- 2 MM order = 2
- 3 MM order = 3
at time frame 30 open one way up to two orders
- 1 MM order = 2
- 2 MM = 3

at time frame 60 one order is opened to one side
- 1 MM order = 3

at time frame 240 does not open

Dilution of the second and third orders according to different conditions

In total we get no more than 9 orders to one side

Close
When a time frame close sell signal appears, this closes all sell orders in the given time frame
When a time frame close buy signal appears, it closes all buy orders in the current timeframe


Please help

 

Please explain how to identify a ticket or order number if it is known to be the first with a given magic number.

Thank you in advance!

 

I. Kim's branch 'Useful functions from KimIV'.

GetTicketLastPos() function. Page 19.
This function returns the ticket of the last open position or -1.
The function GetIndexLastPos(). P.17
This function shall return the index of the last opened position or -1.
The function IndexByTicket(). P.12
Returns the index (the index number in the general list of set orders or open positions) of the order or position by the ticket. If IndexByTicket() cannot find an order or position with the required ticket, it will return -1





 
rid >> :

I. Kim's branch 'Useful functions from KimIV'.

GetTicketLastPos() function. Page 19.
This function returns the ticket of the last open position or -1.
The function GetIndexLastPos(). P.17
This function shall return the index of the last opened position or -1.
The function IndexByTicket(). P.12
Returns the index (the index number in the general list of set orders or open positions) of the order or position by the ticket. If IndexByTicket() cannot find an order or position with the required ticket, it will return -1





Thank you for your help!

 
chief2000 >> :

Here's the code - I removed everything that wasn't relevant to the problem:


I found the cause:

i = Bars-30 - counted_bars - 1;

instead of .

i = Bars - counted_bars - 1;


Thank you!

 

Another basic question to my code above - the exact same Indicator runs separately

and draws a line in the window below the main one (and another one adds other graphical objects in the upper window).

The two for loops inside while() noticeably overload the computer.

- Is it possible to create rectangles, arrows etc. at the top and a line

(RSI type curve) at the bottom?

Reason: