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

 
evillive:
ENUM_DAY_OF_WEEK is int type.
I have tried both int and string and double
 
evillive:
You cannot do it manually, the terminal only draws these icons if you trade using the programme. Alternatively, you can copy the manual trading history to the chart and all trades will be marked.

And if you modify the colour of each open order in this way, will the trade be reflected on the chart?

int i2;  

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

    if (OrderSelect(i2, SELECT_BY_POS, MODE_TRADES)){

      if (OrderSymbol()==Symbol()){  

       if (OrderType()==OP_SELL){

        c=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderTakeProfit(),0,Red);

       }

       if (OrderType()==OP_BUY){   

        c=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderTakeProfit(),0,Green);

       }

      }

     }

    }

   }

 

Decided to display the balance as an indicator when running the visualisation

Balance=AccountBalance();
double price=iCustom(NULL,0,"AccountBalance",Balance,0,1);

from the indicator:

#property indicator_separate_window
#property indicator_buffers 1
#property  indicator_color1  Blue       
//--- input parameters
//--- buffers
extern double       Balance=3;
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(1);
   SetIndexBuffer(0,ExtMapBuffer1);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted(),
   i,limit1;
   limit1=Bars-counted_bars-1;

   for(i=limit1;i>=0;i--)ExtMapBuffer1[i]=Balance;
   
   return(0);
  }
//+------------------------------------------------------------------+

And it's called up too often) It makes the screen go white. The question is rhetorical, what's wrong?

 
Forexman77:

Decided to display the balance as an indicator when running the visualisation

from the indicator:

And it's called up too often) It makes the screen go white. The question is rhetorical, what is wrong?

bool balans;

string balans_S;

///////////////////////////////////////////////////////////////////////////////////////////////////
balans_S=DoubleToStr(AccountBalance(),2)+""+AccountCurrency();
balans=ObjectCreate("Balance", OBJ_LABEL, 0, 0, 0);
balans=ObjectSetText("Balance",balans_S, 14, "Arial", Orange);
balans=ObjectSet("Balance", OBJPROP_CORNER, 1);
balans=ObjectSet("Balance", OBJPROP_XDISTANCE, 20);
balans=ObjectSet("Balance", OBJPROP_YDISTANCE, 20);

///////////////////////////////////////////////////////////////////////////////////////////////////

Insert this code into your Expert Advisor and happiness may come to you

 
woin2110:

bool balans;

string balans_S;

///////////////////////////////////////////////////////////////////////////////////////////////////
balans_S=DoubleToStr(AccountBalance(),2)+""+AccountCurrency();
balans=ObjectCreate("Balance", OBJ_LABEL, 0, 0, 0);
balans=ObjectSetText("Balance",balans_S, 14, "Arial", Orange);
balans=ObjectSet("Balance", OBJPROP_CORNER, 1);
balans=ObjectSet("Balance", OBJPROP_XDISTANCE, 20);
balans=ObjectSet("Balance", OBJPROP_YDISTANCE, 20);

///////////////////////////////////////////////////////////////////////////////////////////////////

Insert this code into your Expert Advisor and happiness may come to you

Thank you. But, I need the balance to be displayed as a line, on the whole section of the chart.
 
evillive:
Strange, it works for me. Maybe there are errors in the log file?

I figured it out, I mistakenly saved the template with the name Debug.tpl with the Expert connected, so there was an extra instruction at the end of the template file:

<expert>
name=ProbaExpert
flags=275
window_num=0
<inputs>
StrPeriod_Direct=
Pips=50
</inputs>
</expert>

Saved template without expert, everything worked, thanks.

 
for(int i=0;i<OrdersHistoryTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
        {  
         if(OrderType()==OP_SELL)
          {  
           if(OrderStopLoss()>OrderOpenPrice())
            {                     
              if(OrdersTotal() == 0)
              {              
               double SELLprice=Bid;  
               int ticket =OrderSend(Symbol(), OP_SELL,Lot*=2,SELLprice, 3,SELLprice+StopLoss* Point, 0, "", MagicNumber,0, clrNONE);
                 
              }
            }            
          }              
        }
     }     

Please advise, I want to make my code to increase LOT in case of a loss trade, and in case of a profit LOT returned to the original volume!

 

To display the balance as a line in the visualisation, took the code from the article.

In the EA:

// сохранение последнего значения баланса в гл. переменную
   GlobalVariableSet( "vGrafBalance", AccountBalance() );

In the indicator:

#property indicator_separate_window
#property indicator_buffers 1
#property  indicator_color1 Blue
 
double balance[];
 
int init()
{
    IndicatorShortName( "vGrafBalance" );
    IndicatorDigits( 2 );
 
    SetIndexStyle( 0, DRAW_LINE );
    SetIndexBuffer( 0, balance );
    SetIndexLabel( 0, "Balance" );
}
int start()
{
    balance[0] = GlobalVariableGet( "vGrafBalance" );
    return(0);
}

The line does not appear. At the end there is only a value on the last, zero bar in the buffer.

 
Forexman77:

To display the balance as a line in the visualisation, took the code from the article.

In the EA:

In the indicator:

The line does not appear. At the end there is only a value on the last, zero bar in the buffer.

To display on all bars, you need to count all bars, as is usually done in indicators.
 
Can you tell me how to change the indicator mfi not to display the volume on the chart, and was a straight vertical line without levels, as in the bottom indicator from the screenshot ? ?
Files:
bw_mfiwe2.mq4  6 kb